Skip to content

HistogramDistribution ​

The empirical density of datadata, binned into equal-width bins of width dxdx — piecewise-constant.

HistogramDistribution(data, {dx})bins of width dx, starting at floor(min(data)/dx)*dx.
HistogramDistribution(data, {x0, x1, dx})bins of width dx over the explicit range [x0, x1].
Typed signatures
TypePackageApplies
(list<real>, list<real>) -> distributionstatisticsalways

Domain: Statistics

Details
  • EXPLICIT bins only — Wolfram's own automatic-binning rule ({} with no spec) is not pinned down here and is out of scope. The {dx} form picks x0=⌊min⁡(data)/dx⌋⋅dxx_0 = \lfloor \min(data)/dx \rfloor \cdot dx as the first bin's left edge (a documented choice of this package, not Wolfram's own automatic rule) and covers every data point up to max⁡(data)\max(data); {x0, x1, dx} gives the range explicitly.
  • PDF(x)=counti/(n⋅dx)PDF(x) = count_i / (n \cdot dx) for the bin ii containing xx, 00 outside every bin — piecewise CONSTANT.
  • CDFCDF is piecewise LINEAR (the PDF's antiderivative) — full bins below xx contribute their whole count, xx's own bin a fractional share.
  • Mean=∑icounti⋅midi/nMean = \sum_i count_i \cdot mid_i / n; Variance=E[X2]−Mean2Variance = E[X^2] - Mean^2, with each bin's E[X2∣bin]E[X^2\mid bin] the standard uniform-on-[a,b][a,b] second moment (a2+ab+b2)/3(a^2+ab+b^2)/3.
  • Bin counts are exact integers and every PDF/CDF/Mean/Variance built from them stays exact (rational arithmetic throughout), even though the BINNING itself (which bin a data point falls in) is computed in plain numbers — inherently a floor/division on a numeric position.

Examples

Basic #

bin [1,2) has 2 of the 8 points -> height 2/(8*1).

live ↗
InPDF⁡(HistogramDistribution([1,1,2,2,2,3,3,4],[0,5,1]),32)\operatorname{PDF}(\mathrm{HistogramDistribution}(\bigl\lbrack1, 1, 2, 2, 2, 3, 3, 4\bigr\rbrack, \bigl\lbrack0, 5, 1\bigr\rbrack), \frac{3}{2})Out14\frac{1}{4}
live ↗
InPDF⁡(HistogramDistribution([1,1,2,2,2,3,3,4],[0,5,1]),10)\operatorname{PDF}(\mathrm{HistogramDistribution}(\bigl\lbrack1, 1, 2, 2, 2, 3, 3, 4\bigr\rbrack, \bigl\lbrack0, 5, 1\bigr\rbrack), 10)Out00

P(X < 2) = the two points below 2, out of 8.

live ↗
InCDF⁡(HistogramDistribution([1,1,2,2,2,3,3,4],[0,5,1]),2)\operatorname{CDF}(\mathrm{HistogramDistribution}(\bigl\lbrack1, 1, 2, 2, 2, 3, 3, 4\bigr\rbrack, \bigl\lbrack0, 5, 1\bigr\rbrack), 2)Out14\frac{1}{4}
live ↗
Inmean(HistogramDistribution([1,1,2,2,2,3,3,4],[0,5,1]))\mathrm{mean}(\mathrm{HistogramDistribution}(\bigl\lbrack1, 1, 2, 2, 2, 3, 3, 4\bigr\rbrack, \bigl\lbrack0, 5, 1\bigr\rbrack))Out114\frac{11}{4}

the {dx} form picks x0 = floor(min(data)/dx)*dx = 1 as the first bin's left edge.

live ↗
InPDF⁡(HistogramDistribution([1,2,2,3],[1]),32)\operatorname{PDF}(\mathrm{HistogramDistribution}(\bigl\lbrack1, 2, 2, 3\bigr\rbrack, \bigl\lbrack1\bigr\rbrack), \frac{3}{2})Out14\frac{1}{4}
About
Examples5

See also: ProbabilityDistribution, EmpiricalDistribution, PDF, CDF