.. _book_fig_chapter3_fig_binomial_distribution: Example of a Binomial distribution ---------------------------------- Figure 3.9. This shows an example of a binomial distribution with various parameters. We'll generate the distribution using:: dist = scipy.stats.binom(...) Where ... should be filled in with the desired distribution parameters Once we have defined the distribution parameters in this way, these distribution objects have many useful methods; for example: * ``dist.pmf(x)`` computes the Probability Mass Function at values ``x`` in the case of discrete distributions * ``dist.pdf(x)`` computes the Probability Density Function at values ``x`` in the case of continuous distributions * ``dist.rvs(N)`` computes ``N`` random variables distributed according to the given distribution Many further options exist; refer to the documentation of ``scipy.stats`` for more details. .. image:: ../images/chapter3/fig_binomial_distribution_1.png :scale: 100 :align: center .. raw:: html
**Code output:** .. raw:: html
.. literalinclude:: fig_binomial_distribution.txt .. raw:: html
**Python source code:** .. raw:: html
.. literalinclude:: fig_binomial_distribution.py :lines: 27- .. raw:: html
:download:`[download source: fig_binomial_distribution.py] ` .. raw:: html