All problems
Normal Distribution PDF
Problem
Compute the probability density function of a normal distribution with mean mu and standard deviation sigma at point x:
pdf(x) = (1 / (sigma * sqrt(2π))) * exp(-(x - mu)^2 / (2 * sigma^2))
If sigma <= 0, return 0.0.
Hint
Don't forget to square sigma in the denominator of the exponent.
Test cases
case 1
in: [0,0,1]
expected: 0.3989422804014327
case 2
in: [1,0,1]
expected: 0.24197072451914337
case 3
in: [0,0,2]
expected: 0.19947114020071635
case 4
in: [5,5,1]
expected: 0.3989422804014327
case 5
in: [0,0,0]
expected: 0
Starter codePython
import math
def normal_pdf(x, mu, sigma):
# Your code here
pass5 test cases · run your code against them in the editor