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 = hypergeom(M,n,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 = hypergeom.cdf(x,M,n,N)<br />

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

Random number generation:<br />

>>> R = hypergeom.rvs(M,n,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 />

Hypergeometric distribution<br />

Models drawing objects from a bin. M is total number of objects, n is total number of Type I objects.<br />

RV counts number of Type I objects in N drawn without replacement from population.<br />

hypergeom.pmf(k, M, n, N) = choose(n,k)*choose(M-n,N-k)/choose(M,N) for N - (M-n)

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

Saved successfully!

Ooh no, something went wrong!