How do I calculate PMF with the random numbers I generated?

조회 수: 12 (최근 30일)
deprove55
deprove55 2020년 4월 24일
댓글: deprove55 2020년 4월 24일
So there are two dice, the first being X1 and the second being X2, that are rolled 1,000,000 times. I'm trying to find the PMF of the minimum number in each role, meaning for each number (1 through 6) what is the probability that number will be the smallest number rolled between the two dice. I know how to generate the random numbers and have used the min function to create a 1x1,000,000 matrix containing the smallest number of each role. Is there a pmf function that I can use on this matrix and, if so, how do I use it and plot it?

채택된 답변

the cyclist
the cyclist 2020년 4월 24일
편집: the cyclist 2020년 4월 24일
The PMF is the number of times each value was obtained, divided by the total number of rolls, right?
I think you should be able to use the histcounts function, with the
'Normalization','probablity'
name-value pair as an input parameter.
For example,
x = [1 2 2 3 3 4];
pmf = histcounts(x,[unique(x) Inf],'Normalization','probability')
You could then use bar or histogram to plot it.

추가 답변 (1개)

David Hill
David Hill 2020년 4월 24일
x=randi(6,1000000,2);
y=min(x,[],2);
histogram(y,6,'BinMethod','integer');

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by