Package org.apache.commons.math

Examples of org.apache.commons.math.MathException


            }
            if (Math.abs(rootFindingFunction.value(upperBound)) < 1E-6) {
                return upperBound;
            }    
            // Failed bracket convergence was not because of corner solution
            throw new MathException(ex);
        }

        // find root
        double root = UnivariateRealSolverUtils.solve(rootFindingFunction,
                bracket[0],bracket[1]);
View Full Code Here


     * @see <a href="http://commons.apache.org/collections/api-release/org/apache/commons/collections/Transformer.html"/>
     */
    public double transform(Object o) throws MathException{

        if (o == null) {
            throw new MathException("Conversion Exception in Transformation, Object is null");
        }

        if (o instanceof Number) {
            return ((Number)o).doubleValue();
        }
           
        try {
            return Double.valueOf(o.toString()).doubleValue();
        } catch (Exception e) {
            throw new MathException(e,
                                    "Conversion Exception in Transformation: {0}", e.getMessage());
        }
    }
View Full Code Here

        recomputeZ();
        if (x < 0 || x > 1) {
            return 0;
        } else if (x == 0) {
            if (alpha < 1) {
                throw new MathException("Cannot compute beta density at 0 when alpha = {0,number}", alpha);
            }
            return 0;
        } else if (x == 1) {
            if (beta < 1) {
                throw new MathException("Cannot compute beta density at 1 when beta = %.3g", beta);
            }
            return 0;
        } else {
            double logX = Math.log(x);
            double log1mX = Math.log1p(-x);
View Full Code Here

            }
            if (Math.abs(rootFindingFunction.value(upperBound)) < 1E-6) {
                return upperBound;
            }    
            // Failed bracket convergence was not because of corner solution
            throw new MathException(ex);
        }

        // find root
        double root = UnivariateRealSolverUtils.solve(rootFindingFunction,
                bracket[0],bracket[1]);
View Full Code Here

     * @throws MathException if bandwidth does not lie in the interval [0,1]
     * or if robustnessIters is negative.
     */
    public LoessInterpolator(double bandwidth, int robustnessIters) throws MathException {
        if (bandwidth < 0 || bandwidth > 1) {
            throw new MathException("bandwidth must be in the interval [0,1], but got {0}",
                                    bandwidth);
        }
        this.bandwidth = bandwidth;
        if (robustnessIters < 0) {
            throw new MathException("the number of robustness iterations must " +
                                    "be non-negative, but got {0}",
                                    robustnessIters);
        }
        this.robustnessIters = robustnessIters;
    }
View Full Code Here

     * </ul>
     */
    public final double[] smooth(final double[] xval, final double[] yval)
            throws MathException {
        if (xval.length != yval.length) {
            throw new MathException(
                    "Loess expects the abscissa and ordinate arrays " +
                    "to be of the same size, " +
                    "but got {0} abscisssae and {1} ordinatae",
                    xval.length, yval.length);
        }

        final int n = xval.length;

        if (n == 0) {
            throw new MathException("Loess expects at least 1 point");
        }

        checkAllFiniteReal(xval, true);
        checkAllFiniteReal(yval, false);

        checkStrictlyIncreasing(xval);

        if (n == 1) {
            return new double[]{yval[0]};
        }

        if (n == 2) {
            return new double[]{yval[0], yval[1]};
        }

        int bandwidthInPoints = (int) (bandwidth * n);

        if (bandwidthInPoints < 2) {
            throw new MathException(
                    "the bandwidth must be large enough to " +
                    "accomodate at least 2 points. There are {0} " +
                    " data points, and bandwidth must be at least {1} " +
                    " but it is only {2}",
                    n, 2.0 / n, bandwidth);
View Full Code Here

            final double x = values[i];
            if (Double.isInfinite(x) || Double.isNaN(x)) {
                final String pattern = isAbscissae ?
                        "all abscissae must be finite real numbers, but {0}-th is {1}" :
                        "all ordinatae must be finite real numbers, but {0}-th is {1}";
                throw new MathException(pattern, i, x);
            }
        }
    }
View Full Code Here

     */
    private static void checkStrictlyIncreasing(final double[] xval)
        throws MathException {
        for (int i = 0; i < xval.length; ++i) {
            if (i >= 1 && xval[i - 1] >= xval[i]) {
                throw new MathException(
                        "the abscissae array must be sorted in a strictly " +
                        "increasing order, but the {0}-th element is {1} " +
                        "whereas {2}-th is {3}",
                        i - 1, xval[i - 1], i, xval[i]);
            }
View Full Code Here

     * @see org.apache.commons.collections.Transformer#transform(java.lang.Object)
     */
    public double transform(Object o) throws MathException{

        if (o == null) {
            throw new MathException("Conversion Exception in Transformation, Object is null");
        }

        if (o instanceof Number) {
            return ((Number)o).doubleValue();
        }
           
        try {
            return new Double(o.toString()).doubleValue();
        } catch (Exception e) {
            throw new MathException("Conversion Exception in Transformation: " + e.getMessage(), e);
        }
    }
View Full Code Here

            }
            if (Math.abs(rootFindingFunction.value(upperBound)) < 1E-6) {
                return upperBound;
            }    
            // Failed bracket convergence was not because of corner solution
            throw new MathException(ex);
        }

        // find root
        double root = UnivariateRealSolverUtils.solve(rootFindingFunction,
                bracket[0],bracket[1]);
View Full Code Here

TOP

Related Classes of org.apache.commons.math.MathException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.