当前位置: 首页>>代码示例>>Java>>正文


Java SimpleRegression.getIntercept方法代码示例

本文整理汇总了Java中org.apache.commons.math3.stat.regression.SimpleRegression.getIntercept方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleRegression.getIntercept方法的具体用法?Java SimpleRegression.getIntercept怎么用?Java SimpleRegression.getIntercept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math3.stat.regression.SimpleRegression的用法示例。


在下文中一共展示了SimpleRegression.getIntercept方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSlope

import org.apache.commons.math3.stat.regression.SimpleRegression; //导入方法依赖的package包/类
public double getSlope(BufferedImage bi1, BufferedImage bi2, int u, int v,  int s, int n) throws IOException {
   
    Raster r1 = bi1.getRaster().createTranslatedChild(0,0);
    Raster r2 = bi2.getRaster().createTranslatedChild(0,0);
    if (r1.getNumBands()>1) throw new IllegalArgumentException("only 1-banded rasters allowed here");
    if (r2.getNumBands()>1) throw new IllegalArgumentException("only 1-banded rasters allowed here");
    SimpleRegression reg = new SimpleRegression(true);
    int minX = u<0?u*-1:0;
    int minY = v<0?v*-1:0;
    int maxX = u>0?bi1.getWidth()-u: bi1.getWidth();
    int maxY = v>0?bi1.getHeight()-v: bi1.getHeight();
    for (int x=minX; x<maxX; x++) {
         for (int y=minY; y<maxY; y++) {
             double d1 = r1.getSampleDouble(x+u,y+v,0);
             if (d1> intensityThreshold) {
                 double d2 = r2.getSampleDouble(x, y, 0);
                 reg.addData(d2, d1);
             }
         }
     }

    double slope = reg.getSlope();
    double intercept = reg.getIntercept();
    logger.info("i,j: "+s+","+n+": "+ "slope: "+slope+" ; intercept: "+intercept);
    return slope;
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:27,代码来源:Calibration.java

示例2: process

import org.apache.commons.math3.stat.regression.SimpleRegression; //导入方法依赖的package包/类
@Override
public Data process(Data item) {

    // TODO Auto-generated method stub
    Utils.mapContainsKeys(item, key);

    double[] data = (double[]) item.get(key);
    double[] slope = new double[data.length];
    double[] intercept = new double[data.length];

    for (int i = 1; i < data.length; i++) {
        SimpleRegression regression = new SimpleRegression();
        for (int j = 0; j < width; j++) {
            regression.addData(j, data[(i + j) % data.length]);
        }
        regression.regress();
        slope[(i + (width / 2)) % data.length] = scale * regression.getSlope();
        intercept[(i + (width / 2)) % data.length] = regression.getIntercept();
    }

    item.put(slopeKey, slope);
    item.put(interceptKey, intercept);

    return item;
}
 
开发者ID:fact-project,项目名称:fact-tools,代码行数:26,代码来源:MovingLinearFit.java

示例3: assertResultsMatch

import org.apache.commons.math3.stat.regression.SimpleRegression; //导入方法依赖的package包/类
/**
 * Checks that the Morpheus OLS model yields the same results as Apache Math
 * @param frame      the data for regression
 * @param actual    the Morpheus results
 * @param expected  the Apache results
 */
private <R> void assertResultsMatch(DataFrame<String,String> frame, DataFrameLeastSquares<String,String> actual, SimpleRegression expected) {

    final double tss1 = actual.getTotalSumOfSquares();
    final double tss2 = expected.getTotalSumSquares();
    final double threshold = ((tss1 + tss2) / 2d) * 0.00001d;

    Assert.assertEquals(actual.getTotalSumOfSquares(), expected.getTotalSumSquares(), threshold, "Total sum of squares matches");
    Assert.assertEquals(actual.getRSquared(), expected.getRSquare(), 0.0000001, "R^2 values match");

    final double beta1 = actual.getBetaValue("X", Field.PARAMETER);
    final double beta2 = expected.getSlope();
    Assert.assertEquals(beta1, beta2, 0.000001, "Beta parameters match");

    final double intercept = expected.getIntercept();
    final double interceptStdError = expected.getInterceptStdErr();
    Assert.assertEquals(actual.getInterceptValue(Field.PARAMETER), intercept,  0.0000001, "The intercepts match");
    Assert.assertEquals(actual.getInterceptValue(Field.STD_ERROR), interceptStdError, 0.000000001, "The intercept std errors match");

    final double betaStdErr1 = actual.getBetaValue("X", Field.STD_ERROR);
    final double betaStdErr2 = expected.getSlopeStdErr();
    Assert.assertEquals(betaStdErr1, betaStdErr2, 0.00000001, "Beta Standard errors match");

    final DataFrame<String,String> residuals = actual.getResiduals();
    Assert.assertEquals(residuals.rows().count(), frame.rows().count(), "There are expected number of residuals");
    residuals.rows().forEach(row -> {
        final double x = frame.data().getDouble(row.ordinal(), "X");
        final double y = frame.data().getDouble(row.ordinal(), "Y");
        final double residual = row.getDouble(0);
        final double expect = y - expected.predict(x);
        Assert.assertEquals(residual, expect, 0.0000001, "Residual matches for x=" + x + " at row index " + row.ordinal());
    });
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:39,代码来源:OLSTests.java

示例4: solve

import org.apache.commons.math3.stat.regression.SimpleRegression; //导入方法依赖的package包/类
/**
 * Directly solve the linear problem, using the {@link SimpleRegression}
 * class.
 */
public double[] solve() {
    final SimpleRegression regress = new SimpleRegression(true);
    for (double[] d : points) {
        regress.addData(d[0], d[1]);
    }

    final double[] result = { regress.getSlope(), regress.getIntercept() };
    return result;
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:14,代码来源:StraightLineProblem.java

示例5: McLeanOrdinaryLeastSquaresRegressionLine

import org.apache.commons.math3.stat.regression.SimpleRegression; //导入方法依赖的package包/类
public McLeanOrdinaryLeastSquaresRegressionLine(SimpleRegression regression) {
    this.regression = regression;

    a = new double[2][1];
    a[1][0] = regression.getIntercept();

    v = new double[2][1];
    v[1][0] = regression.getSlope();
}
 
开发者ID:CIRDLES,项目名称:ET_Redux,代码行数:10,代码来源:McLeanRegressionLineFit.java

示例6: getExpectedValue

import org.apache.commons.math3.stat.regression.SimpleRegression; //导入方法依赖的package包/类
@Override
public Object getExpectedValue(int start, int length)
{
    if (length <= 1) {
        return null;
    }
    SimpleRegression regression = new SimpleRegression();
    for (int i = start; i < start + length; i++) {
        regression.addData(i + 2, i);
    }
    return regression.getIntercept();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:13,代码来源:TestRegrInterceptAggregation.java

示例7: testNonTrivialAggregation

import org.apache.commons.math3.stat.regression.SimpleRegression; //导入方法依赖的package包/类
private void testNonTrivialAggregation(Double[] y, Double[] x)
{
    SimpleRegression regression = new SimpleRegression();
    for (int i = 0; i < x.length; i++) {
        regression.addData(x[i], y[i]);
    }
    double expected = regression.getIntercept();
    checkArgument(Double.isFinite(expected) && expected != 0., "Expected result is trivial");
    testAggregation(expected, createDoublesBlock(y), createDoublesBlock(x));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:11,代码来源:TestRegrInterceptAggregation.java

示例8: testRegression

import org.apache.commons.math3.stat.regression.SimpleRegression; //导入方法依赖的package包/类
@Test
public void testRegression() {

    SimpleRegression regression = new SimpleRegression();
    regression.addData(0.0, 1.0);
    regression.addData(1.0, 2.5);
    regression.addData(2.0, 3.0);

    double slope = regression.getSlope();
    double intercept = regression.getIntercept();
    long n = regression.getN();
    double err = regression.getMeanSquareError();
}
 
开发者ID:ChronixDB,项目名称:chronix.timeseries,代码行数:14,代码来源:RegressionTest.java

示例9: regress

import org.apache.commons.math3.stat.regression.SimpleRegression; //导入方法依赖的package包/类
private Line regress(Set<Line> things, LinearForm lfDir) {
		SimpleRegression fit = new SimpleRegression();

		// regression isn't happy on lines with infinite slope: so swap params!
		boolean flip = Math.abs ( lfDir.x ) > Math.abs (lfDir.y);
		
		for (Line l : things) 
			if (flip) {
				fit.addData(l.start.y, l.start.x);
				fit.addData(l.end.y, l.end.x);
			}
			else {
				fit.addData(l.start.x, l.start.y);
				fit.addData(l.end.x, l.end.y);
			}

		double intercept = fit.getIntercept(), slope = fit.getSlope();
		
		if (Double.isNaN(intercept))
			return null;
		
		LinearForm lf;
		if (flip)
			 lf = new LinearForm(  1, -slope );
		else
			 lf = new LinearForm( -slope, 1 );
		
		
		if ( lf.unitVector().angle(lfDir.unitVector())> Math.PI / 2) {
			lf.x = -lf.x; // if regression is pointing wrong way, flip
			lf.y = -lf.y;
		}
		
		if (flip)
			lf.findC( intercept, 0 );
		else
			lf.findC( 0, intercept );

		double[] minMax = things.stream()
				.map(x -> new double[] { lf.findPParam(x.start), lf.findPParam(x.end) })
				.collect(new InAxDoubleArray());

//		Line line = new Line(lfDir, r.min, r.max);
		return new Line(lf, minMax[0], minMax[1]);  // do regression
	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:46,代码来源:FindLines.java


注:本文中的org.apache.commons.math3.stat.regression.SimpleRegression.getIntercept方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。