public static double GetCriticalValues(MultiCompType ctype, double alpha, int DegreeofFreedom, int ng)
        {
            //% Get the minimum of the specified critical values
            double crit = Double.MaxValue;
            double crit1 = Double.MaxValue;

            switch (ctype)
               {
                   //case MultiCompType.Tukey_Kramer | MultiCompType.HSD:
                   //  double crit1 = stdrinv(1-alpha, df, ng) / sqrt(2);

                   //  // The T-K algorithm is inaccurate for small alpha, so compute
                   //  // an upper bound for it and make sure it's in range.
                   //  ub = GetCriticalValues(MultiCompType.Dunn_Sidak, alpha, df, ng);
                   //  if (crit1 > ub) crit1 = ub;
                   //    break;

                   //case MultiCompType.Dunn_Sidak:
                   //  kstar = nchoosek(ng, 2);
                   //  alf = 1-Math.Pow((1-alpha),(1/kstar));
                   //  if (isinf(df))
                   //     crit1 = norminv(1-alf/2);
                   //  else
                   //     crit1 = tinv(1-alf/2, df);

                   //    break;
                   case MultiCompType.Bonferroni:
                     double kstar = NChooseK(ng, 2);
                     if (double.IsInfinity(DegreeofFreedom))
                        crit1 = normsinv(1 - alpha / (2*kstar));
                     else
                        crit1 = tinv(1 - alpha / (2*kstar), DegreeofFreedom);

                       break;
            //                   case MultiCompType.LSD:
               //                  if (isinf(df))
               //                     crit1 = norminv(1 - alpha / 2);
               //                  else
               //                     crit1 = tinv(1 - alpha / 2, df);
               //                  end
               //                    break;

               //                case MultiCompType.Scheffe:
               //                  if (isinf(df))
               //                     tmp = chi2inv(1-alpha, ng-1) / (ng-1);
               //                  else
               //                     tmp = finv(1-alpha, ng-1, df);
               //                  end
               //                  crit1 = sqrt((ng-1) * tmp);
               //                   break;
                   default:
                        new Exception("Not Implemented Yet");
                        break;
               }
               crit = Math.Min(crit, crit1);

               return crit;
        }
        public static void MultipleComparisons(/*comparison,means,h,*/ MultiCompSource Source, double[] GroupMeans, string[] GroupNames,int[] GroupMemberCounts, int DegreesofFreedom, double sqrtMSE, Single alpha, MultiCompType ctype /*, estimate ,dimension*/)
        {
            if ((alpha<=0) || (alpha>=1))
                new Exception("Alpha for Multiple Comparisons analysis should be between 1 and 0");

            switch(Source)
            {
                case MultiCompSource.ANOVA1:
                   //GroupMemberCounts <- n = stats.n(:);
                   //sqrtMSE <- s = stats.s;
                   int ng = GroupMemberCounts.GetLength(0);
                   if (DegreesofFreedom < 1)
                      new Exception("stats:multcompare:NotEnoughData Cannot compare means with 0 degrees of freedom for error.");

                   double crit = GetCriticalValues( ctype, alpha, DegreesofFreedom, ng);
                   double[] gcov = new double[ng];
                    for(int i = 0; i<ng; i++) gcov[i] = Math.Pow(sqrtMSE,2)/GroupMemberCounts[i];
                    break;
                case MultiCompSource.ANOVA2:
                    break;
                case MultiCompSource.ANOVAN:
                        break;

            }//Switch

            //% Create output matrix showing tests for all pairwise comparisons
            //% and graph that approximates these tests.
            //[M,MM,hh] = makeM(gmeans, gcov, crit, gnames, mname, dodisp);

            //comparison = M;
            //if (nargout>1), means = MM; end
            //if (nargout>2), h = hh; end
        }