Write a program to calculate the probability of two fair dice having sum equal to 7. There are two fair dice and we are interested in seeing whether the sum of the two fair dice having sum equal to 7. Use Monte Carlo Simulation.
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Md Jilani
am 15 Jul. 2019
Bearbeitet: Md Jilani
am 15 Jul. 2019
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/229847/image.png)
2 Kommentare
Guillaume
am 15 Jul. 2019
You've posted the text of your homework, but haven't actually asked a question.
Hopefully, you're not asking us to do your homework for you (which we won't do).
Akzeptierte Antwort
Guillaume
am 15 Jul. 2019
Everything is fine with your code (although the calculation of n7 and nAll could be done with no loop at all), except for your calculation of prob where for some reason you multiply two probabilities together, the theoretical probabilty (n7/nAll) and your monte-carlo probability (count/ntrials), which of course doesn't make much sense.
3 Kommentare
Guillaume
am 15 Jul. 2019
If you have another problem then start a new a question, giving as many details as possible.
If this solution solve your current problem to your liking then please accept it.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!