Search in sources :

Example 6 with QQPlot

use of smile.plot.QQPlot in project smile by haifengl.

the class LogisticDistributionDemo method stateChanged.

@Override
public void stateChanged(ChangeEvent e) {
    if (e.getSource() == sigmaSlider) {
        sigma = sigmaSlider.getValue() / 10.0;
        if (sigma == 0)
            sigma = 0.01;
        LogisticDistribution dist = new LogisticDistribution(0, sigma);
        double[][] p = new double[200][2];
        double[][] q = new double[200][2];
        for (int i = 0; i < p.length; i++) {
            p[i][0] = (i - 100) / 10.0;
            p[i][1] = dist.p(p[i][0]);
            q[i][0] = (i - 100) / 10.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();
    }
}
Also used : QQPlot(smile.plot.QQPlot) LogisticDistribution(smile.stat.distribution.LogisticDistribution)

Example 7 with QQPlot

use of smile.plot.QQPlot in project smile by haifengl.

the class ChiSquareDistributionDemo method stateChanged.

@Override
public void stateChanged(ChangeEvent e) {
    if (e.getSource() == kSlider) {
        k = kSlider.getValue();
        if (k == 0)
            k = 1;
        ChiSquareDistribution dist = new ChiSquareDistribution(k);
        double[][] p = new double[100][2];
        double[][] q = new double[100][2];
        for (int i = 0; i < p.length; i++) {
            p[i][0] = i / 2.0;
            p[i][1] = dist.p(p[i][0]);
            q[i][0] = i / 2.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();
    }
}
Also used : ChiSquareDistribution(smile.stat.distribution.ChiSquareDistribution) QQPlot(smile.plot.QQPlot)

Example 8 with QQPlot

use of smile.plot.QQPlot in project smile by haifengl.

the class BetaDistributionDemo method stateChanged.

@Override
public void stateChanged(ChangeEvent e) {
    if (e.getSource() == alphaSlider || e.getSource() == betaSlider) {
        alpha = alphaSlider.getValue() / 10.0;
        beta = betaSlider.getValue() / 10.0;
        if (alpha == 0)
            alpha = 0.01;
        if (beta == 0)
            beta = 0.01;
        BetaDistribution dist = new BetaDistribution(alpha, beta);
        double[][] p = new double[99][2];
        double[][] q = new double[99][2];
        for (int i = 0; i < p.length; i++) {
            p[i][0] = (i + 1) / 100.0;
            p[i][1] = dist.p(p[i][0]);
            q[i][0] = (i + 1) / 100.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();
    }
}
Also used : BetaDistribution(smile.stat.distribution.BetaDistribution) QQPlot(smile.plot.QQPlot)

Example 9 with QQPlot

use of smile.plot.QQPlot in project smile by haifengl.

the class ExponentialDistributionDemo method stateChanged.

@Override
public void stateChanged(ChangeEvent e) {
    if (e.getSource() == lambdaSlider) {
        lambda = lambdaSlider.getValue() / 10.0;
        if (lambda == 0)
            lambda = 0.01;
        ExponentialDistribution dist = new ExponentialDistribution(lambda);
        double[][] p = new double[100][2];
        double[][] q = new double[100][2];
        for (int i = 0; i < p.length; i++) {
            p[i][0] = i / 20.0;
            p[i][1] = dist.p(p[i][0]);
            q[i][0] = i / 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();
    }
}
Also used : QQPlot(smile.plot.QQPlot) ExponentialDistribution(smile.stat.distribution.ExponentialDistribution)

Example 10 with QQPlot

use of smile.plot.QQPlot 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();
    }
}
Also used : QQPlot(smile.plot.QQPlot) FDistribution(smile.stat.distribution.FDistribution)

Aggregations

QQPlot (smile.plot.QQPlot)10 BetaDistribution (smile.stat.distribution.BetaDistribution)1 ChiSquareDistribution (smile.stat.distribution.ChiSquareDistribution)1 ExponentialDistribution (smile.stat.distribution.ExponentialDistribution)1 FDistribution (smile.stat.distribution.FDistribution)1 GammaDistribution (smile.stat.distribution.GammaDistribution)1 GaussianDistribution (smile.stat.distribution.GaussianDistribution)1 LogNormalDistribution (smile.stat.distribution.LogNormalDistribution)1 LogisticDistribution (smile.stat.distribution.LogisticDistribution)1 TDistribution (smile.stat.distribution.TDistribution)1 WeibullDistribution (smile.stat.distribution.WeibullDistribution)1