Probability Code Problem

When I turn off isWinDefault with isWinConfidence, I get completely different results. I felt that they should be the same. Is there an error in my code or a statistics property that I misunderstood?

This test is designed to simulate the multiple flip of a single 1x coin against a coin.

Question:

If P (x) is 70%, then p (x) * 100 be> = 70 70% of the time, no?

Thank.

    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;
        }


    }
+5
source share
5 answers

Here is a simple answer:

A probability of 70% means that on average 100 coin flips will produce 70 goals up. However, it will sometimes be more than 70, and sometimes less.

, , 100 , 70. 70, 70, 70.

, 70, , " 70 70", , " 50% ".

, .

, IsWinConfidence - , 50.


.

, :

, 70% , 30% ,

, :

100 , 70

, . , .

, :

100 , 70

"" .

, , :

100 , 100 , 100 , 100 .., 100 70

, , , .

.

, , , 100 70, 70.

, ... 70 .

100 000, , 50. , , .

, , , ( ) ,

+2

P (x) 70%, p (x) * 100 be >= 70 70% , ?

. ...

, , - 100 true, 70 . , , 70% , 70 100 "", "" 70% .

+1

IsWinDefault "" 70% , ; IsWinConfidence "" 53,77%, , . . .

+1

true 70% , headsCount ~ 70 ( 100 , 70% ).

pHeadsCount >= .7

50%, ~ 0.7.

0

if (r.NextDouble() <= .7)

if (pHeadsCount >= .7 )

0

All Articles