Esempio n. 1
0
        //function to calc Mann-Whitney statistics
        private double[] calcMWStats()
        {
            double[]      stats     = new double[8];       //to store final stats
            List <double> stoichsG1 = new List <double>(); //double[(this.PeptideStoichiometriesGroupOne.Count()]; //list to store distribution of group one stoichiometries
            List <double> stoichsG2 = new List <double>(); //double[(this.PeptideStoichiometriesGroupTwo.Count()]; //list to store distribution of group two stoichiometries

            foreach (Stoichiometry S1 in (this.PeptideStoichiometriesGroupOne))
            {
                stoichsG1.Add(S1.StoichiometryVal);
            }
            foreach (Stoichiometry S2 in (this.PeptideStoichiometriesGroupTwo))
            {
                stoichsG2.Add(S2.StoichiometryVal);
            }
            //calc stats
            TestResult mw = Univariate.MannWhitneyTest(stoichsG1, stoichsG2);

            stats[0] = mw.Statistic.Value;
            stats[1] = mw.Probability;

            //find medians, mins maxs
            stats[2] = stoichsG1.Median();
            stats[4] = stoichsG1.Min();
            stats[6] = stoichsG1.Max();

            stats[3] = stoichsG2.Median();
            stats[5] = stoichsG2.Min();
            stats[7] = stoichsG2.Max();

            return(stats);
        }
Esempio n. 2
0
        public void InternetSampleDownload()
        {
            FrameTable table = DownloadFrameTable(new Uri("https://raw.githubusercontent.com/Dataweekends/zero_to_deep_learning_udemy/master/data/weight-height.csv"));
            FrameView  view  = table.WhereNotNull();

            view.AddComputedColumn("Bmi", (FrameRow r) => {
                double h = (double)r["Height"];
                double w = (double)r["Weight"];
                return(w / (h * h));
            });

            FrameView males   = view.Where("Gender", (string s) => (s == "Male"));
            FrameView females = view.Where("Gender", (string s) => (s == "Female"));

            SummaryStatistics maleSummary   = new SummaryStatistics(males["Height"].As <double>());
            SummaryStatistics femaleSummary = new SummaryStatistics(females["Height"].As <double>());

            TestResult allNormal    = view["Height"].As <double>().ShapiroFranciaTest();
            TestResult maleNormal   = males["Height"].As <double>().ShapiroFranciaTest();
            TestResult femaleNormal = females["Height"].As <double>().ShapiroFranciaTest();

            TestResult tTest  = Univariate.StudentTTest(males["Height"].As <double>(), females["Height"].As <double>());
            TestResult mwTest = Univariate.MannWhitneyTest(males["Height"].As <double>(), females["Height"].As <double>());

            LinearRegressionResult     result0 = males["Weight"].As <double>().LinearRegression(males["Height"].As <double>());
            PolynomialRegressionResult result1 = males["Height"].As <double>().PolynomialRegression(males["Weight"].As <double>(), 1);
            PolynomialRegressionResult result2 = males["Height"].As <double>().PolynomialRegression(males["Weight"].As <double>(), 2);
            PolynomialRegressionResult result3 = males["Height"].As <double>().PolynomialRegression(males["Weight"].As <double>(), 3);

            //MultiLinearRegressionResult multi = view["Weight"].As<double>().MultiLinearRegression(view["Height"].As<double>(), view["Gender"].As<string>().Select(s => (s == "Male") ? 1.0 : 0.0).ToList());
        }
Esempio n. 3
0
        private static void CompareSamples()
        {
            List <double> a = new List <double>()
            {
                130.0, 140.0, 150.0, 150.0, 160.0, 190.0
            };
            List <double> b = new List <double>()
            {
                120.0, 150.0, 180.0, 170.0, 185.0, 175.0, 190.0, 200.0
            };

            TestResult student = Univariate.StudentTTest(a, b);

            Console.WriteLine($"{student.Statistic.Name} = {student.Statistic.Value}");
            Console.WriteLine($"{student.Type} P = {student.Probability}");

            student.Type = TestType.LeftTailed;
            Console.WriteLine($"{student.Type} P = {student.Probability}");

            TestResult mannWhitney = Univariate.MannWhitneyTest(a, b);

            Console.WriteLine($"{mannWhitney.Statistic.Name} = {mannWhitney.Statistic.Value}");
            Console.WriteLine($"{mannWhitney.Type} P = {mannWhitney.Probability}");

            TestResult kolmogorov = Univariate.KolmogorovSmirnovTest(a, b);

            Console.WriteLine($"{kolmogorov.Statistic.Name} = {kolmogorov.Statistic.Value}");
            Console.WriteLine($"{kolmogorov.Type} P = {kolmogorov.Probability}");
        }