Statistical Methods

Standard Deviation


Description

Standard deviation is a statistic that measures the dispersion of a dataset relative to its mean and is calculated as the square root of the variance. The standard deviation is calculated as the square root of variance by determining each data point's deviation relative to the mean.

If the data points are further from the mean, there is a higher deviation within the data set; thus, the more spread out the data, the higher the standard deviation.

For more information, please visit Investopedia.


Params & Instance Methods

#initialze
@param series [Array] An array of prices, typically closing prices

#standard_deviation
@return [Float] The standard deviation of the price series

#valid?
@return [Boolean] Whether or not the object is valid

Example

require 'ruby-technical-analysis'

series = [0, 1, 2, 3]

statistical_methods = 
  RubyTechnicalAnalysis::StatisticalMethods.new(
    series: series
  )

p statistical_methods.valid? # true

p statistical_methods.standard_deviation.truncate(5) # 1.11803
Previous
Mean