DiffConstant extends AbstractSingleTsVariable { @Override public void data(TsPeriod start, DataBlock data) { TsPeriod s = new TsPeriod(start.getFrequency(), m_start); int del = start.minus(s); if (del < 0) { throw new TsException("Unexpected DConstant"); } double[] g = generateMeanEffect(m_ur, del + data.getLength()); data.copyFrom(g, del); } DiffConstant(BackFilter ur, Day start); static double[] generateMeanEffect(BackFilter ur, int n); @Override void data(TsPeriod start, DataBlock data); @Override String getDescription(TsFrequency context); @Override boolean isSignificant(TsDomain domain); @Override String getName();  }
@Test public void testLinear() { Day start=Day.toDay(); TsDomain domain=new TsDomain(new TsPeriod(TsFrequency.Monthly, start), 120); DataBlock data0=new DataBlock(domain.getLength()); DataBlock data1=new DataBlock(domain.getLength()); DiffConstant dc=new DiffConstant(new BackFilter(UnitRoots.D1), start); LinearTrend t=new LinearTrend(start); dc.data(domain.getStart(), data0); t.data(domain.getStart(), data1); assertTrue(data0.distance(data1)<1e-9); }