Class: GSLng::RNG::Gaussian
- Inherits:
-
GSLng::RNG
- Object
- GSLng::RNG
- GSLng::RNG::Gaussian
- Defined in:
- lib/gslng/rng/gaussian.rb
Instance Attribute Summary collapse
-
#mu ⇒ Object
readonly
Returns the value of attribute mu.
- #ptr ⇒ Object readonly
-
#sigma ⇒ Object
readonly
Returns the value of attribute sigma.
Instance Method Summary collapse
-
#initialize(mu = 0, sigma = 1, sample_method = :boxmuller, generator_type = nil) ⇒ Gaussian
constructor
Creates a new Gaussian distribution.
-
#sample ⇒ Float
(also: #get)
Obtain a sample from this distribution.
Methods inherited from GSLng::RNG
Constructor Details
#initialize(mu = 0, sigma = 1, sample_method = :boxmuller, generator_type = nil) ⇒ Gaussian
Creates a new Gaussian distribution
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gslng/rng/gaussian.rb', line 14 def initialize(mu = 0, sigma = 1, sample_method = :boxmuller, generator_type = nil) super(generator_type) @mu,@sigma = mu,sigma case sample_method when :boxmuller; @function = :gsl_ran_gaussian when :ziggurat; @function = :gsl_ran_gaussian_ziggurat when :ratio_method; @function = :gsl_ran_ratio_method else raise "Unsupported method" end end |
Instance Attribute Details
#mu ⇒ Object (readonly)
Returns the value of attribute mu.
6 7 8 |
# File 'lib/gslng/rng/gaussian.rb', line 6 def mu @mu end |
#ptr ⇒ Object (readonly)
4 5 6 |
# File 'lib/gslng/rng/gaussian.rb', line 4 def ptr @ptr end |
#sigma ⇒ Object (readonly)
Returns the value of attribute sigma.
6 7 8 |
# File 'lib/gslng/rng/gaussian.rb', line 6 def sigma @sigma end |