Class: Axiom::Aggregate::StandardDeviation

Inherits:
Variance show all
Defined in:
lib/axiom/aggregate/standard_deviation.rb

Overview

The standard deviation of a sequence of numbers

Defined Under Namespace

Modules: Methods

Constant Summary

Constants inherited from Variance

Variance::DEFAULT

Instance Attribute Summary

Attributes included from Operation::Unary

#operand

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Variance

call

Methods inherited from Axiom::Aggregate

#call, #default, default, #finalize

Methods included from Visitable

#accept

Methods included from Operation::Unary

#initialize

Class Method Details

.finalize(_accumulator) ⇒ Float?

Calculate the standard deviation from the accumulator

Examples:

standard_deviation = StandardDeviation.finalize(accumulator)

Parameters:

  • _accumulator (Array(Numeric, Integer, Numeric))

Returns:

  • (Float)

    returned for a non-empty set

  • (nil)

    returned for an empty set



22
23
24
25
# File 'lib/axiom/aggregate/standard_deviation.rb', line 22

def self.finalize(_accumulator)
  variance = super
  Math.sqrt(variance) if variance
end

Instance Method Details

#typeClass<Attribute::Float>

Return the type returned from #call

Examples:

type = Axiom::Aggregate::StandardDeviation.type

Returns:



35
36
37
# File 'lib/axiom/aggregate/standard_deviation.rb', line 35

def type
  Attribute::Float
end