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


Java LoessInterpolator类代码示例

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


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

示例1: loessInterpolation

import org.apache.commons.math3.analysis.interpolation.LoessInterpolator; //导入依赖的package包/类
public IDecimalAggregate<E> loessInterpolation(final LoessInterpolationConfig config) {
    if (values.isEmpty()) {
        return DummyDecimalAggregate.getInstance();
    }

    if (values.size() < 3) {
        return parent;
    }

    final Pair<List<Double>, List<Double>> pair = fillInterpolationPoints(config, null);
    final List<Double> xval = pair.getFirst();
    final List<Double> yval = pair.getSecond();
    double bandwidth = config.getSmoothness().getValue(PercentScale.RATE).doubleValue();
    if (bandwidth * values.size() < 2) {
        bandwidth = Decimal.TWO.divide(values.size()).doubleValue();
    }
    final UnivariateInterpolator interpolator = new LoessInterpolator(bandwidth,
            LoessInterpolator.DEFAULT_ROBUSTNESS_ITERS);
    return interpolate(config, xval, yval, interpolator);
}
 
开发者ID:subes,项目名称:invesdwin-util,代码行数:21,代码来源:DecimalAggregateInterpolations.java

示例2: createInterpolator

import org.apache.commons.math3.analysis.interpolation.LoessInterpolator; //导入依赖的package包/类
private UnivariateInterpolator createInterpolator()
{	
switch(this.gcDepthInterpolation)
	{
	case loess: return new LoessInterpolator(0.5,4);
	case neville: return new NevilleInterpolator();
	case difference  : return new DividedDifferenceInterpolator();
	case linear: return new LinearInterpolator();
	case spline : return new SplineInterpolator();
	case identity : return new UnivariateInterpolator()
			{
			@Override
			public UnivariateFunction interpolate(double[] arg0, double[] arg1)
					throws MathIllegalArgumentException, DimensionMismatchException {
				return new Identity();
				}
			};
	default: throw new IllegalStateException("Not implemented");
	}
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:21,代码来源:CopyNumber01.java

示例3: loessSmooth

import org.apache.commons.math3.analysis.interpolation.LoessInterpolator; //导入依赖的package包/类
/**
 * @param weights
 *  The weights to use for smoothing, if null, equal weights are assumed
 * @return
 *  Smoothed series
 */
private double[] loessSmooth(double[] times, double[] series, double bandwidth, double[] weights) {
  if (weights == null) {
    return new LoessInterpolator(bandwidth, LOESS_ROBUSTNESS_ITERATIONS).smooth(times, series);
  } else {
    return new LoessInterpolator(bandwidth, LOESS_ROBUSTNESS_ITERATIONS).smooth(times, series, weights);
  }
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:14,代码来源:STLDecomposition.java

示例4: getSmoothedCurve

import org.apache.commons.math3.analysis.interpolation.LoessInterpolator; //导入依赖的package包/类
/**
 * Perform LOESS smoothing on the FRC curve.
 * <p>
 * The correlation values are smoothed using a LOESS interpolation with the given parameters. If smoothing fails the
 * original curve values are returned. If successful then the input curve is optionally copied and updated with the
 * smoothed correlation.
 *
 * @param frcCurve
 *            the frc curve
 * @param bandwidth
 *            the bandwidth
 * @param robustness
 *            the robustness
 * @param inPlace
 *            Set to true to modify the correlation in place (do not create a copy)
 * @return A new FRC curve
 */
private static FRCCurve getSmoothedCurve(FRCCurve frcCurve, double bandwidth, int robustness, boolean inPlace)
{
	double[] xVals = new double[frcCurve.getSize()];
	double[] yVals = new double[frcCurve.getSize()];

	for (int i = 0; i < frcCurve.getSize(); i++)
	{
		xVals[i] = frcCurve.get(i).getRadius();
		yVals[i] = frcCurve.get(i).getCorrelation();
	}

	double[] ySmoothed = new double[frcCurve.getSize()];

	try
	{
		LoessInterpolator loess = new LoessInterpolator(bandwidth, robustness);
		ySmoothed = loess.smooth(xVals, yVals);

		if (!inPlace)
			frcCurve = frcCurve.copy();

		for (int i = 0; i < frcCurve.getSize(); i++)
			frcCurve.get(i).setCorrelation(ySmoothed[i]);
	}
	catch (Exception e)
	{
		e.printStackTrace();
	}

	return frcCurve;
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:49,代码来源:FRC.java

示例5: smooth

import org.apache.commons.math3.analysis.interpolation.LoessInterpolator; //导入依赖的package包/类
private static boolean smooth(double[] newDx, double[] newDy, double[] originalDriftTimePoints, double smoothing,
		int iterations)
{
	double[][] values = extractValues(originalDriftTimePoints, 0, newDx.length - 1, newDx, newDy);

	// Smooth
	LoessInterpolator loess = new LoessInterpolator(smoothing, iterations);
	values[1] = loess.smooth(values[0], values[1]);
	values[2] = loess.smooth(values[0], values[2]);

	// Add back
	int n = 0;
	for (int t = 0; t < newDx.length; t++)
	{
		if (originalDriftTimePoints[t] != 0)
		{
			newDx[t] = values[1][n];
			newDy[t] = values[2][n];
			n++;

			if (Double.isNaN(newDx[t]))
			{
				Utils.log("ERROR : Loess smoothing created bad X-estimate at point %d/%d", t, newDx.length);
				return false;
			}
			if (Double.isNaN(newDy[t]))
			{
				Utils.log("ERROR : Loess smoothing created bad Y-estimate at point %d/%d", t, newDx.length);
				return false;
			}
		}
	}

	return true;
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:36,代码来源:DriftCalculator.java

示例6: GenerateMassCalibrationRTMap

import org.apache.commons.math3.analysis.interpolation.LoessInterpolator; //导入依赖的package包/类
public void GenerateMassCalibrationRTMap() throws IOException {
    String pngfile = FilenameUtils.getFullPath(ScanCollectionName) + "/" + FilenameUtils.getBaseName(ScanCollectionName) + "_masscaliRT.png";
    XYSeries series = new XYSeries("PSM");
    XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
    LoessInterpolator loessInterpolator = new LoessInterpolator(
            0.75,//bandwidth,
            2//robustnessIters
    );

    for (PSM psm : this.IDsummary.PSMList.values()) {
        float ppm = InstrumentParameter.CalcSignedPPM(psm.ObserPrecursorMass, psm.NeutralPepMass);
        series.add(new XYDataItem(psm.RetentionTime, ppm));
    }
    double x[] = new double[IDsummary.PSMList.size()];
    double y[] = new double[x.length];
    double currentmin = 0f;
    for (int i = 0; i < series.getItemCount(); i++) {
        x[i] = (double) series.getX(i);
        if (x[i] <= currentmin) {
            x[i] = currentmin + 0.0001f;
        }
        currentmin = x[i];
        y[i] = (double) series.getY(i);
    }

    Masscalibrationfunction = loessInterpolator.interpolate(x, y);
    XYSeries smoothline = new XYSeries("Loess Regression");

    double xvalue = series.getMinX();

    while (xvalue < series.getMaxX()) {
        smoothline.add(xvalue, Masscalibrationfunction.value(xvalue));
        xvalue += 0.05d;
    }
    xySeriesCollection.addSeries(smoothline);
    xySeriesCollection.addSeries(series);

    JFreeChart chart = ChartFactory.createScatterPlot("Mass calibration", "RT", "Mass error (ppm)", xySeriesCollection,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyPlot = (XYPlot) chart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);

    XYItemRenderer renderer = xyPlot.getRenderer();
    renderer.setSeriesPaint(1, Color.blue);
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setSeriesShape(1, new Ellipse2D.Double(0, 0, 3, 3));
    renderer.setSeriesStroke(1, new BasicStroke(1.0f));
    xyPlot.setBackgroundPaint(Color.white);
    ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:52,代码来源:LCMSPeakMS1.java

示例7: padEdges

import org.apache.commons.math3.analysis.interpolation.LoessInterpolator; //导入依赖的package包/类
private TimesAndValues padEdges(double[] ts, double[] xs) {
  // Find step between times
  double step = Math.abs(ts[1] - ts[0]);
  // Times (assuming uniform
  double[] paddedTimes = new double[ts.length + 2];
  System.arraycopy(ts, 0, paddedTimes, 1, ts.length);
  paddedTimes[0] = paddedTimes[1] - step;
  paddedTimes[paddedTimes.length - 1] = paddedTimes[paddedTimes.length - 2] + step;

  // Series
  double[] paddedSeries = new double[xs.length + 2];
  System.arraycopy(xs, 0, paddedSeries, 1, xs.length);

  // Use Loess at ends to pad
  // n.b. For some reason, this can result in NaN values - perhaps similar to
  // https://issues.apache.org/jira/browse/MATH-296. If we see NaN, just "extrapolate" by copying
  // the end points :(

  double left = paddedSeries[1];
  double right = paddedSeries[paddedSeries.length - 2];

  double bandwidth = 0.3;
  if (ts.length * bandwidth > 2) {
    PolynomialSplineFunction loess = new LoessInterpolator(bandwidth, 2).interpolate(ts, xs);

    double loessLeft = loess.value(ts[0]);
    if (!Double.isNaN(loessLeft)) {
      left = loessLeft;
    }

    double loessRight = loess.value(ts[ts.length - 1]);
    if (!Double.isNaN(loessRight)) {
      right = loessRight;
    }
  }

  paddedSeries[0] = left;
  paddedSeries[paddedSeries.length - 1] = right;

  return new TimesAndValues(paddedTimes, paddedSeries);
}
 
开发者ID:brandtg,项目名称:stl-java,代码行数:42,代码来源:StlDecomposition.java

示例8: interpolate

import org.apache.commons.math3.analysis.interpolation.LoessInterpolator; //导入依赖的package包/类
private double[] interpolate(double[] xValues2, double[] yValues)
{
	// Smooth the values not in the current on-frames
	double[] newX = Arrays.copyOf(xValues, xValues.length);
	double[] newY = Arrays.copyOf(yValues, yValues.length);

	for (Spot s : onFrames)
	{
		newX[s.frame - 1] = -1;
	}
	int c = 0;
	for (int i = 0; i < newX.length; i++)
	{
		if (newX[i] == -1)
			continue;
		newX[c] = newX[i];
		newY[c] = newY[i];
		c++;
	}
	newX = Arrays.copyOf(newX, c);
	newY = Arrays.copyOf(newY, c);
	double smoothing = 0.25;
	try
	{
		smoothing = Double.parseDouble(smoothingTextField.getText());
		if (smoothing < 0.01 || smoothing > 0.9)
			smoothing = 0.25;
	}
	catch (NumberFormatException e)
	{
	}
	LoessInterpolator loess = new LoessInterpolator(smoothing, 1);
	PolynomialSplineFunction f = loess.interpolate(newX, newY);

	// Interpolate
	double[] plotSmooth = new double[xValues.length];
	for (int i = 0; i < xValues.length; i++)
	{
		// Cannot interpolate outside the bounds of the input data
		if (xValues[i] < newX[0])
			plotSmooth[i] = newY[0];
		else if (xValues[i] > newX[newX.length - 1])
			plotSmooth[i] = newY[newX.length - 1];
		else
			plotSmooth[i] = f.value(xValues[i]);
	}

	return plotSmooth;
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:50,代码来源:SpotAnalysis.java

示例9: displayPlot

import org.apache.commons.math3.analysis.interpolation.LoessInterpolator; //导入依赖的package包/类
private double[][] displayPlot(String title, String yLabel, double[] x, double[] y, double[] se,
		LoessInterpolator loess, int start, int end)
{
	// Extract non NaN numbers
	double[] newX = new double[x.length];
	double[] newY = new double[x.length];
	int c = 0;
	for (int i = 0; i < x.length; i++)
		if (!Double.isNaN(y[i]))
		{
			newX[c] = x[i];
			newY[c] = y[i];
			c++;
		}
	newX = Arrays.copyOf(newX, c);
	newY = Arrays.copyOf(newY, c);

	title = TITLE + " " + title;
	Plot2 plot = new Plot2(title, "z (nm)", yLabel);
	double[] limitsx = Maths.limits(x);
	double[] limitsy = new double[2];
	if (se != null)
	{
		if (c > 0)
		{
			limitsy = new double[] { newY[0] - se[0], newY[0] + se[0] };
			for (int i = 1; i < newY.length; i++)
			{
				limitsy[0] = Maths.min(limitsy[0], newY[i] - se[i]);
				limitsy[1] = Maths.max(limitsy[1], newY[i] + se[i]);
			}
		}
	}
	else
	{
		if (c > 0)
			limitsy = Maths.limits(newY);
	}
	double rangex = Math.max(0.05 * (limitsx[1] - limitsx[0]), 0.1);
	double rangey = Math.max(0.05 * (limitsy[1] - limitsy[0]), 0.1);
	plot.setLimits(limitsx[0] - rangex, limitsx[1] + rangex, limitsy[0] - rangey, limitsy[1] + rangey);

	if (loess == null)
	{
		addPoints(plot, Plot.LINE, newX, newY, x[start], x[end]);
	}
	else
	{
		addPoints(plot, Plot.DOT, newX, newY, x[start], x[end]);
		newY = loess.smooth(newX, newY);
		addPoints(plot, Plot.LINE, newX, newY, x[start], x[end]);
	}
	if (se != null)
	{
		plot.setColor(Color.magenta);
		for (int i = 0; i < x.length; i++)
		{
			if (!Double.isNaN(y[i]))
				plot.drawLine(x[i], y[i] - se[i], x[i], y[i] + se[i]);
		}

		// Draw the start and end lines for the valid range
		plot.setColor(Color.green);
		plot.drawLine(x[start], limitsy[0], x[start], limitsy[1]);
		plot.drawLine(x[end], limitsy[0], x[end], limitsy[1]);
	}
	else
	{
		// draw a line for the recall limit
		plot.setColor(Color.magenta);
		plot.drawLine(limitsx[0] - rangex, recallLimit, limitsx[1] + rangex, recallLimit);
	}
	PlotWindow pw = Utils.display(title, plot);
	if (Utils.isNewWindow())
		idList[idCount++] = pw.getImagePlus().getID();

	return new double[][] { newX, newY };
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:79,代码来源:PSFDrift.java

示例10: Smoother

import org.apache.commons.math3.analysis.interpolation.LoessInterpolator; //导入依赖的package包/类
public Smoother()
{
	if (settings.getSmoothing() != 0)
		loess = new LoessInterpolator(settings.getSmoothing(), 1);
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:6,代码来源:PSFCreator.java

示例11: loessSmooth

import org.apache.commons.math3.analysis.interpolation.LoessInterpolator; //导入依赖的package包/类
/**
 * Performs weighted Loess smoothing on a series.
 *
 * <p>
 *   Does not assume contiguous time.
 * </p>
 *
 * @param times
 *  The times.
 * @param series
 *  The time series data.
 * @param bandwidth
 *  The amount of neighbor points to consider for each point in Loess.
 * @param weights
 *  The weights to use for smoothing, if null, equal weights are assumed.
 * @return
 *  Loess-smoothed series.
 */
private double[] loessSmooth(double[] times,
                             double[] series,
                             double bandwidth,
                             double[] weights) {
  if (weights == null) {
    return new LoessInterpolator(
        bandwidth,
        config.getLoessRobustnessIterations()).smooth(times, series);
  } else {
    return new LoessInterpolator(
        bandwidth,
        config.getLoessRobustnessIterations()).smooth(times, series, weights);
  }
}
 
开发者ID:brandtg,项目名称:stl-java,代码行数:33,代码来源:StlDecomposition.java

示例12: loessSmooth

import org.apache.commons.math3.analysis.interpolation.LoessInterpolator; //导入依赖的package包/类
/**
 * @param times
 * @param series
 * @param bandwidth
 * @param weights
 *  The weights to use for smoothing, if null, equal weights are assumed
 * @return
 *  Smoothed series
 */
private double[] loessSmooth(double[] times, double[] series, double bandwidth, double[] weights) {
  if (weights == null) {
    return new LoessInterpolator(bandwidth, LOESS_ROBUSTNESS_ITERATIONS).smooth(times, series);
  } else {
    return new LoessInterpolator(bandwidth, LOESS_ROBUSTNESS_ITERATIONS).smooth(times, series, weights);
  }
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:17,代码来源:STLDecomposition.java


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