Normal
ExponentialFamilyNormal(loc: Tensor | float, scale: Tensor | float, validate_args: bool | None = None)Univariate Gaussian (Normal) distribution .
The Normal distribution is arguably the most important distribution in probability and statistics. Its probability density function is the iconic bell curve:
where is the location (mean) and is the scale (standard deviation).
Parameters
locTensor or floatscaleTensor or floatloc.validate_argsbool or None= NoneNone.Attributes
Notes
Location-scale family
The Normal distribution is closed under linear transformations: if then . In particular the standard Normal satisfies .
Central Limit Theorem
By the CLT, the (rescaled) sum of i.i.d. random variables with finite mean and variance converges in distribution to a Normal. This explains why the Normal appears naturally across virtually all domains of science and engineering.
Reparameterisation
has_rsample = True — samples are drawn via the standard-Normal
reparameterisation trick:
so gradients flow through and .
Exponential family
The Normal is an exponential-family distribution with natural parameters , and sufficient statistics .
Examples
>>> import lucid.distributions as dist
>>> d = dist.Normal(loc=0.0, scale=1.0)
>>> d.mean
Tensor(0.)
>>> d.variance
Tensor(1.)
>>> x = d.rsample((5,)) # 5 standard-Normal draws
>>> lp = d.log_prob(x) # evaluate log-density at those pointsUsed by 3
Constructors
1__init__
→None__init__(loc: Tensor | float, scale: Tensor | float, validate_args: bool | None = None)Properties
4Mode of the Normal distribution.
The Normal density is symmetric and unimodal; its unique maximum is at .
Returns
TensorThe loc parameter tensor (shape batch_shape).
Standard deviation of the Normal distribution.
Overrides the base-class default (which would compute
variance.sqrt()) for a cheaper, exact result.
Returns
TensorThe scale parameter tensor (shape batch_shape).
Instance methods
5Shannon differential entropy of the Normal distribution.
The Normal maximises entropy among all distributions with fixed mean and variance. The closed-form entropy is
Measured in nats.
Returns
TensorEntropy values of shape batch_shape.
Draw reparameterised samples via the location-scale trick.
Samples are generated as
Because the stochasticity is isolated in
(which does not depend on the parameters), gradients flow back
through both loc () and scale
().
Parameters
sample_shapetuple[int, ...]= ()Returns
TensorSamples of shape sample_shape + batch_shape, attached
to the autograd graph.