本文整理汇总了Java中org.apache.commons.math3.analysis.MultivariateMatrixFunction类的典型用法代码示例。如果您正苦于以下问题:Java MultivariateMatrixFunction类的具体用法?Java MultivariateMatrixFunction怎么用?Java MultivariateMatrixFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MultivariateMatrixFunction类属于org.apache.commons.math3.analysis包,在下文中一共展示了MultivariateMatrixFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNumericJacobianFunction
import org.apache.commons.math3.analysis.MultivariateMatrixFunction; //导入依赖的package包/类
public MultivariateMatrixFunction getNumericJacobianFunction(final double[] xgrid, final double[] ygrid) {
final MultivariateVectorFunction valueFunction = getValueFunction(xgrid, ygrid);
return new MultivariateMatrixFunction() {
static final double step = 0.01;
@Override
public double[][] value(double[] point) throws IllegalArgumentException {
double[][] retVal = new double[xgrid.length][point.length];
for(int i = 0; i < point.length; i++) {
double[] newPoint = point.clone();
newPoint[i] = newPoint[i] + step;
double[] f1 = valueFunction.value(newPoint);
double[] f2 = valueFunction.value(point);
for(int j = 0; j < f1.length; j++) {
retVal[j][i] = (f1[j] - f2[j]) / step;
}
}
return retVal;
}
};
}
示例2: getNumericJacobianFunction
import org.apache.commons.math3.analysis.MultivariateMatrixFunction; //导入依赖的package包/类
private MultivariateMatrixFunction getNumericJacobianFunction(final double[] xgrid1, final double[] ygrid1, final double[] xgrid2, final double[] ygrid2) {
final MultivariateVectorFunction valueFunction = getValueFunction(xgrid1, ygrid1, xgrid2, ygrid2);
return new MultivariateMatrixFunction() {
static final double step = 0.01;
@Override
public double[][] value(double[] point) throws IllegalArgumentException {
double[][] retVal = new double[xgrid1.length + xgrid2.length][point.length];
for(int i = 0; i < point.length; i++) {
double[] newPoint = point.clone();
newPoint[i] = newPoint[i] + step;
double[] f1 = valueFunction.value(newPoint);
double[] f2 = valueFunction.value(point);
for(int j = 0; j < f1.length; j++) {
retVal[j][i] = (f1[j] - f2[j]) / step;
}
}
return retVal;
}
};
}
示例3: getJacobianFunction
import org.apache.commons.math3.analysis.MultivariateMatrixFunction; //导入依赖的package包/类
@Override
public MultivariateMatrixFunction getJacobianFunction(final double[] xgrid, final double[] ygrid) {
return new MultivariateMatrixFunction() {
@Override
public double[][] value(double[] point) throws IllegalArgumentException {
fixParams(point);
//
double[][] retVal = new double[xgrid.length][point.length];
for(int i = 0; i < nmol; i++) {
double [] tmp = Arrays.copyOfRange(point, i*Params.PARAMS_LENGTH, (i+1)*Params.PARAMS_LENGTH);
double [][] J = psf.getNumericJacobianFunction(xgrid, ygrid).value(tmp);
for(int j = 0; j < J.length; j++) {
for(int k = 0, l = i*Params.PARAMS_LENGTH; k < J[j].length; k++, l++) {
retVal[j][l] = J[j][k];
}
}
}
return retVal;
}
};
}
示例4: getModelFunctionJacobian
import org.apache.commons.math3.analysis.MultivariateMatrixFunction; //导入依赖的package包/类
public MultivariateMatrixFunction getModelFunctionJacobian() {
return new MultivariateMatrixFunction() {
public double[][] value(double[] params) {
double[][] jacobian = new double[time.size()][5];
for (int i = 0; i < jacobian.length; ++i) {
final double t = time.get(i);
jacobian[i][0] = 1;
final double p3 = params[3];
final double p4 = params[4];
final double tOp3 = t / p3;
final double tOp4 = t / p4;
jacobian[i][1] = FastMath.exp(-tOp3);
jacobian[i][2] = FastMath.exp(-tOp4);
jacobian[i][3] = params[1] * FastMath.exp(-tOp3) * tOp3 / p3;
jacobian[i][4] = params[2] * FastMath.exp(-tOp4) * tOp4 / p4;
}
return jacobian;
}
};
}
示例5: getModelFunctionJacobian
import org.apache.commons.math3.analysis.MultivariateMatrixFunction; //导入依赖的package包/类
public ModelFunctionJacobian getModelFunctionJacobian() {
return new ModelFunctionJacobian(new MultivariateMatrixFunction() {
public double[][] value(double[] params) {
double[][] jacobian = new double[time.size()][5];
for (int i = 0; i < jacobian.length; ++i) {
final double t = time.get(i);
jacobian[i][0] = 1;
final double p3 = params[3];
final double p4 = params[4];
final double tOp3 = t / p3;
final double tOp4 = t / p4;
jacobian[i][1] = FastMath.exp(-tOp3);
jacobian[i][2] = FastMath.exp(-tOp4);
jacobian[i][3] = params[1] * FastMath.exp(-tOp3) * tOp3 / p3;
jacobian[i][4] = params[2] * FastMath.exp(-tOp4) * tOp4 / p4;
}
return jacobian;
}
});
}
示例6: refine
import org.apache.commons.math3.analysis.MultivariateMatrixFunction; //导入依赖的package包/类
/**
* Perform Levenburg-Marquardt non-linear optimisation to get better
* estimates of the parameters
*/
private void refine()
{
final LevenbergMarquardtOptimizer lm = new LevenbergMarquardtOptimizer();
final RealVector start = buildInitialVector();
final RealVector observed = buildObservedVector();
final int maxEvaluations = 1000;
final int maxIterations = 1000;
final MultivariateVectorFunction value = new Value();
final MultivariateMatrixFunction jacobian = new Jacobian();
final MultivariateJacobianFunction model = LeastSquaresFactory.model(value, jacobian);
final Optimum result = lm.optimize(LeastSquaresFactory.create(model,
observed, start, null, maxEvaluations, maxIterations));
updateEstimates(result.getPoint());
}
示例7: createJacobian
import org.apache.commons.math3.analysis.MultivariateMatrixFunction; //导入依赖的package包/类
@Override
public MultivariateMatrixFunction createJacobian() {
List<MultiVectorDiffFunction> diffFunctions = new ArrayList<>();
for (int i = 0; i < parameters.size(); i++) {
try {
diffFunctions.add(new MultiVectorDiffFunction(formulas, dependentVariables, initValues, initParameters,
parameters, variableValues, timeValues, dependentVariable, timeVariable, integrator,
interpolator));
} catch (ParseException e) {
}
}
return point -> MathUtils.aproxJacobianParallel(diffFunctions, point,
timeValues.stream().mapToInt(t -> t.size()).sum());
}
示例8: getModelFunctionJacobian
import org.apache.commons.math3.analysis.MultivariateMatrixFunction; //导入依赖的package包/类
public MultivariateMatrixFunction getModelFunctionJacobian() {
return new MultivariateMatrixFunction() {
public double[][] value(double[] params) {
double[][] jacobian = new double[time.size()][5];
for (int i = 0; i < jacobian.length; ++i) {
final double t = time.get(i);
jacobian[i][0] = 1;
final double p3 = params[3];
final double p4 = params[4];
final double tOp3 = t / p3;
final double tOp4 = t / p4;
jacobian[i][1] = Math.exp(-tOp3);
jacobian[i][2] = Math.exp(-tOp4);
jacobian[i][3] = params[1] * Math.exp(-tOp3) * tOp3 / p3;
jacobian[i][4] = params[2] * Math.exp(-tOp4) * tOp4 / p4;
}
return jacobian;
}
};
}
示例9: getModelFunctionJacobian
import org.apache.commons.math3.analysis.MultivariateMatrixFunction; //导入依赖的package包/类
public ModelFunctionJacobian getModelFunctionJacobian() {
return new ModelFunctionJacobian(new MultivariateMatrixFunction() {
public double[][] value(double[] params) {
double[][] jacobian = new double[time.size()][5];
for (int i = 0; i < jacobian.length; ++i) {
final double t = time.get(i);
jacobian[i][0] = 1;
final double p3 = params[3];
final double p4 = params[4];
final double tOp3 = t / p3;
final double tOp4 = t / p4;
jacobian[i][1] = Math.exp(-tOp3);
jacobian[i][2] = Math.exp(-tOp4);
jacobian[i][3] = params[1] * Math.exp(-tOp3) * tOp3 / p3;
jacobian[i][4] = params[2] * Math.exp(-tOp4) * tOp4 / p4;
}
return jacobian;
}
});
}
示例10: getModelFunctionJacobian
import org.apache.commons.math3.analysis.MultivariateMatrixFunction; //导入依赖的package包/类
/**
* 雅克比矩阵
*
* @return the model function jacobian
*/
public MultivariateMatrixFunction getModelFunctionJacobian() {
return new MultivariateMatrixFunction() {
@Override
public double[][] value(double[] point) {
return jacobian(point);
}
};
}
示例11: getModelFunctionJacobian
import org.apache.commons.math3.analysis.MultivariateMatrixFunction; //导入依赖的package包/类
/**
* @return the model function Jacobian.
*/
public ModelFunctionJacobian getModelFunctionJacobian() {
return new ModelFunctionJacobian(new MultivariateMatrixFunction() {
/** {@inheritDoc} */
public double[][] value(double[] point) {
final double[][] jacobian = new double[observations.size()][];
int i = 0;
for (WeightedObservedPoint observed : observations) {
jacobian[i++] = f.gradient(observed.getX(), point);
}
return jacobian;
}
});
}
示例12: getModelFunctionJacobian
import org.apache.commons.math3.analysis.MultivariateMatrixFunction; //导入依赖的package包/类
/**
* @return the model function Jacobian.
*/
public MultivariateMatrixFunction getModelFunctionJacobian() {
return new MultivariateMatrixFunction() {
/** {@inheritDoc} */
public double[][] value(double[] p) {
final int len = points.length;
final double[][] jacobian = new double[len][];
for (int i = 0; i < len; i++) {
jacobian[i] = f.gradient(points[i], p);
}
return jacobian;
}
};
}
示例13: getJacobianFunction
import org.apache.commons.math3.analysis.MultivariateMatrixFunction; //导入依赖的package包/类
@Override
public MultivariateMatrixFunction getJacobianFunction(final double[] xgrid, final double[] ygrid) {
return new MultivariateMatrixFunction() {
@Override
//derivations by wolfram alpha:
//d(b^2 + ((J*J)/2/PI/(s*s)/(s*s)) * e^( -( ((x0-x)^2)/(2*s*s*s*s) + (((y0-y)^2)/(2*s*s*s*s)))))/dx
public double[][] value(double[] point) throws IllegalArgumentException {
double[] transformedPoint = transformParameters(point);
double sigma = transformedPoint[Params.SIGMA];
double sigmaSquared = sigma * sigma;
double[][] retVal = new double[xgrid.length][transformedPoint.length];
for (int i = 0; i < xgrid.length; i++) {
//d()/dIntensity
double xd = (xgrid[i] - transformedPoint[Params.X]);
double yd = (ygrid[i] - transformedPoint[Params.Y]);
double upper = -(xd * xd + yd * yd) / (2 * sigmaSquared);
double expVal = exp(upper);
double expValDivPISigmaSquared = expVal / (sigmaSquared * PI);
double expValDivPISigmaPowEight = expValDivPISigmaSquared / sigmaSquared;
retVal[i][Params.INTENSITY] = point[Params.INTENSITY] * expValDivPISigmaSquared;
//d()/dx
retVal[i][Params.X] = transformedPoint[Params.INTENSITY] * xd * expValDivPISigmaPowEight * 0.5;
//d()/dy
retVal[i][Params.Y] = transformedPoint[Params.INTENSITY] * yd * expValDivPISigmaPowEight * 0.5;
//d()/dsigma
retVal[i][Params.SIGMA] = transformedPoint[Params.INTENSITY] * expValDivPISigmaPowEight / point[Params.SIGMA] * (xd * xd + yd * yd - 2 * sigmaSquared);
//d()/dbkg
retVal[i][Params.OFFSET] = 2 * point[Params.OFFSET];
}
//IJ.log("numeric jacobian: " + Arrays.deepToString(SymmetricGaussianPSF.super.getJacobianFunction(xgrid, ygrid).value(point)));
//IJ.log("analytic jacobian: " + Arrays.deepToString(retVal));
return retVal;
}
};
}
示例14: getModelFunctionJacobian
import org.apache.commons.math3.analysis.MultivariateMatrixFunction; //导入依赖的package包/类
/**
* @return the model function Jacobian.
*/
public ModelFunctionJacobian getModelFunctionJacobian() {
return new ModelFunctionJacobian(new MultivariateMatrixFunction() {
public double[][] value(double[] point) {
final double[][] jacobian = new double[observations.size()][];
int i = 0;
for (WeightedObservedPoint observed : observations) {
jacobian[i++] = f.gradient(observed.getX(), point);
}
return jacobian;
}
});
}
示例15: getModelFunctionJacobian
import org.apache.commons.math3.analysis.MultivariateMatrixFunction; //导入依赖的package包/类
/**
* @return the model function Jacobian.
*/
public MultivariateMatrixFunction getModelFunctionJacobian() {
return new MultivariateMatrixFunction() {
public double[][] value(double[] p) {
final int len = points.length;
final double[][] jacobian = new double[len][];
for (int i = 0; i < len; i++) {
jacobian[i] = f.gradient(points[i], p);
}
return jacobian;
}
};
}