本文整理汇总了Java中org.jfree.data.statistics.Regression.getOLSRegression方法的典型用法代码示例。如果您正苦于以下问题:Java Regression.getOLSRegression方法的具体用法?Java Regression.getOLSRegression怎么用?Java Regression.getOLSRegression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.data.statistics.Regression
的用法示例。
在下文中一共展示了Regression.getOLSRegression方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testOLSRegression1b
import org.jfree.data.statistics.Regression; //导入方法依赖的package包/类
/**
* Checks the results of an OLS regression on sample dataset 1 AFTER converting it to
* an XYSeries.
*/
public void testOLSRegression1b() {
final double[][] data = createSampleData1();
final XYSeries series = new XYSeries("Test");
for (int i = 0; i < 11; i++) {
series.add(data[i][0], data[i][1]);
}
final XYDataset ds = new XYSeriesCollection(series);
final double[] result2 = Regression.getOLSRegression(ds, 0);
assertEquals(.25680930, result2[0], 0.0000001);
assertEquals(0.72792106, result2[1], 0.0000001);
}
示例2: testOLSRegression2b
import org.jfree.data.statistics.Regression; //导入方法依赖的package包/类
/**
* Checks the results of an OLS regression on sample dataset 2 AFTER converting it to
* an XYSeries.
*/
public void testOLSRegression2b() {
final double[][] data = createSampleData2();
final XYSeries series = new XYSeries("Test");
for (int i = 0; i < 10; i++) {
series.add(data[i][0], data[i][1]);
}
final XYDataset ds = new XYSeriesCollection(series);
final double[] result = Regression.getOLSRegression(ds, 0);
assertEquals(53.9729697, result[0], 0.0000001);
assertEquals(-4.1823030, result[1], 0.0000001);
}
示例3: testOLSRegression1b
import org.jfree.data.statistics.Regression; //导入方法依赖的package包/类
/**
* Checks the results of an OLS regression on sample dataset 1 AFTER
* converting it to an XYSeries.
*/
public void testOLSRegression1b() {
double[][] data = createSampleData1();
XYSeries series = new XYSeries("Test");
for (int i = 0; i < 11; i++) {
series.add(data[i][0], data[i][1]);
}
XYDataset ds = new XYSeriesCollection(series);
double[] result2 = Regression.getOLSRegression(ds, 0);
assertEquals(.25680930, result2[0], 0.0000001);
assertEquals(0.72792106, result2[1], 0.0000001);
}
示例4: testOLSRegression2b
import org.jfree.data.statistics.Regression; //导入方法依赖的package包/类
/**
* Checks the results of an OLS regression on sample dataset 2 AFTER
* converting it to an XYSeries.
*/
public void testOLSRegression2b() {
double[][] data = createSampleData2();
XYSeries series = new XYSeries("Test");
for (int i = 0; i < 10; i++) {
series.add(data[i][0], data[i][1]);
}
XYDataset ds = new XYSeriesCollection(series);
double[] result = Regression.getOLSRegression(ds, 0);
assertEquals(53.9729697, result[0], 0.0000001);
assertEquals(-4.1823030, result[1], 0.0000001);
}
示例5: testOLSRegression1b
import org.jfree.data.statistics.Regression; //导入方法依赖的package包/类
/**
* Checks the results of an OLS regression on sample dataset 1 AFTER
* converting it to an XYSeries.
*/
public void testOLSRegression1b() {
double[][] data = createSampleData1();
XYSeries series = new XYSeries("Test");
for (int i = 0; i < 11; i++) {
series.add(data[i][0], data[i][1]);
}
XYDataset ds = new XYSeriesCollection(series);
double[] result2 = Regression.getOLSRegression(ds, 0);
assertEquals(.25680930, result2[0], 0.0000001);
assertEquals(0.72792106, result2[1], 0.0000001);
}
示例6: testOLSRegression2b
import org.jfree.data.statistics.Regression; //导入方法依赖的package包/类
/**
* Checks the results of an OLS regression on sample dataset 2 AFTER
* converting it to an XYSeries.
*/
public void testOLSRegression2b() {
double[][] data = createSampleData2();
XYSeries series = new XYSeries("Test");
for (int i = 0; i < 10; i++) {
series.add(data[i][0], data[i][1]);
}
XYDataset ds = new XYSeriesCollection(series);
double[] result = Regression.getOLSRegression(ds, 0);
assertEquals(53.9729697, result[0], 0.0000001);
assertEquals(-4.1823030, result[1], 0.0000001);
}
示例7: drawRegression
import org.jfree.data.statistics.Regression; //导入方法依赖的package包/类
/** Handles drawing of the regression line */
private void drawRegression(XYDataset scatterPlotData, XYPlot xyplot) {
// compute regression function
double regressionParams[] = Regression.getOLSRegression(
scatterPlotData, 0);
Function2D regression = new LineFunction2D(regressionParams[0],
regressionParams[1]);
// sample function values
double lowerBound = xyplot.getDomainAxis().getLowerBound();
double upperBound = xyplot.getDomainAxis().getUpperBound();
XYDataset regressionDataset = DatasetUtilities.sampleFunction2D(
regression, lowerBound, upperBound,
REGRESSION_LINE_SAMPLE_COUNT, "Fitted Regression Line");
xyplot.setDataset(1, regressionDataset);
// render regression line into plot
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true,
false);
xyplot.setRenderer(1, renderer);
renderer.setSeriesPaint(0, REGRESSION_LINE_COLOR);
}
示例8: computeRegressionData
import org.jfree.data.statistics.Regression; //导入方法依赖的package包/类
private XYIntervalSeries computeRegressionData(double xStart, double xEnd) {
if (scatterpointsDataset.getItemCount(0) > 1) {
final double[] coefficients = Regression.getOLSRegression(scatterpointsDataset, 0);
final Function2D curve = new LineFunction2D(coefficients[0], coefficients[1]);
final XYSeries regressionData = DatasetUtilities.sampleFunction2DToSeries(curve, xStart, xEnd, 100, "regression line");
final XYIntervalSeries xyIntervalRegression = new XYIntervalSeries(regressionData.getKey());
for (int i = 0; i < regressionData.getItemCount(); i++) {
XYDataItem item = regressionData.getDataItem(i);
final double x = item.getXValue();
final double y = item.getYValue();
xyIntervalRegression.add(x, x, x, y, y, y);
}
return xyIntervalRegression;
} else {
Dialogs.showInformation("Unable to compute regression line.\n" +
"At least 2 values are needed to compute regression coefficients.");
return null;
}
}
示例9: plotRel2dChartData
import org.jfree.data.statistics.Regression; //导入方法依赖的package包/类
protected boolean plotRel2dChartData(String xAxisName, ArrayList<Double> xarr, String yAxisName, ArrayList<Double> yarr) {
clear2dChartData();
if (setXYSeries(runData, xarr, yarr)) {
double[] ols = Regression.getOLSRegression(chartPanel.getChart().getXYPlot().getDataset(1), 0);
Function2D curve = new LineFunction2D(ols[0], ols[1]);
trendData.clear();
trendData.add(runData.getMinX(), curve.getValue(runData.getMinX()));
trendData.add(runData.getMaxX(), curve.getValue(runData.getMaxX()));
double paddingX = runData.getMaxX() * 0.05;
double paddingY = runData.getMaxY() * 0.05;
XYPlot plot = chartPanel.getChart().getXYPlot();
plot.getDomainAxis(0).setRange(runData.getMinX() - paddingX, runData.getMaxX() + paddingX);
plot.getRangeAxis(0).setRange(runData.getMinY() - paddingY, runData.getMaxY() + paddingY);
plot.getDomainAxis(0).setLabel(xAxisName);
plot.getRangeAxis(0).setLabel(yAxisName);
plot.getRenderer(0).setSeriesVisible(0, true);
return true;
}
return false;
}
示例10: testOLSRegression1a
import org.jfree.data.statistics.Regression; //导入方法依赖的package包/类
/**
* Checks the results of an OLS regression on sample dataset 1.
*/
public void testOLSRegression1a() {
final double[][] data = createSampleData1();
final double[] result1 = Regression.getOLSRegression(data);
assertEquals(.25680930, result1[0], 0.0000001);
assertEquals(0.72792106, result1[1], 0.0000001);
}
示例11: testOLSRegression2a
import org.jfree.data.statistics.Regression; //导入方法依赖的package包/类
/**
* Checks the results of an OLS regression on sample dataset 2.
*/
public void testOLSRegression2a() {
final double[][] data = createSampleData2();
final double[] result = Regression.getOLSRegression(data);
assertEquals(53.9729697, result[0], 0.0000001);
assertEquals(-4.1823030, result[1], 0.0000001);
}
示例12: testOLSRegression1a
import org.jfree.data.statistics.Regression; //导入方法依赖的package包/类
/**
* Checks the results of an OLS regression on sample dataset 1.
*/
public void testOLSRegression1a() {
double[][] data = createSampleData1();
double[] result1 = Regression.getOLSRegression(data);
assertEquals(.25680930, result1[0], 0.0000001);
assertEquals(0.72792106, result1[1], 0.0000001);
}
示例13: testOLSRegression2a
import org.jfree.data.statistics.Regression; //导入方法依赖的package包/类
/**
* Checks the results of an OLS regression on sample dataset 2.
*/
public void testOLSRegression2a() {
double[][] data = createSampleData2();
double[] result = Regression.getOLSRegression(data);
assertEquals(53.9729697, result[0], 0.0000001);
assertEquals(-4.1823030, result[1], 0.0000001);
}
示例14: plotTrimRpmData
import org.jfree.data.statistics.Regression; //导入方法依赖的package包/类
private boolean plotTrimRpmData() {
if (setXYSeries(runData, rpmArray, trimArray)) {
double[] ols = Regression.getOLSRegression(mafChartPanel.getChartPanel().getChart().getXYPlot().getDataset(1), 0);
Function2D curve = new LineFunction2D(ols[0], ols[1]);
currMafData.clear();
currMafData.add(runData.getMinX(), curve.getValue(runData.getMinX()));
currMafData.add(runData.getMaxX(), curve.getValue(runData.getMaxX()));
return true;
}
return false;
}
示例15: computeCoefficientOfDetermination
import org.jfree.data.statistics.Regression; //导入方法依赖的package包/类
private void computeCoefficientOfDetermination() {
int numberOfItems = scatterpointsDataset.getSeries(0).getItemCount();
double arithmeticMeanOfX = 0; //arithmetic mean of X
double arithmeticMeanOfY = 0; //arithmetic mean of Y
double varX = 0; //variance of X
double varY = 0; //variance of Y
double coVarXY = 0; //covariance of X and Y;
//compute arithmetic means
for (int i = 0; i < numberOfItems; i++) {
arithmeticMeanOfX += scatterpointsDataset.getXValue(0, i);
arithmeticMeanOfY += scatterpointsDataset.getYValue(0, i);
}
arithmeticMeanOfX /= numberOfItems;
arithmeticMeanOfY /= numberOfItems;
//compute variances and covariance
for (int i = 0; i < numberOfItems; i++) {
varX += Math.pow(scatterpointsDataset.getXValue(0, i) - arithmeticMeanOfX, 2);
varY += Math.pow(scatterpointsDataset.getYValue(0, i) - arithmeticMeanOfY, 2);
coVarXY += (scatterpointsDataset.getXValue(0, i) - arithmeticMeanOfX) * (scatterpointsDataset.getYValue(0,
i) -
arithmeticMeanOfY);
}
//computation of coefficient of determination
double r2 = Math.pow(coVarXY, 2) / (varX * varY);
r2 = MathUtils.round(r2, Math.pow(10.0, 5));
final double[] coefficients = Regression.getOLSRegression(scatterpointsDataset, 0);
final double intercept = coefficients[0];
final double slope = coefficients[1];
final String linearEquation;
if (intercept >= 0) {
linearEquation = "y = " + (float) slope + "x + " + (float) intercept;
} else {
linearEquation = "y = " + (float) slope + "x - " + Math.abs((float) intercept);
}
TextTitle tt = new TextTitle(linearEquation + "\nR² = " + r2);
tt.setTextAlignment(HorizontalAlignment.RIGHT);
tt.setFont(chart.getLegend().getItemFont());
tt.setBackgroundPaint(new Color(200, 200, 255, 100));
tt.setFrame(new BlockBorder(Color.white));
tt.setPosition(RectangleEdge.BOTTOM);
r2Annotation = new XYTitleAnnotation(0.98, 0.02, tt,
RectangleAnchor.BOTTOM_RIGHT);
r2Annotation.setMaxWidth(0.48);
getPlot().addAnnotation(r2Annotation);
}