## 2017年11月18日 星期六

### Use Python to Emulate Sampling with Replacement

P [# = 0] = 0.6^10 = 0.006
P [# = 1] = 0.6^9 * 0.4 * 10
P [v <= 0.1] = P [# = 0] + P [# = 1] = 0.046…

[SamplingWithReplacement.py]

[Result]

There are 100 balls in the bin. (40 red balls, 60 green balls)
Select %d balls from the bin with replacement.
Times of replacement               = 10000
Number of red balls in the sample  = 348
Probability                        = 0.034800

There are 1000 balls in the bin. (400 red balls, 600 green balls)
Select %d balls from the bin with replacement.
Times of replacement               = 10000
Number of red balls in the sample  = 469
Probability                        = 0.046900

There are 10000 balls in the bin. (4000 red balls, 6000 green balls)
Select %d balls from the bin with replacement.
Times of replacement               = 10000
Number of red balls in the sample  = 473
Probability                        = 0.047300

There are 100000 balls in the bin. (40000 red balls, 60000 green balls)
Select %d balls from the bin with replacement.
Times of replacement               = 10000
Number of red balls in the sample  = 438
Probability                        = 0.043800

-Count
 這封郵件來自 Evernote。Evernote 是您專屬的工作空間，免費下載 Evernote