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.
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Respuesta aceptada
Guillaume
el 15 de Jul. de 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 comentarios
Guillaume
el 15 de Jul. de 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.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!