大数的累积二项分布

时间:2018-01-24 01:53:09

标签: python normal-distribution binomial-coefficients

我在python中实现了以下函数:

   
const x = [{
    _id: "12345",
    name: "A"
  },
  {
    _id: "67890",
    name: "B"
  }
]

const z = x.map(o => o._id);

console.log(z)

然而,计算产生的值太大而n高(最多255)。我搜索了这些值的近似值,但无济于事。你会怎么做?

2 个答案:

答案 0 :(得分:1)

假设X遵循二项分布,

并且你想要计算P(X> = m),我首先进行连续性校正,使得近似为P(X> = m-0.5),然后我将使用正态近似来近似它。

P((X - np)/ sqrt(np(1-p)) >= (m-0.5-np)/sqrt(np(1-p)) 

是近似值

P(Z >= (m-0.5-np)/sqrt(np(1-p)) 

其中Z是标准正态分布。

References这样的近似值。

答案 1 :(得分:1)

根据Siong的回答,我提出了以下解决方案:

import math

# Cumulative distribution function
def CDF(x):
    return (1.0 + math.erf(x/math.sqrt(2.0)))/2.0

# Approximation of binomial cdf with continuity correction for large n
# n: trials, p: success prob, m: starting successes
def BCDF(p, n, m):
    return 1-CDF((m-0.5-(n*p))/math.sqrt(n*p*(1-p)))
相关问题