mixle.stats.univariate.continuous.student_t module¶
Location-scale Student’s t distributions over real values.
Reference: Johnson, Kotz & Balakrishnan, Continuous Univariate Distributions (2nd ed., Wiley, 1994/95).
- class StudentTSuffStat(sum_, sum2_, count_, anchored=None)[source]
Bases:
tupleA
(sum, sum2, count)sufficient statistic that also carries a shift-anchored side payload.Behaves exactly like the plain 3-tuple everywhere it is indexed, unpacked, or iterated (it is one);
anchoredis the shift-anchored moment payload(anchor, sum_i w_i*(x_i - anchor), sum_i w_i*(x_i - anchor)^2)thatStudentTAccumulatormaintains alongside the raw moments so the M-step’s variance survives large-offset data. Code that doesn’t know about the payload (genericscale_suff_stat, engine kernels, …) sees an ordinary tuple and the estimate falls back to the historical raw path.
- class StudentTDistribution(df, loc=0.0, scale=1.0, name=None, keys=None)[source]
Bases:
SequenceEncodableProbabilityDistributionStudent’s t distribution with degrees of freedom df, location loc, and scale > 0.
- classmethod compute_capabilities()[source]
Describe backend support for generated Student-t kernels.
- classmethod compute_declaration()[source]
Return the structured compute declaration for Student-t distributions.
- static backend_legacy_sufficient_statistics(x, params, engine)[source]
Return per-row Student-t sufficient statistics in accumulator order.
- density(x)[source]
Return the probability density or mass at a single observation.
- log_density(x)[source]
Return the log-density or log-mass at a single observation.
- seq_log_density(x)[source]
Return vectorized log-density values for sequence-encoded observations.
- static backend_log_density_from_params(x, df, loc, scale, engine)[source]
Engine-neutral Student-t log-density from explicit parameters.
- backend_seq_log_density(x, engine)[source]
Engine-neutral vectorized log-density for encoded data.
- classmethod backend_stacked_params(dists, engine)[source]
Return stacked Student-t parameters for a homogeneous mixture kernel.
- classmethod backend_stacked_log_density(x, params, engine)[source]
Return an
(n, k)matrix of Student-t log densities.
- cdf(x)[source]
Cumulative distribution function
P(X <= x)(exact). The continuous ‘index of’ a value.
- quantile(q)[source]
Inverse CDF
F^{-1}(q): the value at cumulative-probability indexq(continuous unranking).
- entropy()[source]
Differential entropy log(scale) + (df+1)/2 [psi((df+1)/2) - psi(df/2)] + log(sqrt(df) B(df/2, 1/2)).
- Return type:
- sampler(seed=None)[source]
Return a sampler for drawing observations from this distribution.
- Parameters:
seed (int | None)
- Return type:
StudentTSampler
- estimator(pseudo_count=None)[source]
Return an estimator for fitting this distribution from data.
- Parameters:
pseudo_count (float | None)
- Return type:
StudentTEstimator
- dist_to_encoder()[source]
Return the data encoder used by this distribution for vectorized methods.
- Return type:
StudentTDataEncoder
- class StudentTSampler(dist, seed=None)[source]
Bases:
DistributionSamplerDraw iid Student’s t observations.
- Parameters:
dist (StudentTDistribution)
seed (int | None)
- class StudentTAccumulator(name=None, keys=None)[source]
Bases:
AnchoredMomentTrack,SequenceEncodableStatisticAccumulatorAccumulate weighted first and second moments for fixed-df t estimation.
Alongside the raw
(sum, sum2, count)the accumulator keeps the conditioning-gated shift-anchored moment track ofAnchoredMomentTrack: the naiveE[x^2]-E[x]^2form the moment M-step needs loses ~``2*log2(abs(mean)/sd)`` bits to cancellation, so sd ~2 data at the Unix-epoch offset 1.7e9 collapsed the fitted scale ontomin_scale– 1.6e8x too small, -86.6 nats per observation, reported withconverged=Trueand an emptynumerical_repairs(). Well-conditioned data never activates the track and accumulates bit-identically to the historical single-pass path.- update(x, weight, estimate)[source]
Accumulate weighted first and second moments for one observation.
- initialize(x, weight, rng)[source]
Initialize statistics from one observation.
- Parameters:
x (float)
weight (float)
rng (RandomState | None)
- Return type:
None
- seq_update(x, weights, estimate)[source]
Accumulate weighted first and second moments from encoded data.
- seq_initialize(x, weights, rng)[source]
Initialize statistics from encoded observations.
- Parameters:
x (ndarray)
weights (ndarray)
rng (RandomState | None)
- Return type:
None
- combine(suff_stat)[source]
Merge another Student-t sufficient-statistic tuple.
- value()[source]
Return accumulated sum, second moment sum, and count.
A plain 3-tuple for every consumer that treats it as one; once the shift-anchored moment track is live it is a
StudentTSuffStatadditionally carrying the anchored moments in its.anchoredattribute, socombine()can fold them in andStudentTEstimator.estimate()can compute a shift-invariant scale.
- from_value(x)[source]
Replace accumulator contents from a sufficient-statistic tuple.
- scale(c)[source]
Scale the accumulated statistics in place by
c, anchored track included.- Parameters:
c (float)
- Return type:
StudentTAccumulator
- acc_to_encoder()[source]
Return the encoder used by this accumulator.
- Return type:
StudentTDataEncoder
- class StudentTAccumulatorFactory(name=None, keys=None)[source]
Bases:
StatisticAccumulatorFactoryFactory for StudentTAccumulator.
- make()[source]
Create a fresh Student-t accumulator.
- Return type:
StudentTAccumulator
- class StudentTEstimator(df=5.0, pseudo_count=None, suff_stat=None, min_scale=1.0e-8, name=None, keys=None)[source]
Bases:
ParameterEstimatorMoment-style fixed-df estimator for Student’s t location and scale.
The exact MLE has no simple closed-form update. This estimator keeps df fixed and uses weighted moments, while generic gradient optimizers such as
mixle.inference.gradient_fit.fit_mle/fit_mapcan fit all three parameters through distribution-owned backend math.The variance moment is formed from shift-anchored statistics whenever the accumulated sufficient statistics carry that payload (see
StudentTAccumulator), which makes the fit SHIFT-EQUIVARIANT: estimating onx + creturnsloc + cwithscaleunchanged, for any constantcthe data can carry – epoch seconds (~1.7e9) and 2**31 included. With a plain raw tuple – statistics the conditioning gate never needed to anchor, or ones that arrived already reduced from an engine kernel or an older serialization – the historical raw path is used bit-identically, andestimatewarns rather than returning a scale it cannot stand behind.min_scale(default 1e-8) is an absolute floor on the returnedscale; it exists for genuinely constant data, and a fit that lands on it is reporting no resolvable spread.- Parameters:
- accumulator_factory()[source]
Return an accumulator factory for fixed-df Student-t moments.
- Return type:
StudentTAccumulatorFactory