本文整理汇总了Java中smile.stat.distribution.TDistribution类的典型用法代码示例。如果您正苦于以下问题:Java TDistribution类的具体用法?Java TDistribution怎么用?Java TDistribution使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TDistribution类属于smile.stat.distribution包,在下文中一共展示了TDistribution类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stateChanged
import smile.stat.distribution.TDistribution; //导入依赖的package包/类
@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();
}
}
示例2: TDistributionDemo
import smile.stat.distribution.TDistribution; //导入依赖的package包/类
public TDistributionDemo() {
super(new BorderLayout());
Hashtable<Integer, JLabel> labelTable = new Hashtable<>();
labelTable.put(1, new JLabel(String.valueOf(1)));
for (int i = 5; i <= 20; i += 5) {
labelTable.put(new Integer(i), new JLabel(String.valueOf(i)));
}
nuSlider = new JSlider(1, 20, nu);
nuSlider.addChangeListener(this);
nuSlider.setLabelTable(labelTable);
nuSlider.setMajorTickSpacing(5);
nuSlider.setMinorTickSpacing(1);
nuSlider.setPaintTicks(true);
nuSlider.setPaintLabels(true);
optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
optionPane.add(new JLabel("Degree of Freedom:"));
optionPane.add(nuSlider);
add(optionPane, BorderLayout.NORTH);
canvas = new JPanel(new GridLayout(2, 2));
add(canvas, BorderLayout.CENTER);
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 = LinePlot.plot(p, Line.Style.SOLID, Color.BLUE);
pdf.setTitle("PDF");
canvas.add(pdf);
cdf = LinePlot.plot(q, Line.Style.SOLID, Color.BLUE);
cdf.setTitle("CDF");
canvas.add(cdf);
double[] data = new double[500];
for (int i = 0; i < data.length; i++) {
data[i] = dist.rand();
}
histogram = Histogram.plot(data, 20);
histogram.setTitle("Histogram");
canvas.add(histogram);
qqplot = QQPlot.plot(data, dist);
qqplot.setTitle("Q-Q Plot");
canvas.add(qqplot);
}
示例3: StudentsT
import smile.stat.distribution.TDistribution; //导入依赖的package包/类
/**
* Create a new Student's t distribution with the given degrees of freedom.
*
* @param df the degrees of freedom for this distribution.
*/
public StudentsT(final int df) {
this.dist = new TDistribution(df);
this.df = df;
}