How to use the random variables Xt (outcomes of a dice roll) to define another random variable T5 ?

조회 수: 2 (최근 30일)
I am trying to model Dice Rolling (fair die) as a Stochastic process.
I used a row vector p of size 6 with each entry equals to 1/6 in order to represent probabilties of outcomes (1 to 6):
p = ones(1,6)/6
This gives me the following output :
p =
0.1667 0.1667 0.1667 0.1667 0.1667 0.1667
Now, I want to define another random variable T5 such that it shows me the first time I got a 5 when rolling the dice . I tried to plot the outcomes in another matrix [1,2,3,4,5,6] and also tried to do it using a rand function. But I am not getting the desires expression for it.
What would be the MatLab expression for :
P[T5=t] = P { Xt is the first random variable with outcome 5} .

답변 (1개)

Steven Lord
Steven Lord 2021년 6월 12일
I wouldn't use rand here. I'd use randi to directly generate the values of the fair die roll. [If you were later going to simulate a non-fair die then rand would have a role to play, perhaps combined with discretize.]
Since this sounds like a homework assignment I'm only going to describe how I'd do it rather than giving you the code. Try implementing this procedure and if you encounter difficulty show how far you've gotten with that implementation.
Roll the die t times. If the only 5 in that vector of rolls was the last entry, it counts as a success. Otherwise it counts as a failure. Repeat this process as many times as you need to get an accurate estimate of the probability. You could run a block of multiple runs at once by generating a matrix, if you wanted to minimize the number of calls to the random number generator.

카테고리

Help CenterFile Exchange에서 Video games에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by