# Problem in defining Roll of dice experiment as a Stochastic Process in GNU Octave

I defined a vector P that contains my probability distribution for a Dice
Roll, i.e. 6 equal probabilities for each outcome. (1/6, 1/6,1/6,1/6,1/6,1/6)
Now, I want to define a matrix/vector that contains random variables Xt to define another random variable T_5 such that P(T_5=t) = P{Xt is the first random variable with outcome 5}
In other words: I start my process of tossing a die and T_5 is the first time
a 5 is diced.

Should I define two random value generators over a range of values ? How do I achieve a relationship between T_5 and Xt?

How would I define it with an expression?

The notation and definitions are not fully clear to me (what is “t” and is “t” related to “Xt”)?

I understand something like this:

``````N = 10;
Xt = randi (6, 1, N)
Xt =

3   3   5   1   4   3   3   5   6   1

P = @(Xt, t) find (Xt == t, 1);
T_5 = P(Xt, 5)
T_5 = 3
``````

Thank you so much. I also had confusion regarding the notations but I finally confirmed them and learned by heart. So here are the notation and their meanings :

Consider “t” to be the number of experiment. In this case, an experiment represents tossing a die. Hence, T_5=1 is the fact that you do one experiment (i.e. toss a die) and you get a “5”. Now P(T_5=1) is the probability of the above mentioned fact. If you replace “1” by “t”, then this covers the generic case for calculating the probability.

How do I represent the above as an expression in Matlab/GNU Octave? I tried the following :

X= randi([1,6],1,t); (here ‘t’ is the number of times we do an experiment)
T_5 = getting a 5 as result
P(T_5=1)= Probability of getting a 5 in first result
P(T_5=t)= Probability of getting a 5 in ‘t’ number of experiments (t=1 to 30)

Thanks for the explanations. Using Octave to solve this task does not seem super necessary. Is this part of an homework assignment? (In that case I am hesitating to just post the direct answer).

You should think about what is the probability of not obtaining a “5” as outcome after “t” experiments (dice rolls), then “1” minus that probability is what you are looking for.

I did exactly the same. And it got me the right answer. Thanks

You are welcome

``````P = @(t) 1 - (5/6).^t;
plot (1:30, P(1:30));
xlabel ("t (number of dice rolls)")
ylabel ("P(t)")
``````

help me in octave programming

Welcome to the Octave user community.
If you have specific questions about using Octave, please open a dedicated topic instead of posting in an existing one that is already solved.