本文整理汇总了Java中org.apache.commons.math3.fitting.leastsquares.LeastSquaresBuilder类的典型用法代码示例。如果您正苦于以下问题:Java LeastSquaresBuilder类的具体用法?Java LeastSquaresBuilder怎么用?Java LeastSquaresBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LeastSquaresBuilder类属于org.apache.commons.math3.fitting.leastsquares包,在下文中一共展示了LeastSquaresBuilder类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getProblem
import org.apache.commons.math3.fitting.leastsquares.LeastSquaresBuilder; //导入依赖的package包/类
protected LeastSquaresProblem getProblem(Collection<WeightedObservedPoint> points) {
final int len = points.size();
final double[] target = new double[len];
final double[] weights = new double[len];
final double[] initialGuess = { 1.0, 1.0 };
int i = 0;
for(WeightedObservedPoint point : points) {
target[i] = point.getY();
weights[i] = point.getWeight();
i += 1;
}
AbstractCurveFitter.TheoreticalValuesFunction model = new AbstractCurveFitter.TheoreticalValuesFunction(func, points);
return new LeastSquaresBuilder().
maxEvaluations(Integer.MAX_VALUE).
maxIterations(Integer.MAX_VALUE).
start(initialGuess).
target(target).
weight(new DiagonalMatrix(weights)).
model(model.getModelFunction(), model.getModelFunctionJacobian()).
build();
}
开发者ID:Auraya,项目名称:armorvox-client,代码行数:25,代码来源:VxmlClientGetVoiceprint.java
示例2: createLeastSquaresBuilder
import org.apache.commons.math3.fitting.leastsquares.LeastSquaresBuilder; //导入依赖的package包/类
private LeastSquaresBuilder createLeastSquaresBuilder(List<Double> startValues, int maxIterations) {
LeastSquaresBuilder builder = new LeastSquaresBuilder()
.model(optimizerFunction, optimizerFunction.createJacobian()).maxEvaluations(Integer.MAX_VALUE)
.maxIterations(maxIterations).target(Doubles.toArray(targetValues)).start(Doubles.toArray(startValues));
if (!minValues.isEmpty() || !maxValues.isEmpty()) {
builder.parameterValidator(params -> {
for (int i = 0; i < parameters.size(); i++) {
double value = params.getEntry(i);
Double min = minValues.get(parameters.get(i));
Double max = maxValues.get(parameters.get(i));
if (min != null && value < min) {
value = min;
}
if (max != null && value > max) {
value = max;
}
params.setEntry(i, value);
}
return params;
});
}
return builder;
}
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:31,代码来源:LeastSquaresOptimization.java
示例3: builder
import org.apache.commons.math3.fitting.leastsquares.LeastSquaresBuilder; //导入依赖的package包/类
/**
* Builder least squares builder.
*
* @param problem the problem
*
* @return the least squares builder
*/
public LeastSquaresBuilder builder(CircleProblem problem) {
return new LeastSquaresBuilder()
// .checkerPair(new SimpleVectorValueChecker(1e-6, 1e-6))
.maxEvaluations(100)
.maxIterations(getMaxIterations())
.model(problem.getModelFunction(), problem.getModelFunctionJacobian())
.target(problem.target());
// .weight(new DiagonalMatrix(problem.weight())); 不涉及权重的问题
}
开发者ID:BPL-Gear,项目名称:bpl-gear,代码行数:17,代码来源:CircleOptimizer.java
示例4: getProblem
import org.apache.commons.math3.fitting.leastsquares.LeastSquaresBuilder; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected LeastSquaresProblem getProblem(Collection<WeightedObservedPoint> observations) {
// Prepare least-squares problem.
final int len = observations.size();
final double[] target = new double[len];
final double[] weights = new double[len];
int i = 0;
for (WeightedObservedPoint obs : observations) {
target[i] = obs.getY();
weights[i] = obs.getWeight();
++i;
}
final AbstractCurveFitter.TheoreticalValuesFunction model =
new AbstractCurveFitter.TheoreticalValuesFunction(FUNCTION, observations);
if (initialGuess == null) {
throw new MathInternalError();
}
// Return a new least squares problem set up to fit a polynomial curve to the
// observed points.
return new LeastSquaresBuilder().
maxEvaluations(Integer.MAX_VALUE).
maxIterations(maxIter).
start(initialGuess).
target(target).
weight(new DiagonalMatrix(weights)).
model(model.getModelFunction(), model.getModelFunctionJacobian()).
build();
}
开发者ID:biocompibens,项目名称:SME,代码行数:35,代码来源:PolynomialCurveFitter.java
示例5: getProblem
import org.apache.commons.math3.fitting.leastsquares.LeastSquaresBuilder; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected LeastSquaresProblem getProblem(Collection<WeightedObservedPoint> observations) {
// Prepare least-squares problem.
final int len = observations.size();
final double[] target = new double[len];
final double[] weights = new double[len];
int i = 0;
for (WeightedObservedPoint obs : observations) {
target[i] = obs.getY();
weights[i] = obs.getWeight();
++i;
}
final AbstractCurveFitter.TheoreticalValuesFunction model =
new AbstractCurveFitter.TheoreticalValuesFunction(FUNCTION, observations);
final double[] startPoint = initialGuess != null ?
initialGuess :
// Compute estimation.
new ParameterGuesser(observations).guess();
// Return a new least squares problem set up to fit a Gaussian curve to the
// observed points.
return new LeastSquaresBuilder().
maxEvaluations(Integer.MAX_VALUE).
maxIterations(maxIter).
start(startPoint).
target(target).
weight(new DiagonalMatrix(weights)).
model(model.getModelFunction(), model.getModelFunctionJacobian()).
build();
}
开发者ID:biocompibens,项目名称:SME,代码行数:37,代码来源:GaussianCurveFitter.java
示例6: getProblem
import org.apache.commons.math3.fitting.leastsquares.LeastSquaresBuilder; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected LeastSquaresProblem getProblem(Collection<WeightedObservedPoint> observations) {
// Prepare least-squares problem.
final int len = observations.size();
final double[] target = new double[len];
final double[] weights = new double[len];
int count = 0;
for (WeightedObservedPoint obs : observations) {
target[count] = obs.getY();
weights[count] = obs.getWeight();
++count;
}
final AbstractCurveFitter.TheoreticalValuesFunction model
= new AbstractCurveFitter.TheoreticalValuesFunction(function,
observations);
// Create an optimizer for fitting the curve to the observed points.
return new LeastSquaresBuilder().
maxEvaluations(Integer.MAX_VALUE).
maxIterations(maxIter).
start(initialGuess).
target(target).
weight(new DiagonalMatrix(weights)).
model(model.getModelFunction(), model.getModelFunctionJacobian()).
build();
}
开发者ID:biocompibens,项目名称:SME,代码行数:30,代码来源:SimpleCurveFitter.java
示例7: getProblem
import org.apache.commons.math3.fitting.leastsquares.LeastSquaresBuilder; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected LeastSquaresProblem getProblem(Collection<WeightedObservedPoint> observations) {
// Prepare least-squares problem.
final int len = observations.size();
final double[] target = new double[len];
final double[] weights = new double[len];
int i = 0;
for (WeightedObservedPoint obs : observations) {
target[i] = obs.getY();
weights[i] = obs.getWeight();
++i;
}
final AbstractCurveFitter.TheoreticalValuesFunction model
= new AbstractCurveFitter.TheoreticalValuesFunction(FUNCTION,
observations);
final double[] startPoint = initialGuess != null ?
initialGuess :
// Compute estimation.
new ParameterGuesser(observations).guess();
// Return a new optimizer set up to fit a Gaussian curve to the
// observed points.
return new LeastSquaresBuilder().
maxEvaluations(Integer.MAX_VALUE).
maxIterations(maxIter).
start(startPoint).
target(target).
weight(new DiagonalMatrix(weights)).
model(model.getModelFunction(), model.getModelFunctionJacobian()).
build();
}
开发者ID:biocompibens,项目名称:SME,代码行数:37,代码来源:HarmonicCurveFitter.java
示例8: optimiseLeastSquares
import org.apache.commons.math3.fitting.leastsquares.LeastSquaresBuilder; //导入依赖的package包/类
private double[] optimiseLeastSquares(float[] x, float[] y, double[] initialSolution)
{
// Least-squares optimisation using numerical gradients
final SkewNormalDifferentiableFunction function = new SkewNormalDifferentiableFunction(initialSolution);
function.addData(x, y);
LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
//@formatter:off
LeastSquaresProblem problem = new LeastSquaresBuilder()
.maxEvaluations(Integer.MAX_VALUE)
.maxIterations(3000)
.start(initialSolution)
.target(function.calculateTarget())
.weight(new DiagonalMatrix(function.calculateWeights()))
.model(function, new MultivariateMatrixFunction() {
public double[][] value(double[] point) throws IllegalArgumentException
{
return function.jacobian(point);
}} )
.build();
//@formatter:on
Optimum optimum = optimizer.optimize(problem);
double[] skewParameters = optimum.getPoint().toArray();
return skewParameters;
}
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:29,代码来源:PCPALMMolecules.java
示例9: fitPolygonalCell
import org.apache.commons.math3.fitting.leastsquares.LeastSquaresBuilder; //导入依赖的package包/类
/**
* Find an ellipse that optimises the fit to the polygon detected edges.
*
* @param roi
* @param params
* @param weightMap
* @param angle
* @return
*/
private double[] fitPolygonalCell(PolygonRoi roi, double[] params, FloatProcessor weightMap, FloatProcessor angle)
{
// Get an estimate of the starting parameters using the current polygon
double[] startPoint = params;
startPoint = estimateStartPoint(roi, weightMap.getWidth(), weightMap.getHeight());
int maxEval = 2000;
final DifferentiableEllipticalFitFunction func = new DifferentiableEllipticalFitFunction(roi, weightMap);
double relativeThreshold = 100 * Precision.EPSILON;
double absoluteThreshold = 100 * Precision.SAFE_MIN;
ConvergenceChecker<PointVectorValuePair> checker = new SimplePointChecker<PointVectorValuePair>(
relativeThreshold, absoluteThreshold);
double initialStepBoundFactor = 10;
double costRelativeTolerance = 1e-10;
double parRelativeTolerance = 1e-10;
double orthoTolerance = 1e-10;
double threshold = Precision.SAFE_MIN;
LevenbergMarquardtOptimizer optimiser = new LevenbergMarquardtOptimizer(initialStepBoundFactor,
costRelativeTolerance, parRelativeTolerance, orthoTolerance, threshold);
try
{
//@formatter:off
LeastSquaresProblem problem = new LeastSquaresBuilder()
.maxEvaluations(Integer.MAX_VALUE)
.maxIterations(maxEval)
.start(startPoint)
.target(func.calculateTarget())
.weight(new DiagonalMatrix(func.calculateWeights()))
.model(func, new MultivariateMatrixFunction() {
public double[][] value(double[] point) throws IllegalArgumentException
{
return func.jacobian(point);
}} )
.checkerPair(checker)
.build();
//@formatter:on
Optimum solution = optimiser.optimize(problem);
if (debug)
IJ.log(String.format("Eval = %d (Iter = %d), RMS = %f", solution.getEvaluations(),
solution.getIterations(), solution.getRMS()));
return solution.getPoint().toArray();
}
catch (Exception e)
{
IJ.log("Failed to find an elliptical solution, defaulting to polygon");
e.printStackTrace();
}
return null;
}
开发者ID:aherbert,项目名称:GDSC,代码行数:65,代码来源:Cell_Outliner.java
注:本文中的org.apache.commons.math3.fitting.leastsquares.LeastSquaresBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论