use of smile.stat.distribution.FDistribution in project smile by haifengl.
the class FDistributionDemo method stateChanged.
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == d1Slider || e.getSource() == d2Slider) {
d1 = d1Slider.getValue();
if (d1 == 0)
d1 = 1;
d2 = d2Slider.getValue();
if (d2 == 0)
d2 = 1;
FDistribution dist = new FDistribution(d1, d2);
double[][] p = new double[100][2];
double[][] q = new double[100][2];
for (int i = 0; i < p.length; i++) {
p[i][0] = (i + 1) / 20.0;
p[i][1] = dist.p(p[i][0]);
q[i][0] = (i + 1) / 20.0;
q[i][1] = dist.cdf(p[i][0]);
}
pdf.clear();
pdf.line(p, Line.Style.SOLID, Color.BLUE);
cdf.clear();
cdf.line(q, Line.Style.SOLID, Color.BLUE);
double[] data = new double[500];
for (int i = 0; i < data.length; i++) {
data[i] = dist.rand();
}
histogram.clear();
histogram.histogram(data, 20, Color.BLUE);
qqplot.clear();
qqplot.add(new QQPlot(data, dist));
canvas.repaint();
}
}
Aggregations