class
Chi2
extends
GammaChi2(df: Tensor | float, validate_args: bool | None = None)Chi-squared distribution with degrees of freedom.
Distribution of the sum of squares of independent standard Normal random variables. Foundational in classical statistics: arises in the likelihood-ratio test (Wilks' theorem), Pearson's goodness-of-fit, confidence intervals for variance, and many F-test /t-test derivations.
Equivalent to a Gamma with shape and rate : .
Parameters
dfTensor or floatDegrees of freedom . Need not be an integer.
validate_argsbool= NoneIf
True, validate parameter constraints at construction time.Notes
Probability density on :
Moments:
Special cases:
- → squared standard Normal.
- → .
- Sum: .
By the central limit theorem, as .
Examples
>>> import lucid
>>> from lucid.distributions import Chi2
>>> d = Chi2(df=4.0)
>>> d.mean
Tensor(4.0)
>>> d.sample((4,))
Tensor([...])Methods (1)
dunder
__init__
→None__init__(df: Tensor | float, validate_args: bool | None = None)Construct a Chi-squared distribution.
Parameters
dfTensor | floatDegrees of freedom .
validate_argsbool | None= NoneIf
True, validate parameter constraints at construction time.Notes
is a special case of the Gamma distribution:
It arises as the distribution of the sum of squares of independent standard Normal variables, and is fundamental in hypothesis testing (e.g., goodness-of-fit tests, likelihood-ratio tests).
Examples
>>> from lucid.distributions import Chi2
>>> d = Chi2(df=4.0)
>>> d.mean # k = 4
Tensor(4.0)