class StationaryVarianceDecomposition {

    public boolean process(final TsData O, final TsData T, final TsData S, final TsData I, final TsData Cal, final TsData others, final boolean mul) {
        if (O == null) {
            return false;
        }
        TsData stOc, stCc, Sc, Ic, Calc, Pc;
        if (mul) {
            // use logs
            stOc = O.log();
            stCc = T != null ? T.log() : null;
            Sc = S != null ? S.log() : null;
            Ic = I != null ? I.log() : null;
            Calc = Cal != null ? Cal.log() : null;
            Pc = others != null ? others.log() : null;

        } else {
            stOc = O;
            stCc = T;
            Sc = S;
            Ic = I;
            Calc = Cal;
            Pc = others;
        }

        TsData lt = trendComputer.calcLongTermTrend(stCc);
        stCc = TsData.subtract(stCc, lt);
        stOc = TsData.subtract(stOc, lt);

        //
        DescriptiveStatistics stats = new DescriptiveStatistics(stOc);
        double varO = stats.getVar();

        if (stCc != null) {
            stats = new DescriptiveStatistics(stCc);
            varC = stats.getVar();
        } else {
            varC = 0;
        }

        if (Sc != null) {
            stats = new DescriptiveStatistics(Sc);
            varS = stats.getVar();
        } else {
            varS = 0;
        }
        if (Ic != null) {
            stats = new DescriptiveStatistics(Ic);
            varI = stats.getVar();
        } else {
            varI = 0;
        }
        if (Calc != null) {
            stats = new DescriptiveStatistics(Calc);
            varCal = stats.getVar();
        } else {
            varCal = 0;
        }
        if (Pc != null) {
            stats = new DescriptiveStatistics(Pc);
            varP = stats.getVar();
        } else {
            varP = 0;
        }

        varP /= varO;
        varCal /= varO;
        varS /= varO;
        varC /= varO;
        varI /= varO;

        return true;
    }

    public  StationaryVarianceDecomposition();
    public  StationaryVarianceDecomposition(final ILongTermTrendComputer trendComputer);

}