Example #1
0
        public static Tuple <Matrix, double, double> cochran(Matrix m, int alpha)
        {
            if (!(alpha == 1 || alpha == 5))
            {
                throw new Exception("Cochran function: it is required that alpha be 1 or 5.");
            }


            double[] sqrvars = m.Rows.Select(i => sqrvar(i)).ToArray();
            double   c       = sqrvars.Max() / sqrvars.Sum();
            double   cochran = Cochran.GetValue(m.RowCount, m.ColumnCount, alpha);

            Matrix result;

            if (c <= cochran)
            {
                result = m;
            }
            else
            {
                int    index = 0;
                double max   = sqrvars[0];

                for (int i = 1; i <= sqrvars.Length - 1; i++)
                {
                    if (max < sqrvars[i])
                    {
                        max   = sqrvars[i];
                        index = i;
                    }
                }

                result = m.RemoveRow(index);
            }


            return(new Tuple <Matrix, double, double>(result, c, cochran));
        }
Example #2
0
 public static double tcochran(int row, int column, int alpha)
 {
     return(Cochran.GetValue(row, column, alpha));
 }