gaussian distribution

group turbo_random_gaussian

Functions

template<typename RealType, typename URBG>
RealType gaussian(URBG &&urbg, RealType mean = 0, RealType stddev = 1)

turbo::gaussian<T>(bitgen, mean = 0, stddev = 1) turbo::gaussian produces a floating point number selected from the Gaussian (ie.

“Normal”) distribution. T must be a floating point type, but may be inferred from the types of mean and stddev. See https://en.wikipedia.org/wiki/Normal_distribution

Example:

cpp
      turbo::BitGen bitgen;
      ...
      double giraffe_height = turbo::gaussian(bitgen, 16.3, 3.3);

Template Parameters:
  • RealType

  • URBG

Parameters:
  • urbg

  • mean

  • stddev

Returns:

RealType

template<typename RealType>
RealType gaussian(RealType mean = 0, RealType stddev = 1)

similar to turbo::gaussian<T>(bitgen, mean = 0, stddev = 1) but use the default bitgen turbo::gaussian produces a floating point number selected from the Gaussian (ie.

“Normal”) distribution. T must be a floating point type, but may be inferred from the types of mean and stddev.

See also

turbo::get_tls_bit_gen()

See also

turbo::set_tls_bit_gen()

Template Parameters:

RealType

Parameters:
  • mean

  • stddev

Returns:

RealType

template<typename RealType>
RealType fast_gaussian(RealType mean = 0, RealType stddev = 1)

similar to turbo::gaussian<T>(bitgen, mean = 0, stddev = 1) but use the fast bitgen turbo::gaussian produces a floating point number selected from the Gaussian (ie.

“Normal”) distribution. T must be a floating point type, but may be inferred from the types of mean and stddev.

See also

turbo::get_tls_fast_bit_gen()

See also

turbo::set_tls_fast_bit_gen()

Template Parameters:

RealType

Parameters:
  • mean

  • stddev

Returns:

RealType

template<typename RealType = double>
class gaussian_distribution : private turbo::random_internal::gaussian_distribution_base
#include <gaussian_distribution.h>

turbo::gaussian_distribution<T> the gaussian_distribution implements the Ziggurat algorithm for generating random gaussian numbers.

The specific algorithm has some of the improvements suggested by the 2005 paper, “An Improved Ziggurat Method to Generate Normal Random Samples”, Jurgen A Doornik. (https://www.doornik.com/research/ziggurat.pdf) See https://en.wikipedia.org/wiki/Ziggurat_algorithm See https://en.wikipedia.org/wiki/Normal_distribution See https://www.jstatsoft.org/v05/i08/

Template Parameters:

RealType

class param_type