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

Methods inherited from Variance

call

Methods inherited from Axiom::Aggregate

#call, #default, default, #finalize

Methods included from Operation::Unary

#initialize

Methods inherited from Function

extract_value, rename_attributes, #type

Methods included from Visitable

#accept

Class Method Details

.finalize(_accumulator) ⇒ Float?

Calculate the standard deviation from the accumulator

Examples:

standard_deviation = StandardDeviation.finalize(accumulator)

Parameters:

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

.typeClass<Types::Float>

Return the type returned from #call

Examples:

type = Axiom::Aggregate::StandardDeviation.type
# => Axiom::Types::Float

Returns:

  • (Class<Types::Float>)


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

def self.type
  Types::Float
end