![]() |
better randomization?
I wasn't sure if the randomization is decent on this. It seems to be around the same percentage every time. Which could mean that the theory is proving true, but I'm not quite convinced just yet. What do you guys think?
:
/* ____________________________________________________ |
Re: better randomization?
You're confused by the logic of the project itself not by the program. For the Monty Hall problem, the percentage of the time it's beneficial to change choices is supposed to be 66% (I think). So if you're running a test an infinite numbers of times, the percentage should always come out to the same thing, theoretically. Statistically, you SHOULD be getting around the same percentage every time you run your program. There's nothing wrong with your results. The randomization is fine (for this project).
If you increase tries to 10,000 and run it a few times, you should find that the expected results are even closer together. Then run it on 20,000 tries. Etc. The results will be closer and closer together. |
Re: better randomization?
No need to seed the random number generator every time you call your functions.
This consistently shows 66% for me. I replaced your chooserandom() function with your chooseprize() function. By the way, chosen == bad is a redundant expression. Chosen will never be bad, since your showbad() function asserts that prize != bad.:
#include <stdio.h> |
Re: better randomization?
Quote:
Quote:
Quote:
chosen == bad expression, while I was posting it here.Thank you both for your input. |
Re: better randomization?
If you seed the random number generator every time you call your functions, and each call is milliseconds apart, you're seeding it with a similar value and resetting it. Therefore,
rand()'s return values will actually be less random, as they're all first values generated from very similar seeds. |
| All times are GMT -5. The time now is 4:25 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC