private XYIntervalSeries computeAcceptableDeviationData(double lowerBound, double upperBound) {
   final XYSeries identity =
       DatasetUtilities.sampleFunction2DToSeries(x -> x, lowerBound, upperBound, 100, "1:1 line");
   final XYIntervalSeries xyIntervalSeries = new XYIntervalSeries(identity.getKey());
   for (int i = 0; i < identity.getItemCount(); i++) {
     XYDataItem item = identity.getDataItem(i);
     final double x = item.getXValue();
     final double y = item.getYValue();
     if (scatterPlotModel.showAcceptableDeviation) {
       final double acceptableDeviation = scatterPlotModel.acceptableDeviationInterval;
       final double xOff = acceptableDeviation * x / 100;
       final double yOff = acceptableDeviation * y / 100;
       xyIntervalSeries.add(x, x - xOff, x + xOff, y, y - yOff, y + yOff);
     } else {
       xyIntervalSeries.add(x, x, x, y, y, y);
     }
   }
   return xyIntervalSeries;
 }
  public void addData(DataChannel c) {
    try {
      int col = 1;
      addLabel(lineOffset, 0, c.toString() + " Time (ms)");
      addLabel(lineOffset + 1, 0, c.toString() + " Value");

      for (Object o : c.getSeries().getItems()) {
        XYDataItem i = (XYDataItem) o;
        addNumber(lineOffset, col, i.getXValue());
        addNumber(lineOffset + 1, col, i.getYValue());
        col++;
      }
    } catch (RowsExceededException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (WriteException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    lineOffset += 2;
  }
 private XYIntervalSeries computeRegressionData(double xStart, double xEnd) {
   if (scatterpointsDataset.getItemCount(0) > 1) {
     final double[] coefficients = Regression.getOLSRegression(scatterpointsDataset, 0);
     final Function2D curve = new LineFunction2D(coefficients[0], coefficients[1]);
     final XYSeries regressionData =
         DatasetUtilities.sampleFunction2DToSeries(curve, xStart, xEnd, 100, "regression line");
     final XYIntervalSeries xyIntervalRegression = new XYIntervalSeries(regressionData.getKey());
     for (int i = 0; i < regressionData.getItemCount(); i++) {
       XYDataItem item = regressionData.getDataItem(i);
       final double x = item.getXValue();
       final double y = item.getYValue();
       xyIntervalRegression.add(x, x, x, y, y, y);
     }
     return xyIntervalRegression;
   } else {
     JOptionPane.showMessageDialog(
         this,
         "Unable to compute regression line.\n"
             + "At least 2 values are needed to compute regression coefficients.");
     return null;
   }
 }