
September 25th, 2012, 11:34 PM
#1
Testing the gambler's fallacy
I'd like to test out the gambler's fallacy, using random numbers, and 50/50 odds.
In my program I did 100 rolls for each test.
There are 3 specific tests I'd like to perform. I'm using a random number between 1 and 100 for each roll.
First, the chances of getting below 50 on the first roll.
Second, the number of rolls below 50 a third time after already getting below 50 two consecutive times. (each roll would have to have 2 consecutive below 50 numbers or that roll shouldn't count)
Third, the number of rolls below 50 a fourth time after already getting below 50 three consecutive times. (similar to second test)
Just for anyone who is bored or curious. I'm aware that it should be a 50% chance to roll below 50 on any given test as they are all independent events. However, since the odds of rolling 3 or 4 consecutive numbers below 50 is quite low, I was curious to see some actual numbers.
The first test is pretty obvious, here is what I've done for the second test (third test would be similar) and I'm not sure if I've thought this through correctly, so I'd like a second opinion. I'm getting on average roughly 50.
Code:
Random rand = new Random((int)DateTime.Now.Ticks);
int randomNumber = 0;
int total = 0;
for (int i = 0; i < 100; i++)
{
randomNumber = rand.Next(1, 101);
if (randomNumber <= 50)
{
randomNumber = rand.Next(1, 101);
if (randomNumber <= 50)
{
randomNumber = rand.Next(1, 101);
if (randomNumber <= 50)
{
total++;
}
}
else
i;
}
else
i;
}

September 26th, 2012, 08:35 AM
#2
Re: Testing the gambler's fallacy
I would probably approach it a bit differently.
First, I would use the cryptographic RNG instead of the seeded pseudorandom number generator to come closer to truely random results.
Second I would generate all of the rolls and record them in an array or list.
Third, I would use a vastly larger set of test data.
Fourth, I would generate 1s and 0s for easier analysis.
To test you need to count (at each test level) both the desireable next rolls, and undesireable next rolls. If the gambler's fallacy is false, over a sufficiently large data pool, the two totals should be nearly equal throughout the dataset at all test levels. If it is true, analysis should show an increasing propensity for desireable next rolls as the number of previous consecutive undesireable rolls increase.
for those who are curious, the gambler's fallacy basically states that: Although the probability that any given roll will be desireable is 50%, the probablilty of a desireable next roll increases as the number of undesireable rolls in a row increase.
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.
Featured
