NOTE: In this notebook I use the stats
sub-module of scipy
for all statistics functions, including generation of random numbers. There are other modules with some overlapping functionality, e.g., the regular python random module, and the scipy.random
module, but I do not use them here. The stats
sub-module includes tools for a large number of distributions, it includes a large and growing set of statistical functions, and there is a unified class structure. (And namespace issues are minimized.) See https://docs.scipy.org/doc/scipy/reference/stats.html.
import numpy as np
from scipy import stats
import matplotlib as mpl
import matplotlib.pyplot as plt
# Following is an Ipython magic command that puts figures in notebook.
%matplotlib notebook
# M.L. modification of matplotlib defaults
# Changes can also be put in matplotlibrc file,
# or effected using mpl.rcParams[]
plt.style.use('classic')
plt.rc('figure', figsize = (6, 4.5)) # Reduces overall size of figures
plt.rc('axes', labelsize=16, titlesize=14)
plt.rc('figure', autolayout = True) # Adjusts supblot params for new size
plt.figure()
n = np.linspace(0,60,61)
x = np.linspace(0,60,601)
p = stats.poisson.pmf(n,35)
g = stats.norm.pdf(x,35,np.sqrt(35))
plt.scatter(n, p, c='red', label='Poisson')
plt.plot(x, g, label='Gaussian')
plt.xlim(0,60)
plt.axhline(0)
plt.legend();
version_information
is from J.R. Johansson (jrjohansson at gmail.com); see Introduction to scientific computing with Python for more information and instructions for package installation.
version_information
is installed on the linux network at Bucknell
%load_ext version_information
version_information numpy,scipy, matplotlib