15.12.2012 Views

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

SciPy Reference Guide, Release 0.8.dev<br />

Display frozen pmf:<br />

>>> rv = boltzmann(lambda_,N)<br />

>>> x = np.arange(0,np.min(rv.dist.b,3)+1)<br />

>>> h = plt.plot(x,rv.pmf(x))<br />

Check accuracy of cdf and ppf:<br />

>>> prb = boltzmann.cdf(x,lambda_,N)<br />

>>> h = plt.semilogy(np.abs(x-boltzmann.ppf(prb,lambda_,N))+1e-20)<br />

Random number generation:<br />

>>> R = boltzmann.rvs(lambda_,N,size=100)<br />

Custom made discrete distribution:<br />

>>> vals = [arange(7),(0.1,0.2,0.3,0.1,0.1,0.1,0.1)]<br />

>>> custm = rv_discrete(name=’custm’,values=vals)<br />

>>> h = plt.plot(vals[0],custm.pmf(vals[0]))<br />

Boltzmann (Truncated Discrete Exponential)<br />

boltzmann.pmf(k,b,N) = (1-exp(-b))*exp(-b*k)/(1-exp(-b*N)) for k=0,..,N-1<br />

630 Chapter 3. Reference

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!