#region License Information /* HeuristicLab * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Linq; using HeuristicLab.Common; namespace HeuristicLab.Analysis.Statistics { public class TTest { public static double Test(double[] data1, double[] data2) { double left, right, both; alglib.studentttest2(data1, data1.Length, data2, data2.Length, out both, out left, out right); return both; } public static double GetOptimalSampleSize(double[] data1, double[] data2, double conf = 0.95) { double result = 0.0; double t = alglib.invstudenttdistribution(data1.Length * 2 - 2, conf); double m1 = data1.Average(); double m2 = data2.Average(); double s1 = data1.StandardDeviation(); double s2 = data2.StandardDeviation(); result = Math.Pow(t, 2) * (Math.Pow(s1, 2) + Math.Pow(s2, 2)) / Math.Pow(m1 - m2, 2); return Math.Ceiling(result); } } }