Montecarlo simulations vs rng(0)

2 views (last 30 days)
sudha
sudha on 10 Nov 2020
Answered: Ameer Hamza on 10 Nov 2020
if rng(0) is used in some code which uses rand then is there any use of montecarlo simulations?
montecarlo simulations are done to average the different outputs as rand is used in code i think.
Also i have another doubt.. do we get best output when rng(0) is used?? if not used then for different runs different outputs but the best output always i observed when rng(0) is used.

Answers (1)

Ameer Hamza
Ameer Hamza on 10 Nov 2020
No, rng(0) does not guarantee the best output. It is just a coincidence in your case. The purpose of rng() function is to get the same results at each run. Whether it is useful with Montecarlo depends on how you are using it. If you just place it at the beginning of your script, then it should be fine; however, if you do it inside a loop, then this is not correct.

Community Treasure Hunt

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

Start Hunting!