Java Code Examples for org.apache.commons.math.exception.util.LocalizedFormats#NO_DEGREES_OF_FREEDOM

The following examples show how to use org.apache.commons.math.exception.util.LocalizedFormats#NO_DEGREES_OF_FREEDOM . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractEstimator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Guess the errors in unbound estimated parameters.
 * <p>Guessing is covariance-based, it only gives rough order of magnitude.</p>
 * @param problem estimation problem
 * @return errors in estimated parameters
 * @exception EstimationException if the covariances matrix cannot be computed
 * or the number of degrees of freedom is not positive (number of measurements
 * lesser or equal to number of parameters)
 */
public double[] guessParametersErrors(EstimationProblem problem)
  throws EstimationException {
    int m = problem.getMeasurements().length;
    int p = problem.getUnboundParameters().length;
    if (m <= p) {
        throw new EstimationException(
                LocalizedFormats.NO_DEGREES_OF_FREEDOM,
                m, p);
    }
    double[] errors = new double[problem.getUnboundParameters().length];
    final double c = FastMath.sqrt(getChiSquare(problem) / (m - p));
    double[][] covar = getCovariances(problem);
    for (int i = 0; i < errors.length; ++i) {
        errors[i] = FastMath.sqrt(covar[i][i]) * c;
    }
    return errors;
}
 
Example 2
Source File: AbstractLeastSquaresOptimizer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Guess the errors in optimized parameters.
 * Guessing is covariance-based: It only gives a rough order of magnitude.
 *
 * @return errors in optimized parameters
 * @throws org.apache.commons.math.linear.SingularMatrixException
 * if the covariances matrix cannot be computed.
 * @throws NumberIsTooSmallException if the number of degrees of freedom is not
 * positive, i.e. the number of measurements is less or equal to the number of
 * parameters.
 * @throws org.apache.commons.math.exception.MathUserException if the jacobian
 * function throws one.
 */
public double[] guessParametersErrors() {
    if (rows <= cols) {
        throw new NumberIsTooSmallException(LocalizedFormats.NO_DEGREES_OF_FREEDOM,
                                            rows, cols, false);
    }
    double[] errors = new double[cols];
    final double c = FastMath.sqrt(getChiSquare() / (rows - cols));
    double[][] covar = getCovariances();
    for (int i = 0; i < errors.length; ++i) {
        errors[i] = FastMath.sqrt(covar[i][i]) * c;
    }
    return errors;
}
 
Example 3
Source File: AbstractLeastSquaresOptimizer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Guess the errors in optimized parameters.
 * <p>Guessing is covariance-based, it only gives rough order of magnitude.</p>
 * @return errors in optimized parameters
 * @exception FunctionEvaluationException if the function jacobian cannot b evaluated
 * @exception ConvergenceException if the covariances matrix cannot be computed
 * or the number of degrees of freedom is not positive (number of measurements
 * lesser or equal to number of parameters)
 */
public double[] guessParametersErrors()
    throws FunctionEvaluationException {
    if (rows <= cols) {
        throw new ConvergenceException(LocalizedFormats.NO_DEGREES_OF_FREEDOM,
                                       rows, cols);
    }
    double[] errors = new double[cols];
    final double c = FastMath.sqrt(getChiSquare() / (rows - cols));
    double[][] covar = getCovariances();
    for (int i = 0; i < errors.length; ++i) {
        errors[i] = FastMath.sqrt(covar[i][i]) * c;
    }
    return errors;
}
 
Example 4
Source File: AbstractLeastSquaresOptimizer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Guess the errors in optimized parameters.
 * Guessing is covariance-based: It only gives a rough order of magnitude.
 *
 * @return errors in optimized parameters
 * @throws org.apache.commons.math.linear.SingularMatrixException
 * if the covariances matrix cannot be computed.
 * @throws NumberIsTooSmallException if the number of degrees of freedom is not
 * positive, i.e. the number of measurements is less or equal to the number of
 * parameters.
 * @throws org.apache.commons.math.exception.MathUserException if the jacobian
 * function throws one.
 */
public double[] guessParametersErrors() {
    if (rows <= cols) {
        throw new NumberIsTooSmallException(LocalizedFormats.NO_DEGREES_OF_FREEDOM,
                                            rows, cols, false);
    }
    double[] errors = new double[cols];
    final double c = FastMath.sqrt(getChiSquare() / (rows - cols));
    double[][] covar = getCovariances();
    for (int i = 0; i < errors.length; ++i) {
        errors[i] = FastMath.sqrt(covar[i][i]) * c;
    }
    return errors;
}
 
Example 5
Source File: AbstractLeastSquaresOptimizer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Guess the errors in optimized parameters.
 * Guessing is covariance-based: It only gives a rough order of magnitude.
 *
 * @return errors in optimized parameters
 * @throws org.apache.commons.math.linear.SingularMatrixException
 * if the covariances matrix cannot be computed.
 * @throws NumberIsTooSmallException if the number of degrees of freedom is not
 * positive, i.e. the number of measurements is less or equal to the number of
 * parameters.
 * @throws org.apache.commons.math.exception.MathUserException if the jacobian
 * function throws one.
 */
public double[] guessParametersErrors() {
    if (rows <= cols) {
        throw new NumberIsTooSmallException(LocalizedFormats.NO_DEGREES_OF_FREEDOM,
                                            rows, cols, false);
    }
    double[] errors = new double[cols];
    final double c = FastMath.sqrt(getChiSquare() / (rows - cols));
    double[][] covar = getCovariances();
    for (int i = 0; i < errors.length; ++i) {
        errors[i] = FastMath.sqrt(covar[i][i]) * c;
    }
    return errors;
}