Hello everyone !
Context:
I'm trying to compute the probability that a binary sequence "stop" under a certain constraint: if the sequence has a majority of "1" we stop.
ex: Let's say n is the length of the sequence; At n=2 we have : {(00),(01),(10),(11)} possibilities and so at n=3 {(000),(001),(010),(011),(100),(101)} possibilities (note: we didn't took (1,1) car we already stop at n=2) and so on… the probability to stop at n=2 is P(2)=1/4 and at n=3, P(3)=2/6
Question:
My goal is to know what is the probability that at "step n" we stop (ie, how many sequence at n-step "stop" over how many possibilities, taking in account tthat some possibility already stop before)?
Tentative:
The probleme is the more n will grow up the bigger possibilities we have and im not sure the simulation can support for n tend to big number.
So I heard about "Monte carlo simulation"; my idea was to reapeat a certain time the experience. Like I generate a random binary sequence of length-n and i look the majority (ie if sum(sequence)>=n/2 , it's important that this appear in code) and try to generate statistic. I don't know how much "monte carlo simulation" could help me in my problem.
I did this:
rng('shuffle')nb_mort=0; %number of sequence who stop
n=0; %length of sequence
maj=0; %majority
M=1000; %nb of run
for n_run=1:M; while (n <= 100) | (maj <= n/2 ) count=zeros(n); n=n+1 seq = randi([0 1],1,n) maj=sum(seq) end clear n; %I want he start again the loop but renitialize his length
n=0; nb_mort=nb_mort+1; %count(n)=count(n)+1;
%proba_n(n)=count(n)/M;
%nb_mort_mean(n_run)=nb_mort
end
Don't take in account, the last line in comment Proba, because the proba is wrong, i didn't found…
I don't know why also at the end of my "while" he doesnt renialize the n??
Im not super familiar with Monte Carlo and im beginner on Matlab
Thank you for your help
Best Answer