Esempio n. 1
0
        public void FunctionTest3()
        {
            int   s      = 5;
            int   p      = 3;
            Anova target = new Anova(s, p);

            double[] x = new double[] { 5, 4, 3, 1, 1 };
            double[] y = new double[] { 3, 2, 5, 4, 1 };

            double expected = 4277;
            double actual   = target.Function(x, y);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 2
0
        public void FunctionTest2()
        {
            int   s      = 2;
            int   p      = 1;
            Anova target = new Anova(s, p);

            double[] x = new double[] { 5, 4 };
            double[] y = new double[] { 3, 2 };

            double expected = 23;
            double actual   = target.Function(x, y);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 3
0
        public JsonResult Post([FromBody] List <List <double> > body)
        {
            List <Sample> samples = new List <Sample>();

            for (int i = 0; i < body.Count; i++)
            {
                samples.Add(Anova.CreateSampleFromData(body[i]));
                Debug.WriteLine(samples[i].sd);
            }


            double grandMean = Anova.GetGrandMean(samples);
            double SSTr      = Anova.GetSSTr(samples, grandMean);
            double SSE       = Anova.GetSSE(samples);
            int    N         = Anova.GetTotalObservations(samples);
            int    k         = samples.Count;
            double MSTr      = Anova.GetMSTr(SSTr, k);
            double MSE       = Anova.GetMSE(SSE, N, k);


            int df1 = k - 1;
            int df2 = N - k;

            /*
             * Debug.WriteLine("N: "+N);
             * Debug.WriteLine("k: "+k);
             * Debug.WriteLine("SSTr: "+SSTr);
             * Debug.WriteLine("SSE: "+SSE);
             * Debug.WriteLine("MSTr: "+MSTr);
             * Debug.WriteLine("MSE: "+MSE);
             * Debug.WriteLine("df1: "+df1);
             * Debug.WriteLine("df2: "+df2);
             * Debug.WriteLine("F: "+MSTr/MSE);
             */
            return(Json(new {
                grandMean = N,
                numDataSets = k,
                sumOfSquaresForTreatment = SSTr,
                sumSquaredErrors = SSE,
                meanSquareOftreatment = MSTr,
                meanSquareOfError = MSE,
                degreesOfFreedomOne = df1,
                degreesOfFreedomTwo = df2,
                fStatistic = MSTr / MSE,
                pValue = -1,
                labels = Anova.TukeyKramerLabels(samples.Count),
                tkIntervals = Anova.TukeyKramerComparison(samples, MSE)
            }));
        }
Esempio n. 4
0
        public void FunctionTest()
        {
            int   s      = 2;
            int   p      = 2;
            Anova target = new Anova(s, p);

            // Values from examples by Manju M. Pai, 2003
            // The code, however, is computed differently.

            double[] x = new double[] { 5, 4 };
            double[] y = new double[] { 3, 2 };

            double expected = 120;
            double actual   = target.Function(x, y);

            Assert.AreEqual(expected, actual);
        }