Class: Statsample::Vector

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Summarizable, Writable
Defined in:
lib/statsample-timeseries/utility.rb

Direct Known Subclasses

TimeSeries::ARIMA, TimeSeries::Series

Instance Method Summary collapse

Instance Method Details

#squares_of_sum(demean = false) ⇒ Object

Squares of sum

Parameter

  • demean: boolean - optional. __default__: false

Returns

Sums the timeseries and then returns the square


12
13
14
15
16
17
18
19
# File 'lib/statsample-timeseries/utility.rb', line 12

def squares_of_sum(demean = false)
  if demean
    m = self.mean
    self.map { |x| (x-m) }.sum**2
  else
    return self.sum.to_f**2
  end
end