How can I efficiently calculate the binomial cumulative distribution function?

后端 未结 10 966
你的背包
你的背包 2020-12-07 22:10

Let\'s say that I know the probability of a \"success\" is P. I run the test N times, and I see S successes. The test is akin to tossing an unevenly weighted coin (perhaps

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 22:28

    import numpy as np
    np.random.seed(1)
    x=np.random.binomial(20,0.6,10000) #20 flips of coin,probability of 
                                     heads percentage and 10000 times 
                                      done.
    sum(x>12)/len(x)
    
    The output is 41% of times we got 12 heads.
    

提交回复
热议问题