Class: Digiproc::Probability::GaussianDistribution

Inherits:
Object
  • Object
show all
Includes:
Convolvable::InstanceMethods, FourierTransformable, Initializable
Defined in:
lib/probability/gaussian_distribution.rb

Overview

Class to create a sample of Gaussian Distributed values

Instance Attribute Summary collapse

Attributes included from FourierTransformable

#fft, #fft_strategy

Instance Method Summary collapse

Methods included from Convolvable::InstanceMethods

#acorr, #auto_correlation, #conv, #convolution_strategy, #convolve, #cross_correlation, included, #xcorr

Methods included from Initializable

included

Methods included from FourierTransformable

#fft_angle, #fft_data, #fft_db, #fft_imaginary, #fft_magnitude, #fft_real, included

Constructor Details

#initialize(mean:, stddev:, size:, generator: Digiproc::Strategies::GaussianGeneratorBoxMullerStrategy.new) ⇒ GaussianDistribution

Initialize arguments

mean
Float

mean of the population

stddev
Float

standard deviation of the population

size
Integer

number of datapoints

generator

Strategy for making Gaussian values. Defaults to Digiproc::Strategies::GaussianGeneratorBoxMullerStrategy.new



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/probability/gaussian_distribution.rb', line 16

def initialize(mean: , stddev: , size: ,generator: Digiproc::Strategies::GaussianGeneratorBoxMullerStrategy.new)
    @mean, @stddev, @generator, @size = mean, stddev, generator, size
    generator.mean = mean
    generator.stddev = stddev
    data = []
    size.times do 
        data << generator.rand
    end
    @data = data
    initialize_modules(Digiproc::FourierTransformable => {time_data: data})
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



5
6
7
# File 'lib/probability/gaussian_distribution.rb', line 5

def data
  @data
end

#generatorObject

Returns the value of attribute generator.



5
6
7
# File 'lib/probability/gaussian_distribution.rb', line 5

def generator
  @generator
end

#meanObject

Returns the value of attribute mean.



5
6
7
# File 'lib/probability/gaussian_distribution.rb', line 5

def mean
  @mean
end

#sizeObject (readonly)

Returns the value of attribute size.



6
7
8
# File 'lib/probability/gaussian_distribution.rb', line 6

def size
  @size
end

#stddevObject

Returns the value of attribute stddev.



5
6
7
# File 'lib/probability/gaussian_distribution.rb', line 5

def stddev
  @stddev
end