/** Add an observed weighted (x,y) point to the sample. * @param weight weight of the observed point in the fit * @param x abscissa of the point * @param y observed value of the point at x, after fitting we should * have f(x) as close as possible to this value * @see #addObservedPoint(double, double) * @see #addObservedPoint(WeightedObservedPoint) * @see #getObservations() */ public void addObservedPoint(double weight, double x, double y) { observations.add(new WeightedObservedPoint(weight, x, y)); }
/** * Adds a point to the sample. * * @param weight Weight of the observed point. * @param x Abscissa of the point. * @param y Observed value at {@code x}. After fitting we should * have {@code f(x)} as close as possible to this value. * * @see #add(double, double) * @see #add(WeightedObservedPoint) * @see #toList() */ public void add(double weight, double x, double y) { observations.add(new WeightedObservedPoint(weight, x, y)); }
/** Add an observed weighted (x,y) point to the sample. * @param weight weight of the observed point in the fit * @param x abscissa of the point * @param y observed value of the point at x, after fitting we should * have f(x) as close as possible to this value * @see #addObservedPoint(double, double) * @see #addObservedPoint(WeightedObservedPoint) * @see #getObservations() */ public void addObservedPoint(double weight, double x, double y) { observations.add(new WeightedObservedPoint(weight, x, y)); }
/** Add an observed weighted (x,y) point to the sample. * @param weight weight of the observed point in the fit * @param x abscissa of the point * @param y observed value of the point at x, after fitting we should * have f(x) as close as possible to this value * @see #addObservedPoint(double, double) * @see #addObservedPoint(WeightedObservedPoint) * @see #getObservations() */ public void addObservedPoint(double weight, double x, double y) { observations.add(new WeightedObservedPoint(weight, x, y)); }
/** * Adds a point to the sample. * * @param weight Weight of the observed point. * @param x Abscissa of the point. * @param y Observed value at {@code x}. After fitting we should * have {@code f(x)} as close as possible to this value. * * @see #add(double, double) * @see #add(WeightedObservedPoint) * @see #toList() */ public void add(double weight, double x, double y) { observations.add(new WeightedObservedPoint(weight, x, y)); }
/** * Adds a point to the sample. * * @param weight Weight of the observed point. * @param x Abscissa of the point. * @param y Observed value at {@code x}. After fitting we should * have {@code f(x)} as close as possible to this value. * * @see #add(double, double) * @see #add(WeightedObservedPoint) * @see #toList() */ public void add(double weight, double x, double y) { observations.add(new WeightedObservedPoint(weight, x, y)); }
public static WeightedObservedPoint[] clone( WeightedObservedPoint[] points) { WeightedObservedPoint[] ret = new WeightedObservedPoint[points.length]; for (int i = 0; i < points.length; i++) { ret[i] = new WeightedObservedPoint(points[i].getWeight(), points[i].getX(), points[i].getY()); } return ret; }
/** * Fits sampled data to a polynomial function and keeps the fit in memory. * * @param degree * Degree of the polynomial to be fitted * @throws NullArgumentException * if the computed polynomial coefficients were null * @throws NoDataException * if the computed polynomial coefficients were empty */ public void fitPolynomial(final int degree) { final PolynomialCurveFitter fitter = PolynomialCurveFitter.create(degree); final ArrayList<WeightedObservedPoint> points = new ArrayList<>(); for (int i = 0; i < nPoints; i++) { points.add(new WeightedObservedPoint(1, inputRadii[i], inputCounts[i])); } pFunction = new PolynomialFunction(fitter.fit(points)); fCounts = new double[nPoints]; for (int i = 0; i < nPoints; i++) { fCounts[i] = pFunction.value(inputRadii[i]); } }
points[i] = new WeightedObservedPoint(1, x[i], y[i]); fitter.addObservedPoint(points[i]);