-
-
Notifications
You must be signed in to change notification settings - Fork 47.1k
Closed
Labels
Description
Hi,
the formula is wrong.
return 1 / sqrt(2 * pi * sigma ** 2) * exp(-((x - mu) ** 2) / 2 * sigma ** 2)
^^^^^^^^^^^^^^^
this actually multiplies with sigma**2 instead of dividing by sigma**2
Instead, for example:
1 / (sqrt(2 * pi) * sigma) * exp(- 0.5 * ( (x - mu) / sigma )**2 )
avoids squaring sigma and taking the sqrt again in the factor before the exponential
and first calculating (x-mu) / sigma and then squaring saves you squaring numerator and denominator separately
in the exponential.
Bye,
Stefan