Class GaussianSampler

  • All Implemented Interfaces:
    ContinuousSampler, SharedStateContinuousSampler, SharedStateSampler<SharedStateContinuousSampler>

    public class GaussianSampler
    extends java.lang.Object
    implements SharedStateContinuousSampler
    Sampling from a Gaussian distribution with given mean and standard deviation.

    Note

    The mean and standard deviation are validated to ensure they are finite. This prevents generation of NaN samples by avoiding invalid arithmetic (inf * 0 or inf - inf). However use of an extremely large standard deviation and/or mean may result in samples that are infinite; that is the parameters are not validated to prevent truncation of the output distribution.

    Since:
    1.1
    • Field Detail

      • mean

        private final double mean
        Mean.
      • standardDeviation

        private final double standardDeviation
        standardDeviation.
    • Constructor Detail

      • GaussianSampler

        public GaussianSampler​(NormalizedGaussianSampler normalized,
                               double mean,
                               double standardDeviation)
        Parameters:
        normalized - Generator of N(0,1) Gaussian distributed random numbers.
        mean - Mean of the Gaussian distribution.
        standardDeviation - Standard deviation of the Gaussian distribution.
        Throws:
        java.lang.IllegalArgumentException - if standardDeviation <= 0 or is infinite; or mean is infinite
      • GaussianSampler

        private GaussianSampler​(UniformRandomProvider rng,
                                GaussianSampler source)
        Parameters:
        rng - Generator of uniformly distributed random numbers.
        source - Source to copy.