Beispiel #1
0
        private void DrawBinomial(int n, int y, string Name)
        {
            if (chart_PosteriorDensity.Series.IndexOf(Name) != -1)
            {
                MessageBox.Show("图上已经存在相应分布,请勿重复添加!");
                return;
            }
            Series series = new Series(Name);

            series.BorderWidth = 3;
            series.ChartType   = SeriesChartType.Spline;
            //double MaxValue = 0;
            double Temp = 0;

            for (double i = 0.01; i < 1; i = i + 0.05)
            {
                Temp = n * Stat.BinomialPDF(i, n, y);
                if (MaxValue < Temp)
                {
                    MaxValue = Temp;
                }

                series.Points.AddXY(i, Temp);
            }
            chart_PosteriorDensity.Series.Add(series);
            var XAxis = chart_PosteriorDensity.ChartAreas[0].AxisX;

            XAxis.MajorGrid.Enabled = false;
            var YAxis = chart_PosteriorDensity.ChartAreas[0].AxisY;

            YAxis.MajorGrid.Enabled = false;
            XAxis.Maximum           = 1;
            XAxis.Minimum           = 0;
            YAxis.Maximum           = Math.Ceiling(MaxValue);
        }