Skip to content

Instantly share code, notes, and snippets.

@tsutarou10
Created August 28, 2017 14:40
Show Gist options
  • Save tsutarou10/864bcd773b8d046ed2e8af70ca83f23e to your computer and use it in GitHub Desktop.
Save tsutarou10/864bcd773b8d046ed2e8af70ca83f23e to your computer and use it in GitHub Desktop.
ガウス分布 (1次の場合)
#coding: utf-8
import numpy as np
import matplotlib.pyplot as plt
def norm(x,mu,sigma):
return 1 / pow(2*np.pi*sigma,0.5) * np.exp(-0.5*pow(x-mu,2)/sigma)
if __name__ == "__main__":
N = 1000
x = np.linspace(-6,6, N)
mu = [0.0,-3.4,1.5]
sigma = [1.0,0.25,4.41]
for m,s in zip(mu,sigma):
y = norm(x,m,s)
plt.plot(x,y,label = "meam = " + str(m) + " variance = " + str(s))
plt.legend(loc = "upper right")
plt.title("Univariate Normal Distribution")
plt.savefig("univariate_normal.png")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment