import matplotlib pyplot as plt from math import sqrt exp pi from scip

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import matplotlib.pyplot as plt
from math import sqrt, exp, pi
from scipy.stats import norm
import seaborn as sns
def norm(x, mu, ksi):
exp_power = -( (x-mu)**2 )/( 2*ksi**2 )
return (1. / ( ksi*sqrt(2*pi) )) * exp( exp_power )
def neuman(mu, ksi, size = 10, scale = 100):
result = []
while len(result) < size:
x = ((2*random.random() - 1) - mu)*5*ksi
y = random.random()
if y < norm(x, mu, ksi):
#print x, y
result.append(x*scale)
return map(lambda x: round(x), result)
sns.distplot(neuman(0, 1, 10000))