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


Java SimpleRegression.regress方法代码示例

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


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

示例1: LinearFunctionFitter

import org.apache.commons.math3.stat.regression.SimpleRegression; //导入方法依赖的package包/类
public LinearFunctionFitter(List<DelayPoint> delayPoints) {
    if (delayPoints.size() < 2) {
        throw new Error("cannot fit linear function with just one data point");
    }
    apacheSimpleRegression = new SimpleRegression();
    
    for (DelayPoint p : delayPoints) {
        apacheSimpleRegression.addData(p.getX(), p.getY());
    }
    
    if (delayPoints.size() == 2) {
        DelayPoint center = DelayPoint.centerBetween(delayPoints.get(0), delayPoints.get(1));
        apacheSimpleRegression.addData(center.getX(), center.getY());
    }
    apacheSimpleRegression.regress();
}
 
开发者ID:hpiasg,项目名称:asgdrivestrength,代码行数:17,代码来源:LinearFunctionFitter.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: ApacheRegression

import org.apache.commons.math3.stat.regression.SimpleRegression; //导入方法依赖的package包/类
public static double[] ApacheRegression(double[][] x, double[] y) {
        if (x.length < 2) {
//            Tools.warning("******************************************************");
//            Tools.warning("******************************************************");
//            Tools.warning("******************************************************");
//            Tools.warning("Trying to run regression with " + x.length + " points.");
//            Tools.warning("******************************************************");
//            Tools.warning("******************************************************");
//            Tools.warning("******************************************************");
            exit("Trying to run regression with " + x.length + " points.");
        }
        if (Tools.loggerIsOn()) {
            Tools.writeLog("Regression");
            Tools.writeLog("\tx\ty");
            for (int i = 0; i < x.length; i++) {
                Tools.writeLog("\t" + x[i][0] + "\t" + y[i]);
            }
        }
        SimpleRegression reg = new SimpleRegression(true);
        reg.addObservations(x, y);
        RegressionResults regRes = reg.regress();
        double[] regResValues = regRes.getParameterEstimates();
        double intercept = regResValues[0];
        double slope = regResValues[1];
        return new double[]{intercept, slope, regRes.getRSquared()};
    }
 
开发者ID:pierpal,项目名称:IBDMUT,代码行数:27,代码来源:Tools.java

示例4: calculateSlope

import org.apache.commons.math3.stat.regression.SimpleRegression; //导入方法依赖的package包/类
public double calculateSlope(int slopePos, int numSlices, double[] data) {
    //calculate slope
    SimpleRegression regression = new SimpleRegression();

    for (int j = 0; j < numSlices; j++) {
        regression.addData(j, data[(j + slopePos - numSlices / 2) % data.length]);
    }
    regression.regress();

    return regression.getSlope();

}
 
开发者ID:fact-project,项目名称:fact-tools,代码行数:13,代码来源:FindMaxSlope.java

示例5: drawNameRotated

import org.apache.commons.math3.stat.regression.SimpleRegression; //导入方法依赖的package包/类
/**
 * Draws the given name at the centroid of the given plateCenters. The angle the name is
 * drawn at is the least squares line through the plate centers. This does not break text
 * into multiple lines.
 * 
 * Side effect: This adds a new MapText to mapTexts.
 * 
 * @param riseOffset The text will be raised (positive y) by this much distance above the centroid when
 *  drawn. The rotation will be applied to this location. If there is already a name drawn above the object,
 *  I try negating the riseOffset to draw the name below it. Positive y is down.
 */
public void drawNameRotated(BufferedImage map, Graphics2D g, String name, Set<Point> locations,
		double riseOffset, boolean enableBoundsChecking, TextType type)
{
	if (name.length() == 0)
		return;
	
			
	Point centroid = findCentroid(locations);
	
	SimpleRegression regression = new SimpleRegression();
	for (Point p : locations)
	{
		regression.addObservation(new double[]{p.x}, p.y);
	}
	double angle;
	try
	{
		regression.regress();
		
		// Find the angle to rotate the text to.
		double y0 = regression.predict(0);
		double y1 = regression.predict(1);
		// Move the intercept to the origin.
		y1 -= y0;
		y0 = 0;
		angle = Math.atan(y1/1.0);
	}
	catch(NoDataException e)
	{
		// This happens if the regression had only 2 or fewer points.
		angle = 0;
	}
			
	MapText text = createMapText(name, centroid, angle, type);
	if (drawNameRotated(map, g, riseOffset, enableBoundsChecking, text))
	{
		mapTexts.add(text);
	}
}
 
开发者ID:jeheydorn,项目名称:nortantis,代码行数:51,代码来源:TextDrawer.java


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