Tyche Trading

Standard Deviation

Bar Info

Debugging

Derivatives

Matrix Handling

Price Rounding

Regression Lines

Statistics

User Tracking

Example Strategies

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.

				
					/// <summary>
/// Calculate the standard deviation of a list of inputs.
/// </summary>
/// <param name="input"> A list of values. </param>
/// <returns> The standard deviation. </returns>
private double StandardDeviation(List<double> 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;
}

/// <summary>
/// Calculate the standard deviation of a 1d array of inputs.
/// </summary>
/// <param name="input"> A 1d array of values. </param>
/// <returns> The standard deviation. </returns>
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;
}