![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/782648/image.png)
calculate the PMF of y (sum of three dices) and plot it
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello
I pretty confused about how to calculate the PMF of sum of three dices (represented by y such as 3,4,5...18) and how to plot its PMF using Matlab.
I feel like we need to use hist function but have no idea where to start. Hope someone can help me figure out!
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 29 Okt. 2021
Not sure what PMF is. Did you ever actually try histogram()?
numRolls = 1000000;
numDice = 3;
dieFaces = randi([1, 6], numRolls, numDice);
theSums = sum(dieFaces, 2);
histObject = histogram(theSums, 'Normalization','pdf')
grid on;
xlabel('Sums');
ylabel('PDF')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/782648/image.png)
7 Kommentare
Paul
am 31 Okt. 2021
One you know the PMF, for example from the Values of histObject above, the function
doc cumsum
would be of interest for computing the CDF. The functions
doc stem
doc stairs
would be of interest for plotting the CDF.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Descriptive Statistics and Visualization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!