use of smile.plot.QQPlot in project smile by haifengl.
the class TDistributionDemo method stateChanged.
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == nuSlider) {
nu = nuSlider.getValue();
if (nu == 0)
nu = 1;
TDistribution dist = new TDistribution(nu);
double[][] p = new double[100][2];
double[][] q = new double[100][2];
for (int i = 0; i < p.length; i++) {
p[i][0] = (i - 50) / 10.0;
p[i][1] = dist.p(p[i][0]);
q[i][0] = (i - 50) / 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();
}
}
use of smile.plot.QQPlot in project smile by haifengl.
the class WeibullDistributionDemo method stateChanged.
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == scaleSlider || e.getSource() == shapeSlider) {
scale = scaleSlider.getValue() / 10.0;
shape = shapeSlider.getValue();
if (scale == 0)
scale = 0.01;
if (shape == 0)
shape = 0.01;
WeibullDistribution dist = new WeibullDistribution(shape, scale);
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();
}
}
use of smile.plot.QQPlot in project smile by haifengl.
the class GammaDistributionDemo method stateChanged.
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == scaleSlider || e.getSource() == shapeSlider) {
scale = scaleSlider.getValue() / 10.0;
shape = shapeSlider.getValue();
if (scale == 0)
scale = 0.01;
if (shape == 0)
shape = 0.01;
GammaDistribution dist = new GammaDistribution(shape, scale);
double[][] p = new double[100][2];
double[][] q = new double[100][2];
for (int i = 0; i < p.length; i++) {
p[i][0] = i / 5.0;
p[i][1] = dist.p(p[i][0]);
q[i][0] = i / 5.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();
}
}
use of smile.plot.QQPlot in project smile by haifengl.
the class GaussianDistributionDemo method stateChanged.
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == sigmaSlider) {
sigma = sigmaSlider.getValue() / 10.0;
if (sigma == 0)
sigma = 0.01;
GaussianDistribution dist = new GaussianDistribution(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();
}
}
use of smile.plot.QQPlot in project smile by haifengl.
the class LogNormalDistributionDemo method stateChanged.
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == sigmaSlider) {
sigma = sigmaSlider.getValue() / 10.0;
if (sigma == 0)
sigma = 0.01;
LogNormalDistribution dist = new LogNormalDistribution(0, sigma);
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