Class: GSLng::RNG::Uniform

Inherits:
GSLng::RNG show all
Defined in:
lib/gslng/rng/uniform.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from GSLng::RNG

#initialize_copy, release

Constructor Details

- (Uniform) initialize(min, max, generator_type = nil)

Creates a new Uniform distribution with values in [min,max)

Parameters:

  • min (Float)
  • max (Float)
  • generator_type (Symbol) (defaults to: nil)

    the algorithm to use (without the gsl_rng prefix). Default is :mt19937.



10
11
12
13
# File 'lib/gslng/rng/uniform.rb', line 10

def initialize(min, max, generator_type = nil)
  super(generator_type)
  @min,@max = min,max
end

Instance Attribute Details

- (Object) ptr (readonly)



4
5
6
# File 'lib/gslng/rng/uniform.rb', line 4

def ptr
  @ptr
end

Instance Method Details

- (Float) sample Also known as: get

Obtain a sample from this distribution

Returns:

  • (Float)


17
18
19
# File 'lib/gslng/rng/uniform.rb', line 17

def sample
  GSLng.backend.gsl_ran_flat(self.ptr, @min, @max)
end