org.apache.commons.math3.analysis.interpolation.LinearInterpolator Java Examples
The following examples show how to use
org.apache.commons.math3.analysis.interpolation.LinearInterpolator.
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: SeaWaterInitialDelta234UTableModel.java From ET_Redux with Apache License 2.0 | 4 votes |
public double calculateAr234U_238Uisw(double ageInYears) { LinearInterpolator linearInterpolator = new LinearInterpolator(); double[] dates = getArrayOfDates(); double[] deltas = getArrayOfDeltasAsRatios(); PolynomialSplineFunction psfSeaWater = linearInterpolator.interpolate(dates, deltas); double retVal = 0; try { retVal = psfSeaWater.value(ageInYears); } catch (Exception e) { // System.out.println("calculateAr234U_238Uisw error with age = " + ageInYears); retVal = 0; } return retVal; }
Example #2
Source File: SeaWaterInitialDelta234UTableModel.java From ET_Redux with Apache License 2.0 | 4 votes |
public double calculateAr234U_238UiswUnct(double ageInYears) { LinearInterpolator linearInterpolator = new LinearInterpolator(); double[] dates = getArrayOfDates(); double[] deltasUnct = getArrayOfDeltasAsRatioUncertainties(); PolynomialSplineFunction psfSeaWaterUnct = linearInterpolator.interpolate(dates, deltasUnct); double retVal = 0; try { retVal = psfSeaWaterUnct.value(ageInYears); } catch (Exception e) { // System.out.println("calculateAr234U_238UiswUnct error with age = " + ageInYears); retVal = 0; } return retVal; }
Example #3
Source File: InterpUtil.java From MeteoInfo with GNU Lesser General Public License v3.0 | 2 votes |
/** * Make linear interpolation function - PolynomialSplineFunction * * @param x X data * @param y Y data * @return Linear interpolation function */ public static PolynomialSplineFunction linearInterpFunc(Array x, Array y) { double[] xd = (double[]) ArrayUtil.copyToNDJavaArray_Double(x); double[] yd = (double[]) ArrayUtil.copyToNDJavaArray_Double(y); LinearInterpolator li = new LinearInterpolator(); PolynomialSplineFunction psf = li.interpolate(xd, yd); return psf; }
Example #4
Source File: LerpEvaluator.java From lucene-solr with Apache License 2.0 | 2 votes |
@Override @SuppressWarnings({"unchecked"}) public Object doWork(Object... objects) throws IOException{ Object first = objects[0]; double[] x = null; double[] y = null; if(objects.length == 1) { //Only the y values passed y = ((List) first).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray(); x = new double[y.length]; for(int i=0; i<y.length; i++) { x[i] = i; } } else if(objects.length == 2) { Object second = objects[1]; x = ((List) first).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray(); y = ((List) second).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray(); } LinearInterpolator interpolator = new LinearInterpolator(); PolynomialSplineFunction spline = interpolator.interpolate(x, y); List<Number> list = new ArrayList<>(); for(double xvalue : x) { list.add(spline.value(xvalue)); } VectorFunction vec = new VectorFunction(spline, list); vec.addToContext("x", x); vec.addToContext("y", y); return vec; }
Example #5
Source File: Interpolation.java From mars-sim with GNU General Public License v3.0 | 2 votes |
public double[] linearInterp(double[] x, double[] y, double[] xi) { LinearInterpolator li = new LinearInterpolator(); // or other interpolator PolynomialSplineFunction psf = li.interpolate(x, y); double[] yi = new double[xi.length]; for (int i = 0; i < xi.length; i++) { yi[i] = psf.value(xi[i]); } return yi; }
Example #6
Source File: PSquarePercentile.java From astor with GNU General Public License v2.0 | 1 votes |
/** * Read Object to deserialize. * * @param anInstream Stream Object data * @throws IOException thrown for IO Errors * @throws ClassNotFoundException thrown for class not being found */ private void readObject(ObjectInputStream anInstream) throws ClassNotFoundException, IOException { anInstream.defaultReadObject(); previous=next=this; linear = new LinearInterpolator(); }
Example #7
Source File: PSquarePercentile.java From astor with GNU General Public License v2.0 | 1 votes |
/** * Read Object to deserialize. * * @param anInstream Stream Object data * @throws IOException thrown for IO Errors * @throws ClassNotFoundException thrown for class not being found */ private void readObject(ObjectInputStream anInstream) throws ClassNotFoundException, IOException { anInstream.defaultReadObject(); previous=next=this; linear = new LinearInterpolator(); }