Skip to content

Instantly share code, notes, and snippets.

@matsuken92
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matsuken92/904970b5daf9dc679ec3 to your computer and use it in GitHub Desktop.
Save matsuken92/904970b5daf9dc679ec3 to your computer and use it in GitHub Desktop.
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as st
from matplotlib import animation as ani
plt.style.use('ggplot')
plt.rc('text', usetex=True)
x = st.poisson.rvs(5, size=30) # 平均=5のポアソン分布に従う乱数を30個生成
print x
lam = 3 # 平均値
n = 10000 # 生成する乱数の数
x = st.poisson.rvs(5, size=n)
plt.figure(figsize=(9,7))
plt.title("Poisson distribution. $\lambda=5$, n={}".format(n))
plt.hist(x, bins=np.max(x), color="lightblue")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment