List of usage examples for org.jfree.data.statistics Regression getPowerRegression
public static double[] getPowerRegression(XYDataset data, int series)
From source file:org.operamasks.faces.render.graph.ChartRenderer.java
private XYSeries createCurveSeries(UICurve curve, XYDataset data, int index) { if (data.getItemCount(index) < 2) { throw new IllegalArgumentException("Not enough data"); }/*from w w w .j a v a 2 s. c om*/ Key key = new Key(index, curve.getLegend()); if (curve instanceof UIAverageLine) { double period = ((UIAverageLine) curve).getPeriod(); double skip = ((UIAverageLine) curve).getSkip(); if (data instanceof TimeSeriesCollection) { TimeSeries ts = ((TimeSeriesCollection) data).getSeries(index); return MovingAverage.createMovingAverage(ts, key, (int) period, (int) skip); } else { return MovingAverage.createMovingAverage(data, index, key, period, skip); } } else if (curve instanceof UIRegressionLine) { RegressionType type = ((UIRegressionLine) curve).getType(); int samples = ((UIRegressionLine) curve).getSamples(); if (type == null || type == RegressionType.Linear) { double[] p = Regression.getOLSRegression(data, index); Function2D f = new LineFunction2D(p[0], p[1]); return createFunctionSeries(data, index, key, f, samples); } else if (type == RegressionType.Power) { double[] p = Regression.getPowerRegression(data, index); Function2D f = new PowerFunction2D(p[0], p[1]); return createFunctionSeries(data, index, key, f, samples); } else { throw new IllegalArgumentException(type.toString()); } } else if (curve instanceof UISpline) { SplineType type = ((UISpline) curve).getType(); int samples = ((UISpline) curve).getSamples(); int degree = ((UISpline) curve).getDegree(); if (type == null || type == SplineType.BSpline) { return BSpline.createBSpline(data, index, key, samples, degree); } else if (type == SplineType.CubicSpline) { return CubicSpline.createCubicSpline(data, index, key, samples); } } return null; }