Class TSampler.StudentsTSampler
java.lang.Object
org.apache.commons.rng.sampling.distribution.TSampler
org.apache.commons.rng.sampling.distribution.TSampler.StudentsTSampler
- All Implemented Interfaces:
ContinuousSampler, SharedStateContinuousSampler, SharedStateSampler<SharedStateContinuousSampler>
- Enclosing class:
TSampler
Sample from a t-distribution using Bailey's algorithm.
- Since:
- 1.5
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final doubleDegrees of freedom.private static final doubleThe multiplier to convert the least significant 53-bits of alongto a uniformdouble.private static final doubleThreshold for large degrees of freedom.private final DoubleUnaryOperatorFunction to compute pow(x, -2/v) - 1, where v = degrees of freedom. -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)StudentsTSampler(UniformRandomProvider rng, double v) private -
Method Summary
Modifier and TypeMethodDescriptionprivate static doublemakeSignedDouble(long bits) Creates a signed double in the range[-1, 1).doublesample()Creates adoublesample.Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ContinuousSampler
samples, samples
-
Field Details
-
LARGE_DF
private static final double LARGE_DFThreshold for large degrees of freedom.- See Also:
-
DOUBLE_MULTIPLIER
private static final double DOUBLE_MULTIPLIERThe multiplier to convert the least significant 53-bits of alongto a uniformdouble.- See Also:
-
df
private final double dfDegrees of freedom. -
powm1
Function to compute pow(x, -2/v) - 1, where v = degrees of freedom.
-
-
Constructor Details
-
StudentsTSampler
StudentsTSampler(UniformRandomProvider rng, double v) - Parameters:
rng- Generator of uniformly distributed random numbers.v- Degrees of freedom.
-
StudentsTSampler
- Parameters:
rng- Generator of uniformly distributed random numbers.source- Source to copy.
-
-
Method Details
-
sample
public double sample()Creates adoublesample.- Returns:
- a sample.
-
withUniformRandomProvider
Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.- Specified by:
withUniformRandomProviderin interfaceSharedStateSampler<SharedStateContinuousSampler>- Specified by:
withUniformRandomProviderin classTSampler- Parameters:
rng- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-
makeSignedDouble
private static double makeSignedDouble(long bits) Creates a signed double in the range[-1, 1). The magnitude is sampled evenly from the 254 dyadic rationals in the range.Note: This method will not return samples for both -0.0 and 0.0.
- Parameters:
bits- the bits- Returns:
- the double
-