When I switch out isWinDefault with isWinConfidence I get drastically different results. I felt they should be the same. Is there a bug in my code or a property of statistics that I've misunderstood?
This test is meant to simulate flipping a single coin 1x vs a coin many times.
The question is
If P(x) is 70% then should p(x) * 100 be >= 70 70% of the time, no?
Thanks.
private void TestWin()
{
double headsUp = 0;
double testRuns = 100;
for (double i = 0; i < testRuns; i++)
{
if (IsWinConfidence())
{
headsUp++;
}
}
label1.Text = "Probability of Heads is " + headsUp /testRuns;
}
private bool IsWinDefault()
{
if (r.NextDouble() <= .7)
{
return true;
}
return false;
}
private bool IsWinConfidence()
{
int headsCount = 0;
for (double x = 0; x < 100; x++)
{
if (IsWinDefault())
headsCount++;
}
double pHeadsCount = headsCount / 100d;
if (pHeadsCount >= .7 )
{
return true;
}
else
{
return false;
}
}