/** Checks the results of an OLS regression on sample dataset 1. */ @Test public void testOLSRegression1a() { double[][] data = createSampleData1(); double[] result1 = Regression.getOLSRegression(data); assertEquals(.25680930, result1[0], 0.0000001); assertEquals(0.72792106, result1[1], 0.0000001); }

/** Checks the results of a power regression on sample dataset 2. */ @Test public void testPowerRegression2a() { double[][] data = createSampleData2(); double[] result = Regression.getPowerRegression(data); assertEquals(106.1241681, result[0], 0.0000001); assertEquals(-0.8466615, result[1], 0.0000001); }

public void specific(ObjectContainer con, int step) { super.specific(con, step); TEntry entry = new TEntry().lastElement(); Stack stack = new Stack(); if (step > 0) { stack.addElement(entry.key); ObjectSet set = con.queryByExample(stack); if (set.size() != step) { Regression.addError("Stack member query not found"); } else { Stack res = (Stack) set.next(); if (!(stack.pop().equals(new TEntry().lastElement().key))) { Regression.addError("Stack order changed."); } } } }

/** Checks the results of a power regression on sample dataset 1. */ @Test public void testPowerRegression1a() { double[][] data = createSampleData1(); double[] result = Regression.getPowerRegression(data); assertEquals(0.91045813, result[0], 0.0000001); assertEquals(0.88918346, result[1], 0.0000001); }

/** Checks the results of an OLS regression on sample dataset 2. */ @Test public void testOLSRegression2a() { double[][] data = createSampleData2(); double[] result = Regression.getOLSRegression(data); assertEquals(53.9729697, result[0], 0.0000001); assertEquals(-4.1823030, result[1], 0.0000001); }

/** * Checks the results of a power regression on sample dataset 1 AFTER converting it to an * XYSeries. */ @Test public void testPowerRegression1b() { double[][] data = createSampleData1(); XYSeries series = new XYSeries("Test"); for (int i = 0; i < 11; i++) { series.add(data[i][0], data[i][1]); } XYDataset ds = new XYSeriesCollection(series); double[] result = Regression.getPowerRegression(ds, 0); assertEquals(0.91045813, result[0], 0.0000001); assertEquals(0.88918346, result[1], 0.0000001); }

/** * Checks the results of an OLS regression on sample dataset 1 AFTER converting it to an XYSeries. */ @Test public void testOLSRegression1b() { double[][] data = createSampleData1(); XYSeries series = new XYSeries("Test"); for (int i = 0; i < 11; i++) { series.add(data[i][0], data[i][1]); } XYDataset ds = new XYSeriesCollection(series); double[] result2 = Regression.getOLSRegression(ds, 0); assertEquals(.25680930, result2[0], 0.0000001); assertEquals(0.72792106, result2[1], 0.0000001); }

/** * Checks the results of a power regression on sample dataset 2 AFTER converting it to an * XYSeries. */ @Test public void testPowerRegression2b() { double[][] data = createSampleData2(); XYSeries series = new XYSeries("Test"); for (int i = 0; i < 10; i++) { series.add(data[i][0], data[i][1]); } XYDataset ds = new XYSeriesCollection(series); double[] result = Regression.getPowerRegression(ds, 0); assertEquals(106.1241681, result[0], 0.0000001); assertEquals(-0.8466615, result[1], 0.0000001); }

/** * Checks the results of an OLS regression on sample dataset 2 AFTER converting it to an XYSeries. */ @Test public void testOLSRegression2b() { double[][] data = createSampleData2(); XYSeries series = new XYSeries("Test"); for (int i = 0; i < 10; i++) { series.add(data[i][0], data[i][1]); } XYDataset ds = new XYSeriesCollection(series); double[] result = Regression.getOLSRegression(ds, 0); assertEquals(53.9729697, result[0], 0.0000001); assertEquals(-4.1823030, result[1], 0.0000001); }

public static void main(String[] args) { List<Double> signal = Arrays.asList(0., 1., 1., 3., 5., 4., 6.); Regression.viewGraph = true; Regression.getLinearRegression(signal); }

public static void testNull() { InstanceAttributes inc = new InstanceAttributes(); Regression.verify(inc.aObject == null); }

private static void test1() { InstanceAttributes inc = new InstanceAttributes(); Regression.verify(inc.aValue == 47); Regression.verify(inc.aEnabled); }