15.12.2012 Views

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

Display frozen pmf:<br />

>>> rv = zipf(a)<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 = zipf.cdf(x,a)<br />

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

Random number generation:<br />

>>> R = zipf.rvs(a,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 />

Zipf distribution<br />

zipf.pmf(k,a) = 1/(zeta(a)*k**a) for k >= 1<br />

634 Chapter 3. Reference

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

Saved successfully!

Ooh no, something went wrong!