private void button_Generate_Click(object sender, EventArgs e) { Stat.BetaAlphaBeta(Convert.ToInt32(textBox_SampleSize.Text), Convert.ToInt32(textBox_success.Text), ref Alpha, ref Beta); if (Classification.Length != 0 && CountTimes.Length != 0) { Result.Append("先验分布: "); Result.Append("Beta("); Result.Append(Alpha.ToString()); Result.Append(", "); Result.Append(Beta.ToString()); Result.Append(")\r\n"); Stat.ConjugateBeta(ref Alpha, ref Beta, CountTimes[0] + CountTimes[1], CountTimes[0]); Series series = new Series(); series.Points.AddXY(Classification[0], CountTimes[0]); series.Points.AddXY(Classification[1], CountTimes[1]); series.ChartType = SeriesChartType.Pie; chart_Posterior.Series.Clear(); chart_Posterior.Series.Add(series); Result.Append("似然函数: "); Result.Append("Binomial("); double p = ((double)CountTimes[0]) / (double)(CountTimes[0] + CountTimes[1]); Result.Append(CountTimes[0] + CountTimes[1]); Result.Append(", "); Result.Append(MathV.NumberPolish(p.ToString()).Trim()); Result.Append(")\r\n"); Result.Append("后验分布: "); Result.Append("Beta("); Result.Append(Alpha.ToString()); Result.Append(", "); Result.Append(Beta.ToString()); Result.Append(")\r\n"); Result.Append("后验分布等效样本量: "); Result.Append((Alpha + Beta - 2).ToString()); Result.Append("\r\n"); MainForm.S.richTextBox1.AppendText(Result.ToString()); MainForm.S.richTextBox1.Select(); //让RichTextBox获得焦点 MainForm.S.richTextBox1.Select(MainForm.S.richTextBox1.TextLength, 0); //将插入符号置于文本结束处 MainForm.S.richTextBox1.ScrollToCaret(); button_PosteriorDensity.Enabled = true; } }