Skip to content

Instantly share code, notes, and snippets.

@taroyabuki
Last active December 11, 2015 19:28
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 taroyabuki/4648554 to your computer and use it in GitHub Desktop.
Save taroyabuki/4648554 to your computer and use it in GitHub Desktop.
CodeIQ「NumpyとScipyで統計基本復習」https://codeiq.jp/ace/tsuji_shingo/q153
# -*- coding: utf-8 -*-
import numpy as np
import scipy.stats as ss
import matplotlib.pyplot as plt
ss.binom.rvs(10, 0.3)
np.random.binomial(10, 0.3)
data = ss.binom.rvs(10, 0.3, size=1000)
plt.hist(data, range(12))
plt.show()
ss.binom.pmf(6, 10, 0.3)
#0.03675690899999997
np.sum(ss.binom.pmf(range(6, 11), 10, 0.3))
#0.047348987399999959
1 - ss.binom(10, 0.3).cdf(5)
#0.047348987400000042
ss.binom.rvs(10, 0.3, size=[5, 3])
data = ss.binom.rvs(10, 0.3, size=[500, 200])
plt.clf()
plt.hist(list(map(np.mean, data)))
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment