Skip to content

Instantly share code, notes, and snippets.

@solaris33
Last active November 14, 2017 12:08
Show Gist options
  • Save solaris33/ad569bf3480b849902344c3f96f77860 to your computer and use it in GitHub Desktop.
Save solaris33/ad569bf3480b849902344c3f96f77860 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
mu, sigma = 0, 0.1 # mean and standard deviation
# np.random.nomral 함수를 이용해서 평균 0, 표준편차 0.1인 sample들을 1000개 추출한다.
s = np.random.normal(mu, sigma, 1000)
# sample들의 historgram을 출력한다.
count, bins, ignored = plt.hist(s, 30, normed=True)
# sample들을 이용해서 Gaussian Distribution의 shape을 재구축해서 line으로 그린다.
plt.plot(bins, 1/(sigma * np.sqrt(2 * np.pi)) *
np.exp( - (bins - mu)**2 / (2 * sigma**2) ), linewidth=2, color='r')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment