help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Value of a random variable X at Time t


From: Brett Green
Subject: Re: Value of a random variable X at Time t
Date: Fri, 11 Jun 2021 18:14:01 -0400


On Fri, Jun 11, 2021 at 3:52 PM umairjamali <umairahmedjamali@gmail.com> 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 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 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)..


reply via email to

[Prev in Thread] Current Thread [Next in Thread]