Probability calculations
Compute the likelihood or cumulative probability associated with observed numeric values.
SciPy · Function
scipy.stats.norm represents a normal continuous random variable. Its loc and scale parameters control the mean and standard deviation, and its inherited distribution methods support common probability calculations.
norm represents a normal continuous random variable and provides the generic continuous-distribution methods inherited from rv_continuous. Use loc to set the mean and scale to set the standard deviation; methods such as pdf, cdf, and ppf then operate on that parameterized distribution.
scipy.stats.norm| Name | Type | Description |
|---|---|---|
x | array_like | Input value or values at which an inherited distribution method is evaluated. |
loc | float, optional | Location parameter specifying the mean; defaults to 0 for the standard normal. |
scale | float, optional | Scale parameter specifying the standard deviation; defaults to 1 for the standard normal. |
An rv_continuous distribution object representing a normal continuous random variable; its inherited methods return values appropriate to the selected operation.
scipy.stats.norm models the normal continuous distribution.loc keyword.loc and scale to obtain shifted or scaled normal distributions.rv_continuous.scale is the standard deviation, not the variance.from scipy.stats import norm
mean = 10
std = 2
x = 12
probability_density = norm.pdf(x, loc=mean, scale=std)
probability_below = norm.cdf(x, loc=mean, scale=std)
quantile = norm.ppf(0.95, loc=mean, scale=std)
print(probability_density)
print(probability_below)
print(quantile)Evaluate density, cumulative probability, and a quantile for a normal distribution with mean 10 and standard deviation 2.
Compute the likelihood or cumulative probability associated with observed numeric values.
Convert probabilities into values on a normal distribution using quantiles.
Generate or analyze data under a normal model with chosen mean and standard deviation.
loc and scale mean for norm?loc specifies the distribution's mean, while scale specifies its standard deviation. The object is a continuous random variable with generic methods supplied by rv_continuous.
Follow-up: How would you standardize a value? Compute y = (x - loc) / scale, then use the standard normal methods on y.
norm relate to the standard normal distribution?The standard normal density is evaluated at a real-valued input using the documented normal density formula. A nonstandard normal distribution is obtained by shifting with loc and scaling with scale.
Follow-up: Why does the density divide by scale? Scaling must preserve total probability, so the horizontal stretch is offset by a reciprocal density factor.
norm inherit?norm is an instance of rv_continuous, so it exposes the inherited continuous-distribution methods in addition to the normal-specific distribution definition. This supports operations such as density, cumulative probability, and random-variates workflows through the common API.
Follow-up: What design benefit does the shared base class provide? Code can use a consistent interface across continuous distributions while each distribution supplies its own details.
scipy.stats.rv_continuousscipy.stats.norm.pdfscipy.stats.norm.cdfscipy.stats.norm.ppfscipy.stats.norm.rvs