Package jdistlib
Class NumericalDiscreteDistribution
java.lang.Object
jdistlib.generic.GenericDistribution
jdistlib.NumericalDiscreteDistribution
- All Implemented Interfaces:
AtomAwareDistribution,SupportedDistribution
public class NumericalDiscreteDistribution
extends GenericDistribution
implements SupportedDistribution, AtomAwareDistribution
A finite discrete distribution obtained by normalizing a nonnegative weight
function over a declared set of numeric outcomes.
The weight function is evaluated once during construction. Outcomes are sorted, must be unique and finite, and may be supplied explicitly or as an inclusive integer range. Summation is scaled to avoid overflow when weights have a large common magnitude.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class jdistlib.generic.GenericDistribution
random -
Constructor Summary
ConstructorsConstructorDescriptionNumericalDiscreteDistribution(UnivariateFunction weight, double[] support) Constructs a distribution over an arbitrary finite set of outcomes.NumericalDiscreteDistribution(UnivariateFunction weight, int lowerInclusive, int upperInclusive) Constructs a distribution over every integer in the inclusive range. -
Method Summary
Modifier and TypeMethodDescriptionRuns mass, CDF, quantile, tail, and moment diagnostics.analyzeDistribution(MomentAnalysisOptions settings) Runs diagnostics with user-selected absolute-moment orders and tail split.doubleatomProbability(double x) ReturnsP(X = x); zero means no declared atom atx.builder()Returns a fluent builder for a finite custom discrete distribution.doublecentralMoment(double order) doublecumulative(double x, boolean lowerTail, boolean logP) doubledensity(double x, boolean log) doubleentropy()Shannon entropy in nats.doubleexpectation(UnivariateFunction function) Exactly evaluates E[g(X)] over the retained finite support.fromLogWeights(UnivariateFunction logWeight, double[] support) Constructs over explicit outcomes from unnormalized log-weights.fromLogWeights(UnivariateFunction logWeight, int lowerInclusive, int upperInclusive) Constructs over an inclusive integer range from unnormalized log-weights.doubleReturns the log normalization constant without overflow.doubledoubleReturns the normalization constant, or positive infinity if its magnitude exceeds the representabledoublerange.double[]Returns probabilities corresponding togetSupport().double[]Returns the sorted declared support.doubledoublemode()Returns the smallest outcome having maximum mass.probabilityInterval(double probability) Returns an equal-tail interval; its actual discrete mass may exceed the request.doublequantile(double p, boolean lowerTail, boolean logP) doublerandom()doublerawMoment(double order) Methods inherited from class jdistlib.generic.GenericDistribution
copyBackward, cumulative, cumulative, cumulative, cumulative_hazard, cumulative_hazard, cumulativeInto, density, density, densityInto, getRandomEngine, hazard, hazard, inverse_survival, inverse_survival, quantile, quantile, quantile, quantileInto, random, random, randomInto, setRandomEngine, survival, survival, survival
-
Constructor Details
-
NumericalDiscreteDistribution
Constructs a distribution over an arbitrary finite set of outcomes.- Parameters:
weight- nonnegative unnormalized probability-mass functionsupport- finite, unique numeric outcomes- Throws:
IllegalArgumentException- if the support or a weight is invalid
-
NumericalDiscreteDistribution
public NumericalDiscreteDistribution(UnivariateFunction weight, int lowerInclusive, int upperInclusive) Constructs a distribution over every integer in the inclusive range.
-
-
Method Details
-
builder
Returns a fluent builder for a finite custom discrete distribution. -
fromLogWeights
public static NumericalDiscreteDistribution fromLogWeights(UnivariateFunction logWeight, double[] support) Constructs over explicit outcomes from unnormalized log-weights. -
fromLogWeights
public static NumericalDiscreteDistribution fromLogWeights(UnivariateFunction logWeight, int lowerInclusive, int upperInclusive) Constructs over an inclusive integer range from unnormalized log-weights. -
getSupport
public double[] getSupport()Returns the sorted declared support. -
getLowerBound
public double getLowerBound()- Specified by:
getLowerBoundin interfaceSupportedDistribution
-
getUpperBound
public double getUpperBound()- Specified by:
getUpperBoundin interfaceSupportedDistribution
-
getProbabilities
public double[] getProbabilities()Returns probabilities corresponding togetSupport(). -
getNormalizationConstant
public double getNormalizationConstant()Returns the normalization constant, or positive infinity if its magnitude exceeds the representabledoublerange. -
getLogNormalizationConstant
public double getLogNormalizationConstant()Returns the log normalization constant without overflow. -
analyzeDistribution
Runs mass, CDF, quantile, tail, and moment diagnostics. -
analyzeDistribution
Runs diagnostics with user-selected absolute-moment orders and tail split. -
density
public double density(double x, boolean log) - Specified by:
densityin classGenericDistribution
-
cumulative
public double cumulative(double x, boolean lowerTail, boolean logP) - Specified by:
cumulativein classGenericDistribution
-
quantile
public double quantile(double p, boolean lowerTail, boolean logP) - Specified by:
quantilein classGenericDistribution
-
random
public double random()- Specified by:
randomin classGenericDistribution
-
atomProbability
public double atomProbability(double x) Description copied from interface:AtomAwareDistributionReturnsP(X = x); zero means no declared atom atx.- Specified by:
atomProbabilityin interfaceAtomAwareDistribution
-
getSamplingStrategy
-
getSamplingStrategyExplanation
-
expectation
Exactly evaluates E[g(X)] over the retained finite support. -
rawMoment
public double rawMoment(double order) -
centralMoment
public double centralMoment(double order) -
entropy
public double entropy()Shannon entropy in nats. -
mode
public double mode()Returns the smallest outcome having maximum mass. -
probabilityInterval
Returns an equal-tail interval; its actual discrete mass may exceed the request.
-