private void runButton_Click(object sender, EventArgs e) { DistributionTester tester = new DistributionTester(sampleSize); distributionLabel.Text = distLabels[distNum]; meanLabel.Text = distributions[distNum].Mean().ToString(); sampleMeanLabel.Text = tester.SampleMean(distributions[distNum]).ToString(); varianceLabel.Text = distributions[distNum].Variance().ToString(); sampleVarianceLabel.Text = tester.SampleVariance(distributions[distNum]).ToString(); skewnessLabel.Text = distributions[distNum].Skewness().ToString(); sampleSkewnessLabel.Text = tester.SampleSkewness(distributions[distNum]).ToString(); kurtosisLabel.Text = distributions[distNum].Kurtosis().ToString(); sampleKurtosisLabel.Text = tester.SampleKurtosis(distributions[distNum]).ToString(); sample = SampleGenerator.GenerateSample(distributions[distNum], sampleSize); chiLabel.Text = ChiSquared(sample).ToString(); PaintChart(); chart.Visible = true; distNum++; distNum = distNum % 4; }
public double SampleMean(IDistribution distribution) { sample = SampleGenerator.GenerateSample(distribution, n); double sum = 0; foreach (double x in sample) { sum += x; } return(sum / n); }