Skip to content

Moment ​

The raw moment E[Xr]E[X^r].

Moment(dist, r)exact for r=0,1,2r=0,1,2 via Mean/Variance (E[X2]=Variance+Mean2E[X^2]=Variance+Mean^2); r≥3r\geq 3 stays unevaluated for every distribution EXCEPT BernoulliDistribution, which has an order-independent identity — a distribution-specific formula this generic layer doesn't otherwise have, not an approximation.
Typed signatures
TypePackageApplies
(distribution, integer) -> realstatisticsalways

Domain: Statistics

Details
  • Generic over every distribution this package's Mean/Variance answer, old or new.
  • BernoulliDistribution(pp): X∈{0,1}X\in\{0,1\} so Xr=XX^r=X identically for any r≥1r\geq1, giving Moment(r)=pMoment(r) = p at every order, not just r≤2r\leq2.

Examples

Basic #
live ↗
InMoment(GeometricDistribution(14),0)\mathrm{Moment}(\mathrm{GeometricDistribution}(\frac{1}{4}), 0)Out11
live ↗
InMoment(GeometricDistribution(14),1)\mathrm{Moment}(\mathrm{GeometricDistribution}(\frac{1}{4}), 1)Out33
live ↗
InMoment(GeometricDistribution(14),2)\mathrm{Moment}(\mathrm{GeometricDistribution}(\frac{1}{4}), 2)Out2121
live ↗
InMoment(BernoulliDistribution(25),5)\mathrm{Moment}(\mathrm{BernoulliDistribution}(\frac{2}{5}), 5)Out25\frac{2}{5}
Possible issues #
live ↗
InMoment(GeometricDistribution(14),3)\mathrm{Moment}(\mathrm{GeometricDistribution}(\frac{1}{4}), 3)OutMoment(GeometricDistribution(14),3)\mathrm{Moment}(\mathrm{GeometricDistribution}(\frac{1}{4}), 3)
About
Examples5

See also: CentralMoment, FactorialMoment, Cumulant, Mean, Variance