class SeasonalOutlier extends AbstractOutlierVariable {

    @Override
    public void data(TsPeriod start, DataBlock data) {
        TsPeriod pstart=new TsPeriod(start.getFrequency(), position);
        int pos = pstart.minus(start);
        data.set(0);
        int freq = start.getFrequency().intValue();

        double z = -1.0 / (freq - 1);
        int xpos;
        int len = data.getLength();
        if (zeroEnded) {
            int j = 1;
            if (pos < 0) {
                return;
            } else if (pos > len) {
                int n = pos - len;
                j = 1 + n % freq;
                xpos = len;
            } else {
                xpos = pos;
            }
            do {
                for (; j < freq && xpos > 0; ++j) {
                    data.set(--xpos, z);
                }
                if (xpos > 0) {
                    data.set(--xpos, 1);
                } else {
                    break;
                }
                j = 1;
            } while (true);
        } else {
            if (pos < 0) {
                xpos = pos % freq;
            } else {
                xpos = pos;
            }
            if (xpos < 0) {
                int max=Math.min(len, freq + xpos);
                for (int j = 0; j < max; ++j) {
                    data.set(j, z);
                }
                xpos += freq;

            }

            for (int i = xpos; i < len;) {
                data.set(i++, 1);
                for (int j = 1; j < freq && i < len; ++i, ++j) {
                    data.set(i, z);
                }
            }
        }
    }

    public  SeasonalOutlier(Day pos);

}