Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-019

Normal PDF Value

Problem

Normal probability density function evaluated at x with mean mu and standard deviation sigma.

f(x) = exp(-(x - mu)^2 / (2 * sigma^2)) / (sigma * sqrt(2 * pi)). Return 0.0 when sigma <= 0.

Hint

The density peaks at the mean with value 1 / (sigma * sqrt(2 * pi)).

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: [0,0,0]
expected: 0
Starter codePython
import math


def normal_pdf_value(x, mu, sigma):
    # Your code here
    pass

4 test cases · run your code against them in the editor