Per.Andreas.Brodtkorb 14 years ago
parent 0298945f31
commit 8a0004ba59

@ -6905,13 +6905,13 @@ for k*b >= 0
class boltzmann_gen(rv_discrete): class boltzmann_gen(rv_discrete):
def _pmf(self, k, lambda_, N): def _pmf(self, k, lambda_, N):
fact = (1-exp(-lambda_))/(1-exp(-lambda_*N)) fact = (expm1(-lambda_))/(expm1(-lambda_*N))
return fact*exp(-lambda_*k) return fact*exp(-lambda_*k)
def _cdf(self, x, lambda_, N): def _cdf(self, x, lambda_, N):
k = floor(x) k = floor(x)
return (1-exp(-lambda_*(k+1)))/(1-exp(-lambda_*N)) return (expm1(-lambda_*(k+1)))/(expm1(-lambda_*N))
def _ppf(self, q, lambda_, N): def _ppf(self, q, lambda_, N):
qnew = q*(1-exp(-lambda_*N)) qnew = -q*(expm1(-lambda_*N))
vals = ceil(-1.0/lambda_ * log1p(-qnew)-1) vals = ceil(-1.0/lambda_ * log1p(-qnew)-1)
vals1 = (vals-1).clip(0.0, np.inf) vals1 = (vals-1).clip(0.0, np.inf)
temp = self._cdf(vals1, lambda_, N) temp = self._cdf(vals1, lambda_, N)

Loading…
Cancel
Save