Discrete

{A,B,B,C,A,C,C,C}

Coin (head/tail)

Random

Length of a blade of grass

In [1]:
import numpy as np
import matplotlib.pyplot as plt
In [2]:
n = 1000
stretch = 2
shift = 5

pnts = np.random.randn(n)*stretch + shift
print('Mean is %g, std is %g' %(np.mean(pnts),np.std(pnts)))

fig,ax = plt.subplots(1,2,figsize=(6,3))

ax[0].plot(pnts,'s',alpha=.4)
ax[1].hist(pnts,50)

plt.show()
Mean is 4.98903, std is 1.97094
In [3]:
pnts = np.random.rand(n)*stretch + shift - .5*stretch
print('Mean is %g, range is %g' %(np.mean(pnts),np.max(pnts)-np.min(pnts)))

fig,ax = plt.subplots(1,2,figsize=(6,3))

ax[0].plot(pnts,'s',alpha=.4)
ax[1].hist(pnts,50)

plt.show()
Mean is 4.9837, range is 1.99433
In [4]:
lam = 4

pnts = np.random.poisson(lam,n)
print('Mean is %g, variance is %g' %(np.mean(pnts),np.var(pnts))) # mean is equal to variance

fig,ax = plt.subplots(1,2,figsize=(6,3))

ax[0].plot(pnts,'s',alpha=.4)
ax[1].hist(pnts,bins=np.arange(0,np.max(pnts)+1),edgecolor='w')

plt.show()
Mean is 4.005, variance is 4.19898