While calculating u in pdf function, it should be sigma square
class Gaussian:
"Model univariate Gaussian"
def __init__(self, mu, sigma):
#mean and standard deviation
self.mu = mu
self.sigma = sigma
#probability density function
def pdf(self, datum):
"Probability of a data point given the current parameters"
u = (datum - self.mu) / abs(self.sigma)
y = (1 / (sqrt(2 * pi) * abs(self.sigma))) * exp(-u * u / 2)
return y
#printing model values
def __repr__(self):
return 'Gaussian({0:4.6}, {1:4.6})'.format(self.mu, self.sigma)
While calculating u in pdf function, it should be sigma square