Qu

normpdf

Builtin index · Statistics & ML

result = normpdf(x, [mu=0], [sigma=1])

Input: x, mu, sigma · Output: result

What it is

Gaussian probability density at x (a number or vector, elementwise) with mean mu (default 0) and standard deviation sigma (default 1).

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = normpdf(x, [mu=0], [sigma=1])
x number or vectornot documented yet
mu number or vector, optional (default 0)not documented yet
sigma number or vector, optional (default 1)not documented yet
result number or vector
Returns a number or vector the same shape as x.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

seed(42)                             # reseed the shared stream

u = rand(3, seed = 1)                # an explicit seed still wins

print("rand draws: {round(u, 3)}")
print("chi2pdf(2, 3):  {round(chi2pdf(2, 3), 4)}")
print("normpdf(0):     {round(normpdf(0), 4)}")

walk = random_walk(20, drift = 0.1, volatility = 1.0, seed = 3)
print("random walk, last value: {round(walk[19], 3)}")
output
rand draws: [0.746, 0.971, 0.444]
chi2pdf(2, 3):  0.2076
normpdf(0):     0.3989
random walk, last value: -3.552

from statistics-ml

How it works

normpdf(x, mu, sigma) — the univariate Gaussian density, elementwise over x. sigma is the standard deviation, not the variance (matches normal/randn's own parameterization).

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.