On this page
statistics.NormalDist
Prev: statistics.multimode | Up: statistics | Next: statistics.pstdev
Rel: statistics.correlation, statistics.covariance, statistics.fmean, statistics.geometric_mean
Ref: docs.python.org — statistics.NormalDist
Tags: #public #python3 #stdlib #statistics
Import
import statistics
from statistics import NormalDist
Signature & Overview
statistics.NormalDist(mu=0.0, sigma=1.0)
Normal distribution of a random variable
Methods & Attributes
NormalDist.cdf(self, x)— Cumulative distribution function. P(X <= x)NormalDist.from_samples(data)— Make a normal distribution instance from sample data.NormalDist.inv_cdf(self, p)— Inverse cumulative distribution function. x : P(X <= x) = p Finds the value of the random variable such that the probability of the variable being less than or equal to that value equals the givenNormalDist.mean(...)— Arithmetic mean of the normal distribution.NormalDist.median(...)— Return the median of the normal distributionNormalDist.mode(...)— Return the mode of the normal distribution The mode is the value x where which the probability density function (pdf) takes its maximum value.NormalDist.overlap(self, other)— Compute the overlapping coefficient (OVL) between two normal distributions.NormalDist.pdf(self, x)— Probability density function. P(x <= X < x+dx) / dxNormalDist.quantiles(self, n=4)— Divide into n continuous intervals with equal probability.NormalDist.samples(self, n, *, seed=None)— Generate n samples for a given mean and standard deviation.NormalDist.stdev(...)— Standard deviation of the normal distribution.NormalDist.variance(...)— Square of the standard deviation.NormalDist.zscore(self, x)— Compute the Standard Score. (x - mean) / stdev Describes x in terms of the number of standard deviations above or below the mean of the normal distribution.
Usage
import statistics
nd = statistics.NormalDist(mu=100, sigma=15)
assert round(nd.cdf(100), 4) == 0.5
assert round(nd.zscore(115), 4) == 1.0
Gotchas
- Zero-dependency normal distribution: Supports
.pdf(),.cdf(),.inv_cdf(),.quantiles(),.overlap(), and+/-linear combinations.
REPL Inspect
from statistics import NormalDist
help(NormalDist)
Linked from
Related notes
- tuts/python3/stdlib_module/statistics/multimode Linked here; links to this page; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/pstdev Linked here; links to this page; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/statistics/correlation Linked here; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/covariance Linked here; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/fmean Linked here; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/geometric_mean Linked here; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/harmonic_mean shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/kde shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/kde_random shared tags: #statistics, #stdlib