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


Java PolynomialCurveFitter类代码示例

本文整理汇总了Java中org.apache.commons.math3.fitting.PolynomialCurveFitter的典型用法代码示例。如果您正苦于以下问题:Java PolynomialCurveFitter类的具体用法?Java PolynomialCurveFitter怎么用?Java PolynomialCurveFitter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PolynomialCurveFitter类属于org.apache.commons.math3.fitting包,在下文中一共展示了PolynomialCurveFitter类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSlope

import org.apache.commons.math3.fitting.PolynomialCurveFitter; //导入依赖的package包/类
private double getSlope(Hashtable<Integer,Double> points)
{
    WeightedObservedPoints obs=new WeightedObservedPoints();
    Enumeration e=points.keys();
    int key;
    while (e.hasMoreElements())
    {
        key=(int)e.nextElement();
        obs.add(key,points.get(key));
    }
    PolynomialCurveFitter fitter=PolynomialCurveFitter.create(1);
    double[] coeff=fitter.fit(obs.toList());

    BigDecimal bd = new BigDecimal(coeff[1]);
    BigDecimal slope=bd.setScale(3,BigDecimal.ROUND_HALF_UP);
    return slope.doubleValue()*10;
}
 
开发者ID:ZingBug,项目名称:NystagmusJava,代码行数:18,代码来源:Calculate.java

示例2: fit

import org.apache.commons.math3.fitting.PolynomialCurveFitter; //导入依赖的package包/类
public void fit(String path) throws IOException {
	final WeightedObservedPoints obs = new WeightedObservedPoints();
	try(BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(path))))) {
		String line = br.readLine();
		while (line != null) {
			String[] point = line.split(" ");
			double x = Double.parseDouble(point[0]);
			double y = Double.parseDouble(point[1]);
			obs.add(x, y);
			line = br.readLine();
		}
	} catch (IOException e) {
		throw e;
	}
	final PolynomialCurveFitter fitter = PolynomialCurveFitter.create(5);
	final double[] coeff = fitter.fit(obs.toList());
	StringBuilder res = new StringBuilder();
	for (int i = coeff.length - 1; i >= 0; i--) {
		res.append(coeff[i]).append(":");
	}
	System.out.println(res.substring(0, res.length() - 1));
}
 
开发者ID:Saisimon,项目名称:tip,代码行数:23,代码来源:Fitting2.java

示例3: smooth

import org.apache.commons.math3.fitting.PolynomialCurveFitter; //导入依赖的package包/类
@Override
public double[] smooth(double[] sourceX, double[] noisyY, double[] estimateX, double parameter) {
	int degree = (int)Math.round(parameter);
	if(degree < 1 || degree > sourceX.length) {
		throw new IllegalArgumentException("Degree must be between 1 and number of data points.");
	}
	if(sourceX.length != noisyY.length) {
		throw new IllegalArgumentException("X and Y input must have the same length.");
	}
	
	
	PolynomialCurveFitter curveFitter = PolynomialCurveFitter.create(degree).withMaxIterations(10000);
	WeightedObservedPoints points = new WeightedObservedPoints();
	for(int i = 0; i < sourceX.length; i++) {
		points.add(sourceX[i], noisyY[i]);
	}
	PolynomialFunction func = new PolynomialFunction(curveFitter.fit(points.toList()));
	
	double[] result = new double[estimateX.length];
	for(int i = 0; i < estimateX.length; i++) {
		result[i] = func.value(estimateX[i]);
	}
	return result;
}
 
开发者ID:cas-bioinf,项目名称:cy-dataseries,代码行数:25,代码来源:PolynomialSmoothingProvider.java

示例4: process

import org.apache.commons.math3.fitting.PolynomialCurveFitter; //导入依赖的package包/类
/**
 * TODO
 * 
 * @return
 */
public double process() {
	Collection<WeightedObservedPoint> points = new LinkedList<WeightedObservedPoint>();

	// TODO We might need to change the behavior due to the fact that cell that are not in a track might still be in the metaXml file
	for (MIFrame frame : forest.getMetaxml().getAllFrames()) {
		// For the growth rate to be correct we need elapsed time in hours
		double elapsedTime = frame.getElapsedTime() / 60;
		double cellNumber = (double) frame.getAllCellsInFrame().size();

		// The points are uniformly weighted
		points.add(new WeightedObservedPoint(1d, elapsedTime, Math.log(cellNumber)));
	}

	final AbstractCurveFitter fitter = PolynomialCurveFitter.create(1);
	double[] coeffs = fitter.fit(points);

	growthRate = coeffs[1];

	return growthRate;
}
 
开发者ID:modsim,项目名称:vizardous,代码行数:26,代码来源:GrowthRateCalculator.java

示例5: processNew

import org.apache.commons.math3.fitting.PolynomialCurveFitter; //导入依赖的package包/类
/**
 * TODO
 * 
 * @return
 */
public double processNew() {
	Collection<WeightedObservedPoint> points = new LinkedList<WeightedObservedPoint>();

	// TODO We might need to change the behavior due to the fact that cell that are not in a track might still be in the metaXml file
	for (MIFrame frame : forest.getMetaxml().getAllFrames()) {
		// For the growth rate to be correct we need elapsed time in hours
		double elapsedTime = frame.getElapsedTime() / 60;
		double cellNumber = (double) frame.getAllCellsInFrame().size();

		// The points are uniformly weighted
		points.add(new WeightedObservedPoint(elapsedTime/forest.getMetaxml().getExperimentDuration(), elapsedTime, Math.log(cellNumber)));
	}

	final AbstractCurveFitter fitter = PolynomialCurveFitter.create(1);
	double[] coeffs = fitter.fit(points);
	
	factor = coeffs[0];
	growthRate = coeffs[1];

	return growthRate;
}
 
开发者ID:modsim,项目名称:vizardous,代码行数:27,代码来源:GrowthRateCalculator.java

示例6: getStageEstimationFunction

import org.apache.commons.math3.fitting.PolynomialCurveFitter; //导入依赖的package包/类
public static PolynomialFunction getStageEstimationFunction(
		List<Double> trainingSizes, List<Long> trainingDurations, int degree)
		throws SmallDataException {

	if (trainingSizes.size() <= degree)
		throw new SmallDataException();

	PolynomialCurveFitter fitter = PolynomialCurveFitter.create(degree);
	List<WeightedObservedPoint> points = new ArrayList<>();

	for (int i = 0; i < trainingSizes.size(); i++)
		points.add(new WeightedObservedPoint(1, trainingSizes.get(i),
				new Long(trainingDurations.get(i)).doubleValue()));

	return new PolynomialFunction(fitter.fit(points));

}
 
开发者ID:GiovanniPaoloGibilisco,项目名称:spark-log-processor,代码行数:18,代码来源:ApplicationEstimator.java

示例7: detrend

import org.apache.commons.math3.fitting.PolynomialCurveFitter; //导入依赖的package包/类
public static void detrend(List<double[]> set, int detrendPolynomial) {
	PolynomialCurveFitter p = PolynomialCurveFitter.create(detrendPolynomial);
	WeightedObservedPoints wop = new WeightedObservedPoints();
	for(int i = 0; i < set.size(); i++) {
		wop.add(set.get(i)[0], set.get(i)[1]);
	}
	double[] coeff = p.fit(wop.toList());
	for(int h = 0; h < set.size(); h++) {
		double val = set.get(h)[0];
		double off = 0;
		for(int i = detrendPolynomial; i >= 0; i--) {
			off += coeff[i] * Math.pow(val, i);
		}
		set.set(h, new double[]{set.get(h)[0], set.get(h)[1]-off});
	}
}
 
开发者ID:CBLRIT,项目名称:ECG-Viewer,代码行数:17,代码来源:Filters.java

示例8: isLinearCoeffDiff

import org.apache.commons.math3.fitting.PolynomialCurveFitter; //导入依赖的package包/类
private boolean isLinearCoeffDiff(double[] input, int centerIndex) {
	double xStep = 2.0 / (input.length + 1);

	WeightedObservedPoints firstHalf = new WeightedObservedPoints();
	WeightedObservedPoints secondHalf = new WeightedObservedPoints();

	for (int i = 0; i < input.length; i++) {
		if (i <= centerIndex) {
			firstHalf.add(i * xStep, input[i]);
		}

		if (i >= centerIndex) {
			secondHalf.add((i - centerIndex) * xStep, input[i]);
		}
	}

	PolynomialCurveFitter fitter = PolynomialCurveFitter.create(1);

	double[] firstHalfCoeffs = fitter.fit(firstHalf.toList());
	double[] secondHalfCoeffs = fitter.fit(secondHalf.toList());

	double firstHalfCoeff = firstHalfCoeffs[1];
	double secondHalfCoeff = secondHalfCoeffs[1];

	return firstHalfCoeff * secondHalfCoeff < 0;
}
 
开发者ID:cping,项目名称:RipplePower,代码行数:27,代码来源:ExtremumComputer.java

示例9: fitCurve

import org.apache.commons.math3.fitting.PolynomialCurveFitter; //导入依赖的package包/类
private double[] fitCurve(
	final List<ValuePair<DoubleType, DoubleType>> pairs)
{
	if (!allValuesFinite(pairs)) {
		return new double[2];
	}
	final WeightedObservedPoints points = toWeightedObservedPoints(pairs);
	final PolynomialCurveFitter curveFitter = PolynomialCurveFitter.create(1);
	return curveFitter.fit(points.toList());
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:11,代码来源:FractalDimensionWrapper.java

示例10: fitPolynomialToData

import org.apache.commons.math3.fitting.PolynomialCurveFitter; //导入依赖的package包/类
/**
 * Get fitting coefficients for N degree polynomial.
 * @param x
 * @param y
 * @param degree
 * @param reverseCoefficients
 * @return Fitting coefficients.
 */
public double[] fitPolynomialToData(double[] x, double[] y, int degree, boolean reverseCoefficients) {
    WeightedObservedPoints obs = new WeightedObservedPoints();
    for (int i = 0; i < x.length; i++) {
        obs.add(1, x[i], y[i]);
    }
    PolynomialCurveFitter fitter = PolynomialCurveFitter.create(degree);
    double[] coefficients = fitter.fit(obs.toList());
    if (reverseCoefficients) {
        return reverseDoublePrimitiveArray(coefficients);
    } else {
        return coefficients;
    }
}
 
开发者ID:piotrdzwiniel,项目名称:Specvis,代码行数:22,代码来源:Functions.java

示例11: createFitter

import org.apache.commons.math3.fitting.PolynomialCurveFitter; //导入依赖的package包/类
@Override
protected AbstractCurveFitter createFitter() {
    return PolynomialCurveFitter.create(degree);
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:5,代码来源:PolynomialApacheMathApproximator.java

示例12: setUp

import org.apache.commons.math3.fitting.PolynomialCurveFitter; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    curveFitter = PolynomialCurveFitter.create(0).withMaxIterations(2);
}
 
开发者ID:octavian-h,项目名称:time-series-math,代码行数:5,代码来源:PiecewiseCurveFitterApproximationTest.java

示例13: estimateStageDuration

import org.apache.commons.math3.fitting.PolynomialCurveFitter; //导入依赖的package包/类
public static long estimateStageDuration(List<Double> trainingSizes,
		List<Long> trainingDurations, double newSize, int degree) {

	PolynomialCurveFitter fitter = PolynomialCurveFitter.create(degree);
	List<WeightedObservedPoint> points = new ArrayList<>();

	for (int i = 0; i < trainingSizes.size(); i++)
		points.add(new WeightedObservedPoint(1, trainingSizes.get(i),
				new Long(trainingDurations.get(i)).doubleValue()));

	PolynomialFunction function = new PolynomialFunction(fitter.fit(points));

	return new Double(function.value(newSize)).longValue();

}
 
开发者ID:GiovanniPaoloGibilisco,项目名称:spark-log-processor,代码行数:16,代码来源:ApplicationEstimator.java


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