/// <summary> /// 母平均に対する平均値の検定を行う. /// </summary> /// <param name="set">検定対象となる数値群</param> /// <param name="population">母平均</param> /// <param name="level">有意水準</param> /// <param name="p">p値が格納される(out)</param> /// <param name="t">t値が格納される(out)</param> /// <returns>trueの場合は「有意差あり」,falseの場合は「有意差無し」を意味する</returns> public static bool Test(IVector set, double population, double level, out double p, out double t) { VectorChecker.ZeroSize(set); t = (set.Average - population) / Math.Sqrt(set.Variance); p = GSL.Functions.cdf_tdist_Q(Math.Abs(t), set.Size - 1); return(p <= level); }
/// <summary> /// 2つのベクトルの相関を求める. /// </summary> /// <param name="vx">ベクトル</param> /// <param name="vy">ベクトル</param> /// <returns>相関</returns> /// <exception cref="Exception.MismatchSizeException"> /// ベクトルのサイズが一致しないときにthrowされる. /// </exception> public static double Correl(IVector vx, IVector vy) { VectorChecker.MismatchSize(vx, vy); double sxy = 0.0; double avg_x = vx.Average; double avg_y = vy.Average; for (int i = 0; i < vx.Size; ++i) { sxy += ((vx[i] - avg_x) * (vy[i] - avg_y)); } return(sxy / Math.Sqrt(vx.Scatter * vy.Scatter)); }