Class: Nonsensor::MidpointDisplacement

Inherits:
Object
  • Object
show all
Includes:
Series
Defined in:
lib/nonsensor/midpoint_displacement.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Series

#take, #take!, #to_enum

Constructor Details

#initialize(start: 0.0, displacement: 50.0, decay_power: 1, batch_size: 100) ⇒ MidpointDisplacement

Returns a new instance of MidpointDisplacement.



6
7
8
9
10
11
12
13
# File 'lib/nonsensor/midpoint_displacement.rb', line 6

def initialize(start: 0.0, displacement: 50.0, decay_power: 1, batch_size: 100)
  @start = start
  @initial_displacement = displacement
  @decay = (1.0 / 2 ** decay_power)
  @batch_size = batch_size.to_i

  @batch = []
end

Instance Attribute Details

#batchObject (readonly)

Returns the value of attribute batch.



4
5
6
# File 'lib/nonsensor/midpoint_displacement.rb', line 4

def batch
  @batch
end

#batch_sizeObject (readonly)

Returns the value of attribute batch_size.



4
5
6
# File 'lib/nonsensor/midpoint_displacement.rb', line 4

def batch_size
  @batch_size
end

#startObject (readonly)

Returns the value of attribute start.



4
5
6
# File 'lib/nonsensor/midpoint_displacement.rb', line 4

def start
  @start
end

Instance Method Details

#next!Object



15
16
17
18
# File 'lib/nonsensor/midpoint_displacement.rb', line 15

def next!
  make_batch if @batch.empty?
  @batch.shift
end