Running frequency plotting from matrix

2 次查看(过去 30 天)
Hi everyone ,I got a homework from Probability course.It says we will roll dice for 200 times and enter the results of that into 200 by 2 matrix (Each result will be a pair, such as (3, 2), which means "3" on the first die, and "2" on the second die).Based on the data we collect , we need to create 6 by 6 matrix that shows running frequency of the pairs ((1,1),(2,2),(3,3)...etc).Running frequency is ; the probability that we want / trials(whole possibility).I already wrote a code about it but i need opinion from everyone how to make it work.
r1=randi(6,200,2) bir=0 i=0 u=0 d=0 bes=0 al=0
a=1 while a>200 if r1(a,:)=(1,1) bir+=1 elseif r1(a,:)=(2,2) i+=1 elseif r1(a,:)=(3,3) u+=1 elseif r1(a,:)=(4,4) d+=1 elseif r1(a,:)=(5,5) bes+=1 elseif r1(a,:)=(6,6) al+=1 end
freq1=bir/200
freq2=i/200
freq3=u/200
freq4=d/200
freq5=bes/200
freq6=al/200
new_matrix=[freq1,freq2,freq3,freq4,freq5,freq6]
plot(new_matrix)
By the way instead of rolling 200 dice i created random matrix.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Spline Postprocessing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by