public static List<Tuple<int, float, int, float>> ChiSquare(int n, ReportList list) { var rL = new List<Tuple<int, float, int, float>>(); for (int i = 0; i < n; i++) { var range = new Range(i*(1/(float) n), ((i + 1)*(1/(float) n))); int oi = list.GetNumberOfObservationInRange(range); int ei = list.InnerData.Count/n; float oiei = ((oi - ei)*(oi - ei)/(float) ei); rL.Add(new Tuple<int, float, int, float>(i + 1, oi, ei, oiei)); } return rL; }
public int GetNumberOfObservationInRange(Range range) { return InnerData.Count(item => item < range.Upper && item >= range.Lower); }