如何在Matlab中列出概率实验的所有结果

时间:2017-04-06 18:23:51

标签: matlab

坚持如何在一个矩阵中列出我的所有结果。截至目前,我只从100次重复中得到一个结果。我可以在最后添加一行,这样我就可以从所有100次重复中获得结果吗?

N=1000; %Number of Die Rolls
nreps=100;
count=zeros(1,N+1);     

for n=1:nreps
     n_3H = 0; %count the number of occurrences of the pattern HHH
      flipStates = randi([1, 2], 1, N)  %code to toss a coin N times
      for i=3:N
        if  all(flipStates(i-2:i) == [1,1,1])%condition that the pattern HHH appears at position (i-2,i-1,i)
            n_3H = n_3H+1;
        end
      end
     %ADD CODE TO LIST ALL RESULTS IN COUNT VARIABLE
end

0 个答案:

没有答案
相关问题