mixle.stats.rankings.thurstone module¶
Thurstone ranking model as a normalized Gaussian random-utility approximation.
Each item has latent utility U_i ~ Normal(mu_i, 1) and a ranking is the
descending ordering of those utilities. Exact ranking probabilities are
Gaussian orthant probabilities and have no general closed form.
This implementation exposes an explicitly labelled, deterministic
finite-sample approximation. n_mc common random-utility draws are converted
to ranking counts and combined with positive symmetric Dirichlet smoothing.
That construction is a proper categorical distribution: probabilities are
exactly normalized, a datum’s score cannot depend on its batch neighbors, and
the sampler draws from the same represented law. Every distribution records
the approximation provenance and conservative binomial error scale.
Data type: List[int] – a full ordering of 0..n-1 with x[rank] the
item at that rank, best first.
- class ThurstoneApproximationDiagnostics(method, draws, seed, smoothing, distinct_rankings, support_size, maximum_binomial_standard_error)[source]
Bases:
objectProvenance and uncertainty scale for the approximating categorical law.
- class ThurstoneFitDiagnostics(method, exact_mle, regularized, pseudo_count)[source]
Bases:
objectProvenance for an estimated Thurstone utility vector.
- class ThurstoneDistribution(mu, name=None, keys=None, n_mc=4000, seed=0, smoothing=0.5, fit_diagnostics=None, *, _mu_already_centered=False)[source]
Bases:
SequenceEncodableProbabilityDistributionNormalized finite-sample approximation to a Case V Thurstone law.
- Parameters:
- classmethod compute_capabilities()[source]
Declare the NumPy execution path used to build the approximation.
- density(x)[source]
Return the normalized approximating probability of a full ordering.
- log_density(x)[source]
Return the normalized approximating log-probability of one ordering.
- seq_log_density(x)[source]
Return batch-invariant log-probabilities for encoded full orderings.
- sampler(seed=None)[source]
Return a sampler for this exact approximating categorical law.
- Parameters:
seed (int | None)
- Return type:
ThurstoneSampler
- estimator(pseudo_count=None)[source]
Return a labelled Thurstone-Mosteller pairwise-moment estimator.
- Parameters:
pseudo_count (float | None)
- Return type:
ThurstoneEstimator
- dist_to_encoder()[source]
Return the dense full-ranking encoder used by vectorized methods.
- Return type:
ThurstoneDataEncoder
- class ThurstoneSampler(dist, seed=None)[source]
Bases:
DistributionSamplerDraw exactly from a distribution’s empirical-plus-uniform mixture.
- Parameters:
dist (ThurstoneDistribution)
seed (int | None)
- class ThurstoneAccumulator(dim, keys=None)[source]
Bases:
SequenceEncodableStatisticAccumulatorAccumulate weighted pairwise-precedence counts from full rankings.
- update(x, weight, estimate)[source]
Update pairwise-precedence counts from one full ordering.
- initialize(x, weight, rng)[source]
Initialize precedence counts from one ordering.
- Parameters:
weight (float)
rng (RandomState | None)
- Return type:
None
- seq_update(x, weights, estimate)[source]
Update pairwise-precedence counts from encoded orderings.
- seq_initialize(x, weights, rng)[source]
Initialize precedence counts from a batch of encoded orderings.
- Parameters:
x (ndarray)
weights (ndarray)
rng (RandomState | None)
- Return type:
None
- combine(suff_stat)[source]
Merge validated count and pairwise-precedence statistics.
- from_value(x)[source]
Restore validated accumulator state.
- acc_to_encoder()[source]
Return the ranking encoder compatible with this accumulator.
- Return type:
ThurstoneDataEncoder
- class ThurstoneAccumulatorFactory(dim, keys=None)[source]
Bases:
StatisticAccumulatorFactoryCreate accumulators for Thurstone pairwise-precedence statistics.
- make()[source]
Create an empty Thurstone accumulator.
- Return type:
ThurstoneAccumulator
- class ThurstoneEstimator(dim, n_mc=4000, seed=0, smoothing=0.5, pseudo_count=None, name=None, keys=None)[source]
Bases:
ParameterEstimatorLabelled pairwise-moment estimator for Case V Thurstone utilities.
- Parameters:
- accumulator_factory()[source]
Return a factory for Thurstone sufficient-statistic accumulators.
- Return type:
ThurstoneAccumulatorFactory