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 />

binom<br />

A binom discrete random variable.<br />

Discrete random variables are defined from a standard form and may require some shape parameters to complete<br />

its specification. Any optional keyword parameters can be passed to the methods of the RV object as given<br />

below:<br />

Examples<br />

>>> import matplotlib.pyplot as plt<br />

>>> numargs = binom.numargs<br />

>>> [ n,pr ] = [’Replace with resonable value’,]*numargs<br />

Display frozen pmf:<br />

>>> rv = binom(n,pr)<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 = binom.cdf(x,n,pr)<br />

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

Random number generation:<br />

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

Binomial distribution<br />

Counts the number of successes in n independent trials when the probability of success each time<br />

is pr.<br />

binom.pmf(k,n,p) = choose(n,k)*p**k*(1-p)**(n-k) for k in {0,1,...,n}<br />

614 Chapter 3. Reference

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

Saved successfully!

Ooh no, something went wrong!