Re: Value of a random variable X at Time t
Doug Stewart <[email protected]>
| Newsgroups | gmane.comp.gnu.octave.general |
|---|---|
| Message-ID | <CAAohRsYoA95LP3UaXRSVPYR4FHvesQ6UQ3QOWjkVmzjPpsO86w@mail.gmail.com> |
On Sat, Jun 12, 2021 at 2:36 AM umairjamali <[email protected]> wrote: > BGreen wrote > > On Fri, Jun 11, 2021 at 3:52 PM umairjamali < > > > umairahmedjamali@ > > > > > > wrote: > > > >> I defined a vector P that contains my probability distribution for a > Dice > >> Roll, i.e. 6 equal probabilities for each outcome. > >> > >> Now, I want to define a variable T5 such that P[T5=t] = P{Xt is the > first > >> random variable with outcome 5} > >> In other words: I start my process of tossing a die and T5 is the first > >> time > >> a 5 is diced. > >> > >> How would I define it with an expression? > >> > >> -- > >> Sent from: > >> https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html > >> > > > > You can use the rand function > > <https://octave.sourceforge.io/octave/function/rand.html> to > > generate > > random numbers, and then scale or round them to be uniform 1 through 6. > > P = floor(6*rand(1,N)+1) > > Then use find > > <https://octav > <https://octave.sourceforge.io/octave/function/find.html>>" mean(29): > out of bound 1 (dimensions are 1x1) (note: variable 'mean' shadows > function)"e.sourceforge.io/octave/function/find.html> > <https://octave.sourceforge.io/octave/function/find.html>>; to > > get the indices of all entries equal to 5: > > T = find(P==5) > > The first time a 5 is rolled is just the first element of T, i.e. it is > > T(1).. > > Thank you. The find function worked and gave me and output of all times at > which T==5. Now , I want to calculate the mean of those times but when I > type mean(T) , it gives error: > > " mean(29): out of bound 1 (dimensions are 1x1) (note: variable 'mean' > shadows > function)" > > Did you notice what the Note says? You have made a new variable named "mean". So now Octave tries to use your new variable when you ask for the "mean" of a vector. Rename your local var. to mean2 or some other name. Use the clear function to remove all old var names. > The output that I got from T=find(P==5) was something like this : > T = > > 10 11 13 14 15 29 > > Is it a matrix or vector? In any case, how do I calculate the mean of this > output? > > > > > -- > Sent from: > https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html > > > -- DAS[image: Certificate for 206392] <https://linuxcounter.net/user/206392.html>