Esempio n. 1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         double score = float.Parse(TextBox1.Text);
         if (score > 100 || score < 0)
         {
             Response.Write("请输入正确的成绩");
         }
         else
         {
             Mean   me     = new Mean();
             double a      = me.calcMean(Scores2019);
             double b      = me.calcVari(Scores2019);
             float  z1     = intoZ(score, a, b);
             float  z2     = intoZ(110, a, b);
             double result = ClassStatistics.selfCaculate(z2) - ClassStatistics.selfCaculate(z1);
             result = result * 100;
             Response.Write("估计你的排名在前" + result + "%");
         }
     }
     catch (Exception ex)
     {
         Response.Write("输入错误!" + "</br>" + ex.Message);
     }
     finally
     {
     }
 }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)  //  create report
        {
            ClassStatistics cl = new ClassStatistics(this.houseKeeper);

            cl.RefToLastForm = this;
            this.Visible     = false;
            cl.Show();
        }
Esempio n. 3
0
        public ActionResult StatisticContent(Schools id, int year)
        {
            var stats = new ClassStatistics {
                school = id, usergroup = UserGroup.STUDENT, year = year
            };

            stats.CalculateStats(repository);
            return(View(stats));
        }
Esempio n. 4
0
        public void CreateClassStatisticks_PacientCollectionWithFeatures_BinaryFeaturesStat()
        {
            var classStat = new ClassStatistics(patients, Classification.Normal);

            Feature feature = new Feature {
                Id = 2, Value = 1, Type = FeatureType.Binary
            };

            Assert.Equal(0.667, classStat.FeaturesProbabilities(feature), 3);
        }
Esempio n. 5
0
        public void CreateClassStatisticks_PacientCollectionWithFeatures_Probability0()
        {
            ContinousFeaturesRanges.Buckets = 10;
            var classStat = new ClassStatistics(patients, Classification.Normal);

            Feature feature = new Feature {
                Id = 17, Value = 0.6, Type = FeatureType.Continuous
            };

            Assert.Equal(0, classStat.FeaturesProbabilities(feature), 3);
        }
 protected void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         float x = float.Parse(TextBox1.Text);
         float z = (x - 86.07143F) / 6.198667F;
         float p = ClassStatistics.selfCaculate(z);
         float a = (1 - p) * 100;
         Response.Write("排名大概是前" + a + "%");
     }
     catch (Exception ex)
     {
         Response.Write("输入内容有误!" + "</br>" + ex);
     }
 }
Esempio n. 7
0
        private static ClassStatistics CreateClassStatistics()
        {
            var classStats = new ClassStatistics(new NamespaceStatistics(new ModuleStatistics("module", Guid.Empty, 0, 0), "ns"), "Clazz");
            foreach (var methodStats in Enumerable.Range(1, 10)
                .Select(x => new MethodStatistics((uint)x, "Method " + x, "Method " + x, new VSCoverageStatistics
                {
                    BlocksCovered = (uint)x,
                    BlocksNotCovered = (uint)x - 1,
                    LinesCovered = (uint)x,
                    LinesNotCovered = (uint)x - 1,
                    LinesPartiallyCovered = (uint)x
                })))
                classStats.AddMethod(methodStats);

            return classStats;
        }
Esempio n. 8
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            double z1, z2;
            double x1, x2;
            double m, s, sigma;//均值\方差\标准差

            try
            {
                m     = double.Parse(txtMean.Text);
                s     = double.Parse(txtS.Text);//输入的是方差
                sigma = Math.Sqrt(s);
                //处理统计区间,如果是第二个文本框内容是A,表示正无穷
                //如果是第一个文本框内容是A,表示负无穷
                if (txtX1.Text.ToUpper() != "A")
                {
                    x1 = double.Parse(txtX1.Text);
                    z1 = (x1 - m) / s;//标准正态变换
                }
                else
                {
                    z1 = -4;//只要小于-3.8就可以视为负无穷
                }
                if (txtX2.Text.ToUpper() != "A")
                {
                    x2 = double.Parse(txtX2.Text);
                    z2 = (x2 - m) / s;//标准正态变换
                }
                else
                {
                    z2 = 4;//只要大于3.8就可以视为正无穷
                }
                Response.Write(string.Format("转换为标准正态分布之后,所求的区间是{0}-{1},所求概率是{2}",
                                             z1, z2, ClassStatistics.selfCaculate(z2) - ClassStatistics.selfCaculate(z1)
                                             )
                               );
            }
            catch
            {
                Response.Write("输入内容有误!");
            }
        }
Esempio n. 9
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string         filepath = @"某公司统计的开机时间17000条左右.csv";
            classCSVHelper csh      = new classCSVHelper();

            filepath = Server.MapPath(filepath);
            DataTable dt = csh.readCsvTxt(filepath, Encoding.Default);

            double[] Time = new double[dt.Rows.Count];
            int      j    = 0;

            //数据清洗
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i][1].ToString() != "" && double.Parse(dt.Rows[i][1].ToString()) > 0)
                {
                    Time[j] = double.Parse(dt.Rows[i][1].ToString());
                    j++;
                }
            }
            //建立新数组,防止出现null值
            double[] openTime = new double[j];
            for (int i = 0; i < j; i++)
            {
                openTime[i] = Time[i];
            }
            double mean  = calMean(openTime);
            double devar = Caldevar(openTime);

            try
            {
                double second = double.Parse(TextBox1.Text);
                double z      = (second - mean) / devar;
                double rate   = 1 - ClassStatistics.selfCaculate(z);
                Response.Write(string.Format("你的开机速度击败了{0:F}%的成员!", rate * 100));
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Esempio n. 10
0
        protected void BtnEstimate_Click(object sender, EventArgs e)
        {
            double[] existedGrades = { 90, 79, 91, 89, 77, 82, 85, 88, 78, 92,
                                       92, 94, 93, 72, 92, 91,  0, 92, 76, 86,87, 77, 79, 89, 90, 90,
                                       81, 92, 86 };
            double   grade;

            try
            {
                grade = double.Parse(TxtGrade.Text);
                double mean = CalcMean(existedGrades);
                //Response.Write(mean.ToString()+"<br />");
                double s = Math.Sqrt(CalcVariance(existedGrades));
                //Response.Write(s);
                double z    = (grade - mean) / s;
                double rank = 1 - ClassStatistics.selfCaculate((float)z);
                Response.Write(string.Format("{0}分排名大约为前{1:F2}%", grade, rank * 100));
            }
            catch (Exception Ex)
            {
                Response.Write(Ex.Message);
            }
        }
Esempio n. 11
0
        /// <inheritdoc />
        public override bool Equals(object obj)
        {
            if (object.ReferenceEquals(null, obj))
            {
                return(false);
            }

            if (object.ReferenceEquals(this, obj))
            {
                return(true);
            }

            ClassStatistics other = obj as ClassStatistics;

            if (other == null)
            {
                return(false);
            }

            return(object.Equals(this.All, other.All) &&
                   object.Equals(this.WithTruth, other.WithTruth) &&
                   object.Equals(this.RejectCurveAll, other.RejectCurveAll) &&
                   object.Equals(this.RejectCurveTruth, other.RejectCurveTruth));
        }
Esempio n. 12
0
        public ActionResult ExportStats(Schools school, UserGroup ugroup, int year)
        {
            var stats = new ClassStatistics {
                school = school, usergroup = ugroup, year = year
            };

            stats.CalculateStats(repository);

            var ms = new MemoryStream();

            using (var fs =
                       new FileStream(
                           AppDomain.CurrentDomain.BaseDirectory + "/Content/templates/NPOITemplate.xls",
                           FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                var templateWorkbook = new HSSFWorkbook(fs, true);
                var sheet            = templateWorkbook.CreateSheet(school.ToString());

                // create fonts
                var boldStyle = templateWorkbook.CreateCellStyle();
                var boldFont  = templateWorkbook.CreateFont();
                boldFont.Boldweight = (short)FontBoldWeight.BOLD;
                boldStyle.SetFont(boldFont);

                var rowcount = 0;
                var row      = sheet.CreateRow(rowcount++);
                var colcount = 0;

                // show general stats first
                row.CreateCell(colcount).SetCellValue(SecurityElement.Escape("Malaysian"));
                colcount += 2;
                row.CreateCell(colcount).SetCellValue(SecurityElement.Escape("Foreigners"));
                colcount += 2;
                row.CreateCell(colcount).SetCellValue(SecurityElement.Escape("SubTotal"));
                colcount += 2;
                row.CreateCell(colcount).SetCellValue(SecurityElement.Escape("Total"));
                row = sheet.CreateRow(rowcount++);
                for (int i = 0; i < 3; i++)
                {
                    row.CreateCell(i * 2).SetCellValue(SecurityElement.Escape("M"));
                    row.CreateCell(i * 2 + 1).SetCellValue(SecurityElement.Escape("F"));
                }
                row = sheet.CreateRow(rowcount++);
                row.CreateCell(0, CellType.NUMERIC).SetCellValue(stats.msian_male);
                row.CreateCell(1, CellType.NUMERIC).SetCellValue(stats.msian_female);
                row.CreateCell(2, CellType.NUMERIC).SetCellValue(stats.foreign_male);
                row.CreateCell(3, CellType.NUMERIC).SetCellValue(stats.foreign_female);
                row.CreateCell(4, CellType.NUMERIC).SetCellValue(stats.msian_male + stats.foreign_male);
                row.CreateCell(5, CellType.NUMERIC).SetCellValue(stats.msian_female + stats.foreign_female);
                row.CreateCell(6, CellType.NUMERIC).SetCellValue(stats.msian_male + stats.foreign_male + stats.msian_female + stats.foreign_female);

                foreach (var entry in stats.collections)
                {
                    // class row
                    row = sheet.CreateRow(rowcount++);
                    row.CreateCell(0).SetCellValue(SecurityElement.Escape(entry.name));
                    row.GetCell(0).CellStyle = boldStyle;

                    // header row1
                    row      = sheet.CreateRow(rowcount++);
                    colcount = 0;
                    foreach (var race in entry.GetList())
                    {
                        row.CreateCell(colcount).SetCellValue(SecurityElement.Escape(race.name));
                        colcount += 2;
                    }
                    row.CreateCell(colcount).SetCellValue(SecurityElement.Escape("Total"));

                    // header row2
                    row = sheet.CreateRow(rowcount++);
                    for (int i = 0; i < entry.GetList().Count(); i++)
                    {
                        row.CreateCell(i * 2).SetCellValue(SecurityElement.Escape("M"));
                        row.CreateCell(i * 2 + 1).SetCellValue(SecurityElement.Escape("F"));
                    }

                    // stats row
                    row      = sheet.CreateRow(rowcount++);
                    colcount = 0;
                    foreach (var race in entry.GetList())
                    {
                        row.CreateCell(colcount++).SetCellValue(race.male);
                        row.CreateCell(colcount++).SetCellValue(race.female);
                    }
                    row.CreateCell(colcount).SetCellValue(entry.GetList().Sum(x => x.male + x.female));
                }
                // delete first sheet
                templateWorkbook.RemoveSheetAt(0);
                templateWorkbook.Write(ms);
            }

            // return created file path);
            return(File(ms.ToArray(), "application/vnd.ms-excel", string.Format("Statistics_{0}_{1}.xls", ugroup, school)));
        }
Esempio n. 13
0
        public void CreateClassStatisticks_PacientCollections_APrioriStat()
        {
            var classStat = new ClassStatistics(patients, Classification.Normal);

            Assert.Equal(0.333, classStat.ClassProbability, 3);
        }