I decided it was quicker to write my own, that just did what I needed. Here's the code...
/// <summary>
/// Very basic statistical analysis routines
/// </summary>
public class Statistics
{
List<double> numbers;
public double Sum { get; private set; }
public double Min { get; private set; }
public double Max { get; private set; }
double sumOfSquares;
public Statistics()
{
numbers = new List<double>();
}
public int Count
{
get { return numbers.Count; }
}
public void Add(double number)
{
if(Count == 0)
{
Min = Max = number;
}
numbers.Add(number);
Sum += number;
sumOfSquares += number * number;
Min = Math.Min(Min,number);
Max = Math.Max(Max,number);
}
public double Average
{
get { return Sum / Count; }
}
public double StandardDeviation
{
get { return Math.Sqrt(sumOfSquares / Count - (Average * Average)); }
}
/// <summary>
/// A simplistic implementation of Median
/// Returns the middle number if there is an odd number of elements (correct)
/// Returns the number after the midpoint if there is an even number of elements
/// Sorts the list on every call, so should be optimised for performance if planning
/// to call lots of times
/// </summary>
public double Median
{
get
{
if (numbers.Count == 0)
throw new InvalidOperationException("Can't calculate the median with no data");
numbers.Sort();
int middleIndex = (Count) / 2;
return numbers[middleIndex];
}
}
}