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


Java NonMonotonicSequenceException类代码示例

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


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

示例1: interpolate

import org.apache.commons.math3.exception.NonMonotonicSequenceException; //导入依赖的package包/类
/**
 * Compute an interpolating function by performing a loess fit
 * on the data at the original abscissae and then building a cubic spline
 * with a
 * {@link org.apache.commons.math3.analysis.interpolation.SplineInterpolator}
 * on the resulting fit.
 *
 * @param xval the arguments for the interpolation points
 * @param yval the values for the interpolation points
 * @return A cubic spline built upon a loess fit to the data at the original abscissae
 * @throws NonMonotonicSequenceException if {@code xval} not sorted in
 * strictly increasing order.
 * @throws DimensionMismatchException if {@code xval} and {@code yval} have
 * different sizes.
 * @throws NoDataException if {@code xval} or {@code yval} has zero size.
 * @throws NotFiniteNumberException if any of the arguments and values are
 * not finite real numbers.
 * @throws NumberIsTooSmallException if the bandwidth is too small to
 * accomodate the size of the input data (i.e. the bandwidth must be
 * larger than 2/n).
 */
public final PolynomialSplineFunction interpolate(double[] xval,
                                                  double[] yval)
    throws NonMonotonicSequenceException,
           DimensionMismatchException,
           NoDataException,
           NotFiniteNumberException,
           NumberIsTooSmallException {
    double[] smoothed = smooth(xval, yval);
    DoubleList newX = new ArrayDoubleList();
    DoubleList newSmoothed = new ArrayDoubleList();
    newX.add(xval[0]);
    newSmoothed.add(smoothed[0]);
    for(int i = 1; i < xval.length; i++){
        if(xval[i] != xval[i-1]){
            newX.add(xval[i]);
            newSmoothed.add(smoothed[i]);
        }
    }
    xval = newX.toArray();
    smoothed = newSmoothed.toArray();
    
    return new SplineInterpolator().interpolate(xval, smoothed);
}
 
开发者ID:zitmen,项目名称:thunderstorm,代码行数:45,代码来源:ModifiedLoess.java

示例2: BilinearInterpolatingFunction

import org.apache.commons.math3.exception.NonMonotonicSequenceException; //导入依赖的package包/类
public BilinearInterpolatingFunction(double[] xval, double[] yval, double[][] fval)
throws DimensionMismatchException, NoDataException, NonMonotonicSequenceException {
	if (xval.length == 0 || yval.length == 0 || fval.length == 0) {
		throw new NoDataException();
	}
	if (xval.length != fval.length) {
		throw new DimensionMismatchException(xval.length, fval.length);
	}
	if (yval.length != fval[0].length) {
		throw new DimensionMismatchException(yval.length, fval[0].length);
	}

	MathArrays.checkOrder(xval);
	MathArrays.checkOrder(yval);
	
	this.xval = xval;
	this.yval = yval;
	this.fval = fval;
}
 
开发者ID:sing-group,项目名称:la-images,代码行数:20,代码来源:BilinearInterpolatingFunction.java

示例3: interpolate

import org.apache.commons.math3.exception.NonMonotonicSequenceException; //导入依赖的package包/类
@Override
public BilinearInterpolatingFunction interpolate(double[] xval, double[] yval, double[][] fval)
throws NoDataException, DimensionMismatchException, NonMonotonicSequenceException {
	if (xval.length == 0 || yval.length == 0 || fval.length == 0) {
           throw new NoDataException();
       }
       if (xval.length != fval.length) {
           throw new DimensionMismatchException(xval.length, fval.length);
       }
       if (yval.length != fval[0].length) {
       	throw new DimensionMismatchException(yval.length, fval[0].length);
       }

       MathArrays.checkOrder(xval);
       MathArrays.checkOrder(yval);
       
	return new BilinearInterpolatingFunction(xval, yval, fval);
}
 
开发者ID:sing-group,项目名称:la-images,代码行数:19,代码来源:BilinearInterpolator.java

示例4: StepFunction

import org.apache.commons.math3.exception.NonMonotonicSequenceException; //导入依赖的package包/类
/**
 * Builds a step function from a list of arguments and the corresponding
 * values. Specifically, returns the function h(x) defined by <pre><code>
 * h(x) = y[0] for all x &lt; x[1]
 *        y[1] for x[1] &le; x &lt; x[2]
 *        ...
 *        y[y.length - 1] for x &ge; x[x.length - 1]
 * </code></pre>
 * The value of {@code x[0]} is ignored, but it must be strictly less than
 * {@code x[1]}.
 *
 * @param x Domain values where the function changes value.
 * @param y Values of the function.
 * @throws NonMonotonicSequenceException
 * if the {@code x} array is not sorted in strictly increasing order.
 * @throws NullArgumentException if {@code x} or {@code y} are {@code null}.
 * @throws NoDataException if {@code x} or {@code y} are zero-length.
 * @throws DimensionMismatchException if {@code x} and {@code y} do not
 * have the same length.
 */
public StepFunction(double[] x,
                    double[] y)
    throws NullArgumentException, NoDataException,
           DimensionMismatchException, NonMonotonicSequenceException {
    if (x == null ||
        y == null) {
        throw new NullArgumentException();
    }
    if (x.length == 0 ||
        y.length == 0) {
        throw new NoDataException();
    }
    if (y.length != x.length) {
        throw new DimensionMismatchException(y.length, x.length);
    }
    MathArrays.checkOrder(x);

    abscissa = MathArrays.copyOf(x);
    ordinate = MathArrays.copyOf(y);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:41,代码来源:StepFunction.java

示例5: PolynomialSplineFunction

import org.apache.commons.math3.exception.NonMonotonicSequenceException; //导入依赖的package包/类
/**
 * Construct a polynomial spline function with the given segment delimiters
 * and interpolating polynomials.
 * The constructor copies both arrays and assigns the copies to the knots
 * and polynomials properties, respectively.
 *
 * @param knots Spline segment interval delimiters.
 * @param polynomials Polynomial functions that make up the spline.
 * @throws NullArgumentException if either of the input arrays is {@code null}.
 * @throws NumberIsTooSmallException if knots has length less than 2.
 * @throws DimensionMismatchException if {@code polynomials.length != knots.length - 1}.
 * @throws NonMonotonicSequenceException if the {@code knots} array is not strictly increasing.
 *
 */
public PolynomialSplineFunction(double knots[], PolynomialFunction polynomials[])
    throws NullArgumentException, NumberIsTooSmallException,
           DimensionMismatchException, NonMonotonicSequenceException{
    if (knots == null ||
        polynomials == null) {
        throw new NullArgumentException();
    }
    if (knots.length < 2) {
        throw new NumberIsTooSmallException(LocalizedFormats.NOT_ENOUGH_POINTS_IN_SPLINE_PARTITION,
                                            2, knots.length, false);
    }
    if (knots.length - 1 != polynomials.length) {
        throw new DimensionMismatchException(polynomials.length, knots.length);
    }
    MathArrays.checkOrder(knots);

    this.n = knots.length -1;
    this.knots = new double[n + 1];
    System.arraycopy(knots, 0, this.knots, 0, n + 1);
    this.polynomials = new PolynomialFunction[n];
    System.arraycopy(polynomials, 0, this.polynomials, 0, n);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:37,代码来源:PolynomialSplineFunction.java

示例6: evaluate

import org.apache.commons.math3.exception.NonMonotonicSequenceException; //导入依赖的package包/类
/**
 * Evaluate the Lagrange polynomial using
 * <a href="http://mathworld.wolfram.com/NevillesAlgorithm.html">
 * Neville's Algorithm</a>. It takes O(n^2) time.
 *
 * @param x Interpolating points array.
 * @param y Interpolating values array.
 * @param z Point at which the function value is to be computed.
 * @return the function value.
 * @throws DimensionMismatchException if {@code x} and {@code y} have
 * different lengths.
 * @throws NonMonotonicSequenceException
 * if {@code x} is not sorted in strictly increasing order.
 * @throws NumberIsTooSmallException if the size of {@code x} is less
 * than 2.
 */
public static double evaluate(double x[], double y[], double z)
    throws DimensionMismatchException, NumberIsTooSmallException, NonMonotonicSequenceException {
    if (verifyInterpolationArray(x, y, false)) {
        return evaluateInternal(x, y, z);
    }

    // Array is not sorted.
    final double[] xNew = new double[x.length];
    final double[] yNew = new double[y.length];
    System.arraycopy(x, 0, xNew, 0, x.length);
    System.arraycopy(y, 0, yNew, 0, y.length);

    MathArrays.sortInPlace(xNew, yNew);
    // Second check in case some abscissa is duplicated.
    verifyInterpolationArray(xNew, yNew, true);
    return evaluateInternal(xNew, yNew, z);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:34,代码来源:PolynomialFunctionLagrangeForm.java

示例7: interpolate

import org.apache.commons.math3.exception.NonMonotonicSequenceException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public PiecewiseBicubicSplineInterpolatingFunction interpolate( final double[] xval,
                                                                final double[] yval,
                                                                final double[][] fval)
    throws DimensionMismatchException,
           NullArgumentException,
           NoDataException,
           NonMonotonicSequenceException {
    if ( xval == null ||
         yval == null ||
         fval == null ||
         fval[0] == null ) {
        throw new NullArgumentException();
    }

    if ( xval.length == 0 ||
         yval.length == 0 ||
         fval.length == 0 ) {
        throw new NoDataException();
    }

    MathArrays.checkOrder(xval);
    MathArrays.checkOrder(yval);

    return new PiecewiseBicubicSplineInterpolatingFunction( xval, yval, fval );
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:29,代码来源:PiecewiseBicubicSplineInterpolator.java

示例8: interpolate

import org.apache.commons.math3.exception.NonMonotonicSequenceException; //导入依赖的package包/类
/**
 * Compute an interpolating function for the dataset.
 *
 * @param x Interpolating points array.
 * @param y Interpolating values array.
 * @return a function which interpolates the dataset.
 * @throws DimensionMismatchException if the array lengths are different.
 * @throws NumberIsTooSmallException if the number of points is less than 2.
 * @throws NonMonotonicSequenceException if {@code x} is not sorted in
 * strictly increasing order.
 */
public PolynomialFunctionNewtonForm interpolate(double x[], double y[])
    throws DimensionMismatchException,
           NumberIsTooSmallException,
           NonMonotonicSequenceException {
    /**
     * a[] and c[] are defined in the general formula of Newton form:
     * p(x) = a[0] + a[1](x-c[0]) + a[2](x-c[0])(x-c[1]) + ... +
     *        a[n](x-c[0])(x-c[1])...(x-c[n-1])
     */
    PolynomialFunctionLagrangeForm.verifyInterpolationArray(x, y, true);

    /**
     * When used for interpolation, the Newton form formula becomes
     * p(x) = f[x0] + f[x0,x1](x-x0) + f[x0,x1,x2](x-x0)(x-x1) + ... +
     *        f[x0,x1,...,x[n-1]](x-x0)(x-x1)...(x-x[n-2])
     * Therefore, a[k] = f[x0,x1,...,xk], c[k] = x[k].
     * <p>
     * Note x[], y[], a[] have the same length but c[]'s size is one less.</p>
     */
    final double[] c = new double[x.length-1];
    System.arraycopy(x, 0, c, 0, c.length);

    final double[] a = computeDividedDifference(x, y);
    return new PolynomialFunctionNewtonForm(a, c);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:37,代码来源:DividedDifferenceInterpolator.java

示例9: computeDividedDifference

import org.apache.commons.math3.exception.NonMonotonicSequenceException; //导入依赖的package包/类
/**
 * Return a copy of the divided difference array.
 * <p>
 * The divided difference array is defined recursively by <pre>
 * f[x0] = f(x0)
 * f[x0,x1,...,xk] = (f[x1,...,xk] - f[x0,...,x[k-1]]) / (xk - x0)
 * </pre>
 * <p>
 * The computational complexity is \(O(n^2)\) where \(n\) is the common
 * length of {@code x} and {@code y}.</p>
 *
 * @param x Interpolating points array.
 * @param y Interpolating values array.
 * @return a fresh copy of the divided difference array.
 * @throws DimensionMismatchException if the array lengths are different.
 * @throws NumberIsTooSmallException if the number of points is less than 2.
 * @throws NonMonotonicSequenceException
 * if {@code x} is not sorted in strictly increasing order.
 */
protected static double[] computeDividedDifference(final double x[], final double y[])
    throws DimensionMismatchException,
           NumberIsTooSmallException,
           NonMonotonicSequenceException {
    PolynomialFunctionLagrangeForm.verifyInterpolationArray(x, y, true);

    final double[] divdiff = y.clone(); // initialization

    final int n = x.length;
    final double[] a = new double [n];
    a[0] = divdiff[0];
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < n-i; j++) {
            final double denominator = x[j+i] - x[j];
            divdiff[j] = (divdiff[j+1] - divdiff[j]) / denominator;
        }
        a[i] = divdiff[0];
    }

    return a;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:41,代码来源:DividedDifferenceInterpolator.java

示例10: StepFunction

import org.apache.commons.math3.exception.NonMonotonicSequenceException; //导入依赖的package包/类
/**
 * Builds a step function from a list of arguments and the corresponding
 * values. Specifically, returns the function h(x) defined by <pre><code>
 * h(x) = y[0] for all x < x[1]
 *        y[1] for x[1] <= x < x[2]
 *        ...
 *        y[y.length - 1] for x >= x[x.length - 1]
 * </code></pre>
 * The value of {@code x[0]} is ignored, but it must be strictly less than
 * {@code x[1]}.
 *
 * @param x Domain values where the function changes value.
 * @param y Values of the function.
 * @throws NonMonotonicSequenceException
 * if the {@code x} array is not sorted in strictly increasing order.
 * @throws NullArgumentException if {@code x} or {@code y} are {@code null}.
 * @throws NoDataException if {@code x} or {@code y} are zero-length.
 * @throws DimensionMismatchException if {@code x} and {@code y} do not
 * have the same length.
 */
public StepFunction(double[] x,
                    double[] y)
    throws NullArgumentException, NoDataException,
           DimensionMismatchException, NonMonotonicSequenceException {
    if (x == null ||
        y == null) {
        throw new NullArgumentException();
    }
    if (x.length == 0 ||
        y.length == 0) {
        throw new NoDataException();
    }
    if (y.length != x.length) {
        throw new DimensionMismatchException(y.length, x.length);
    }
    MathArrays.checkOrder(x);

    abscissa = MathArrays.copyOf(x);
    ordinate = MathArrays.copyOf(y);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:41,代码来源:StepFunction.java

示例11: computeDividedDifference

import org.apache.commons.math3.exception.NonMonotonicSequenceException; //导入依赖的package包/类
/**
 * Return a copy of the divided difference array.
 * <p>
 * The divided difference array is defined recursively by <pre>
 * f[x0] = f(x0)
 * f[x0,x1,...,xk] = (f[x1,...,xk] - f[x0,...,x[k-1]]) / (xk - x0)
 * </pre></p>
 * <p>
 * The computational complexity is O(N^2).</p>
 *
 * @param x Interpolating points array.
 * @param y Interpolating values array.
 * @return a fresh copy of the divided difference array.
 * @throws DimensionMismatchException if the array lengths are different.
 * @throws NumberIsTooSmallException if the number of points is less than 2.
 * @throws NonMonotonicSequenceException
 * if {@code x} is not sorted in strictly increasing order.
 */
protected static double[] computeDividedDifference(final double x[], final double y[])
    throws DimensionMismatchException,
           NumberIsTooSmallException,
           NonMonotonicSequenceException {
    PolynomialFunctionLagrangeForm.verifyInterpolationArray(x, y, true);

    final double[] divdiff = y.clone(); // initialization

    final int n = x.length;
    final double[] a = new double [n];
    a[0] = divdiff[0];
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < n-i; j++) {
            final double denominator = x[j+i] - x[j];
            divdiff[j] = (divdiff[j+1] - divdiff[j]) / denominator;
        }
        a[i] = divdiff[0];
    }

    return a;
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:40,代码来源:DividedDifferenceInterpolator.java

示例12: testParameters

import org.apache.commons.math3.exception.NonMonotonicSequenceException; //导入依赖的package包/类
/**
 * Test of parameters for the interpolator.
 */
@Test
public void testParameters() {
    UnivariateInterpolator interpolator = new DividedDifferenceInterpolator();

    try {
        // bad abscissas array
        double x[] = { 1.0, 2.0, 2.0, 4.0 };
        double y[] = { 0.0, 4.0, 4.0, 2.5 };
        UnivariateFunction p = interpolator.interpolate(x, y);
        p.value(0.0);
        Assert.fail("Expecting NonMonotonicSequenceException - bad abscissas array");
    } catch (NonMonotonicSequenceException ex) {
        // expected
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:19,代码来源:DividedDifferenceInterpolatorTest.java

示例13: testParameters

import org.apache.commons.math3.exception.NonMonotonicSequenceException; //导入依赖的package包/类
/**
 * Test of parameters for the interpolator.
 */
@Test
public void testParameters() {
    UnivariateInterpolator interpolator = new NevilleInterpolator();

    try {
        // bad abscissas array
        double x[] = { 1.0, 2.0, 2.0, 4.0 };
        double y[] = { 0.0, 4.0, 4.0, 2.5 };
        UnivariateFunction p = interpolator.interpolate(x, y);
        p.value(0.0);
        Assert.fail("Expecting NonMonotonicSequenceException - bad abscissas array");
    } catch (NonMonotonicSequenceException ex) {
        // expected
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:19,代码来源:NevilleInterpolatorTest.java


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