A truncated discrete exponential discrete random variable.
Discrete random variables are defined from a standard form and may require some shape parameters to complete its specification. Any optional keyword parameters can be passed to the methods of the RV object as given below:
Methods: | boltzmann.rvs(lambda_,N,loc=0,size=1) :
boltzmann.pmf(x,lambda_,N,loc=0) :
boltzmann.cdf(x,lambda_,N,loc=0) :
boltzmann.sf(x,lambda_,N,loc=0) :
boltzmann.ppf(q,lambda_,N,loc=0) :
boltzmann.isf(q,lambda_,N,loc=0) :
boltzmann.stats(lambda_,N,loc=0,moments=’mv’) :
boltzmann.entropy(lambda_,N,loc=0) :
Alternatively, the object may be called (as a function) to fix : the shape and location parameters returning a : “frozen” discrete RV object: : myrv = boltzmann(lambda_,N,loc=0) :
You can construct an aribtrary discrete rv where P{X=xk} = pk : by passing to the rv_discrete initialization method (through the values= : keyword) a tuple of sequences (xk,pk) which describes only those values of : X (xk) that occur with nonzero probability (pk). : |
---|
Examples
>>> import matplotlib.pyplot as plt
>>> numargs = boltzmann.numargs
>>> [ lambda_,N ] = ['Replace with resonable value',]*numargs
Display frozen pmf:
>>> rv = boltzmann(lambda_,N)
>>> x = np.arange(0,np.min(rv.dist.b,3)+1)
>>> h = plt.plot(x,rv.pmf(x))
Check accuracy of cdf and ppf:
>>> prb = boltzmann.cdf(x,lambda_,N)
>>> h = plt.semilogy(np.abs(x-boltzmann.ppf(prb,lambda_,N))+1e-20)
Random number generation:
>>> R = boltzmann.rvs(lambda_,N,size=100)
Custom made discrete distribution:
>>> vals = [arange(7),(0.1,0.2,0.3,0.1,0.1,0.1,0.1)]
>>> custm = rv_discrete(name='custm',values=vals)
>>> h = plt.plot(vals[0],custm.pmf(vals[0]))
Boltzmann (Truncated Discrete Exponential)
boltzmann.pmf(k,b,N) = (1-exp(-b))*exp(-b*k)/(1-exp(-b*N)) for k=0,..,N-1