本文整理汇总了Java中smile.plot.Line类的典型用法代码示例。如果您正苦于以下问题:Java Line类的具体用法?Java Line怎么用?Java Line使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Line类属于smile.plot包,在下文中一共展示了Line类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FirstPassageTimeTest
import smile.plot.Line; //导入依赖的package包/类
public FirstPassageTimeTest(){
super(new GridLayout(1,2));
int dbscanMeter = 500;
loadRealWorldData(new DistanceWithUnit(dbscanMeter, SpatialDistanceUnit.Meter));
HashMap<Long, Double> values = null;
values = firstPassageTimeCalculationTest();
double[][] plotValues = new double [values.keySet().size()][2];
int index=0;
for(Entry<Long, Double> entry:values.entrySet()){
plotValues[index][0] = entry.getKey();
plotValues[index][1] = entry.getValue();
index++;
}
PlotCanvas canvas = LinePlot.plot("First passage time", plotValues, Line.Style.SOLID, Color.RED);
canvas.setTitle("First passage time (DBSCAN=" + dbscanMeter + "m)");
canvas.setAxisLabels("t (hour)", "Fpt (t)");
add(canvas);
}
示例2: stateChanged
import smile.plot.Line; //导入依赖的package包/类
@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();
}
}
示例3: stateChanged
import smile.plot.Line; //导入依赖的package包/类
@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();
}
}
示例4: stateChanged
import smile.plot.Line; //导入依赖的package包/类
@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();
}
}
示例5: stateChanged
import smile.plot.Line; //导入依赖的package包/类
@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();
}
}
示例6: stateChanged
import smile.plot.Line; //导入依赖的package包/类
@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();
}
}
示例7: stateChanged
import smile.plot.Line; //导入依赖的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();
}
}
示例8: stateChanged
import smile.plot.Line; //导入依赖的package包/类
@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();
}
}
示例9: stateChanged
import smile.plot.Line; //导入依赖的package包/类
@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();
}
}
示例10: stateChanged
import smile.plot.Line; //导入依赖的package包/类
@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();
}
}
示例11: stateChanged
import smile.plot.Line; //导入依赖的package包/类
@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();
}
}
示例12: GaussianDistributionDemo
import smile.plot.Line; //导入依赖的package包/类
public GaussianDistributionDemo() {
super(new BorderLayout());
Hashtable<Integer, JLabel> labelTable = new Hashtable<>();
for (int i = 0; i <= 50; i+=10) {
labelTable.put(new Integer(i), new JLabel(String.valueOf(i/10)));
}
sigmaSlider = new JSlider(0, 50, (int) Math.round(sigma * 10));
sigmaSlider.addChangeListener(this);
sigmaSlider.setLabelTable(labelTable);
sigmaSlider.setMajorTickSpacing(10);
sigmaSlider.setMinorTickSpacing(2);
sigmaSlider.setPaintTicks(true);
sigmaSlider.setPaintLabels(true);
optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
optionPane.add(new JLabel("\u03C3:"));
optionPane.add(sigmaSlider);
add(optionPane, BorderLayout.NORTH);
canvas = new JPanel(new GridLayout(2, 2));
add(canvas, BorderLayout.CENTER);
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 = 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);
}
示例13: WeibullDistributionDemo
import smile.plot.Line; //导入依赖的package包/类
public WeibullDistributionDemo() {
super(new BorderLayout());
Hashtable<Integer, JLabel> shapeLabelTable = new Hashtable<>();
for (int i = 0; i <= 10; i+=2) {
shapeLabelTable.put(new Integer(i), new JLabel(String.valueOf(i)));
}
shapeSlider = new JSlider(0, 10, (int) Math.round(shape));
shapeSlider.addChangeListener(this);
shapeSlider.setLabelTable(shapeLabelTable);
shapeSlider.setMajorTickSpacing(2);
shapeSlider.setMinorTickSpacing(1);
shapeSlider.setPaintTicks(true);
shapeSlider.setPaintLabels(true);
Hashtable<Integer, JLabel> scaleLabelTable = new Hashtable<>();
for (int i = 0; i <= 50; i+=10) {
scaleLabelTable.put(new Integer(i), new JLabel(String.valueOf(i/10)));
}
scaleSlider = new JSlider(0, 50, (int) Math.round(scale*10));
scaleSlider.addChangeListener(this);
scaleSlider.setLabelTable(scaleLabelTable);
scaleSlider.setMajorTickSpacing(10);
scaleSlider.setMinorTickSpacing(2);
scaleSlider.setPaintTicks(true);
scaleSlider.setPaintLabels(true);
optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
optionPane.add(new JLabel("Shape:"));
optionPane.add(shapeSlider);
optionPane.add(new JLabel("Scale:"));
optionPane.add(scaleSlider);
add(optionPane, BorderLayout.NORTH);
canvas = new JPanel(new GridLayout(2, 2));
add(canvas, BorderLayout.CENTER);
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 = 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);
}
示例14: ExponentialDistributionDemo
import smile.plot.Line; //导入依赖的package包/类
public ExponentialDistributionDemo() {
super(new BorderLayout());
Hashtable<Integer, JLabel> labelTable = new Hashtable<>();
for (int i = 0; i <= 50; i+=10) {
labelTable.put(new Integer(i), new JLabel(String.valueOf(i/10)));
}
lambdaSlider = new JSlider(0, 50, (int) Math.round(lambda * 10));
lambdaSlider.addChangeListener(this);
lambdaSlider.setLabelTable(labelTable);
lambdaSlider.setMajorTickSpacing(10);
lambdaSlider.setMinorTickSpacing(2);
lambdaSlider.setPaintTicks(true);
lambdaSlider.setPaintLabels(true);
optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
optionPane.add(new JLabel("\u03BB:"));
optionPane.add(lambdaSlider);
add(optionPane, BorderLayout.NORTH);
canvas = new JPanel(new GridLayout(2, 2));
add(canvas, BorderLayout.CENTER);
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 = 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);
}
示例15: BetaDistributionDemo
import smile.plot.Line; //导入依赖的package包/类
public BetaDistributionDemo() {
super(new BorderLayout());
Hashtable<Integer, JLabel> labelTable = new Hashtable<>();
for (int i = 0; i <= 100; i+=20) {
labelTable.put(new Integer(i), new JLabel(String.valueOf(i / 10)));
}
alphaSlider = new JSlider(0, 100, (int) Math.round(alpha * 10));
alphaSlider.addChangeListener(this);
alphaSlider.setLabelTable(labelTable);
alphaSlider.setMajorTickSpacing(10);
alphaSlider.setMinorTickSpacing(2);
alphaSlider.setPaintTicks(true);
alphaSlider.setPaintLabels(true);
betaSlider = new JSlider(0, 100, (int) Math.round(beta * 10));
betaSlider.addChangeListener(this);
betaSlider.setLabelTable(labelTable);
betaSlider.setMajorTickSpacing(10);
betaSlider.setMinorTickSpacing(2);
betaSlider.setPaintTicks(true);
betaSlider.setPaintLabels(true);
optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
optionPane.add(new JLabel("\u03B1:"));
optionPane.add(alphaSlider);
optionPane.add(new JLabel("\u03B2:"));
optionPane.add(betaSlider);
add(optionPane, BorderLayout.NORTH);
canvas = new JPanel(new GridLayout(2, 2));
add(canvas, BorderLayout.CENTER);
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 = 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);
}