Bar Info
Menu
Debugging
Menu
Derivatives
Menu
Matrix Handling
Menu
Price Rounding
Menu
Regression Lines
Menu
Statistics
Menu
User Tracking
Menu
Example Strategies
Menu
Standard Deviation
Description:
Calculates the standard deviation of a given list of inputs.
Syntax:
StandardDeviation(List<double> input);
StandardDeviation(double[] input);
Arguments:
input: The set of inputs from the chart.
///
/// Calculate the standard deviation of a list of inputs.
///
/// A list of values.
/// The standard deviation.
private double StandardDeviation(List input)
{
double avg = input.Average();
double sum = input.Sum(d => Math.Pow(d - avg, 2));
double sd = Math.Sqrt(sum / input.Count - 1); // remove "- 1" if population
return sd;
}
///
/// Calculate the standard deviation of a 1d array of inputs.
///
/// A 1d array of values.
/// The standard deviation.
private double StandardDeviation(double[] input)
{
double avg = input.Average();
double sum = input.Sum(d => Math.Pow(d - avg, 2));
double sd = Math.Sqrt(sum / input.Length - 1); // remove "- 1" if population
return sd;
}