Example usage for org.apache.commons.collections.primitives ArrayDoubleList ArrayDoubleList

List of usage examples for org.apache.commons.collections.primitives ArrayDoubleList ArrayDoubleList

Introduction

In this page you can find the example usage for org.apache.commons.collections.primitives ArrayDoubleList ArrayDoubleList.

Prototype

public ArrayDoubleList() 

Source Link

Document

Construct an empty list with the default initial capacity.

Usage

From source file:cz.cuni.lf1.lge.ThunderSTORM.results.ModifiedLoess.java

/**
 * Compute an interpolating function by performing a loess fit
 * on the data at the original abscissae and then building a cubic spline
 * with a/*from  ww  w .j a  va2s .  c o  m*/
 * {@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);
}

From source file:plugin.trackmate.tram.trackanalyzer.TrAM.java

/**
 * Computes the median absolute difference between adjacent values within
 * each data vector./*from  w w  w.ja v  a2 s .c o  m*/
 * 
 * @param timeSeries
 *            a staggered array whose rows are each independent time series.
 * @return the median absolute difference between adjacent values within all
 *         time series.
 */
public static double computeMedianAbsoluteDifference(final double[][] timeSeries) {
    if (timeSeries.length < 1)
        throw new IllegalArgumentException("Must have at least one data vector.");

    // where we accumulate all the absolute differences
    final ArrayDoubleList accum = new ArrayDoubleList();

    // compute absolute differences for each time series
    for (final double[] vals : timeSeries) {
        for (int i = 0; i < vals.length - 1; ++i)
            accum.add(Math.abs(vals[i + 1] - vals[i]));
    }

    final Median m = new Median();
    m.setData(accum.toArray());

    return m.evaluate();
}