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

private static final class TSampler.StudentsTSampler extends TSampler
Sample from a t-distribution using Bailey's algorithm.
  • Field Details

    • LARGE_DF

      private static final double LARGE_DF
      Threshold for large degrees of freedom.
      See Also:
    • DOUBLE_MULTIPLIER

      private static final double DOUBLE_MULTIPLIER
      The multiplier to convert the least significant 53-bits of a long to a uniform double.
      See Also:
    • df

      private final double df
      Degrees of freedom.
    • powm1

      private final DoubleUnaryOperator 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

      private StudentsTSampler(UniformRandomProvider rng, TSampler.StudentsTSampler source)
      Parameters:
      rng - Generator of uniformly distributed random numbers.
      source - Source to copy.
  • Method Details

    • sample

      public double sample()
      Creates a double sample.
      Returns:
      a sample.
    • withUniformRandomProvider

      public TSampler.StudentsTSampler withUniformRandomProvider(UniformRandomProvider rng)
      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:
      withUniformRandomProvider in interface SharedStateSampler<SharedStateContinuousSampler>
      Specified by:
      withUniformRandomProvider in class TSampler
      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