Class: RandomSet::GaussianTrend
- Inherits:
-
Object
- Object
- RandomSet::GaussianTrend
- Defined in:
- lib/random_set/gaussian_trend.rb
Overview
Generates a Gaussian trend. For each sample, a Gaussian random number is generated using Gaussian, and its value is taken as the mean value for the next value. This produces a natural trend.
Instance Method Summary collapse
-
#initialize(start, volatility = 0.2, rand_helper = lambda { Kernel.rand }) ⇒ GaussianTrend
constructor
Initializes the generator.
- #next ⇒ Object
Constructor Details
#initialize(start, volatility = 0.2, rand_helper = lambda { Kernel.rand }) ⇒ GaussianTrend
Initializes the generator.
20 21 22 23 24 |
# File 'lib/random_set/gaussian_trend.rb', line 20 def initialize(start, volatility = 0.2, rand_helper = lambda { Kernel.rand }) @prev = start @volatility = volatility @rand_helper = rand_helper end |
Instance Method Details
#next ⇒ Object
26 27 28 |
# File 'lib/random_set/gaussian_trend.rb', line 26 def next @prev = Gaussian.new(@prev, @prev * @volatility, @rand_helper).next end |