Loading the problem
Before you start
Implement the probability density of the normal distribution.
f(x) = 1 / (sigma * sqrt(2 * pi)) * exp(-(x - mu)^2 / (2 * sigma^2))
x may be a scalar or an array; return the same shape.
This density is the reason squared error is the loss for regression. Maximising
the log likelihood of Gaussian noise is minimising (x - mu)^2, and everything
else in the formula is a constant that the gradient throws away.
def normal_pdf(x, mu, sigma):
Input
normal_pdf(0.0, mu=0.0, sigma=1.0)
Output
np.float64(0.3989422804014327)
Reasoning
At the mean, the exponent is 0, so the density is 1 / sqrt(2 * pi), about 0.3989.
x may be a scalar or an array. Return the same shape.Check runs the visible cases against a fresh kernel. Submit runs the hidden ones too.
⇧↵run cell