All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jdplus.stl.base.api.IStlSpec Maven / Gradle / Ivy

/*
 * Copyright 2022 National Bank of Belgium
 *
 * Licensed under the EUPL, Version 1.2 or – as soon they will be approved 
 * by the European Commission - subsequent versions of the EUPL (the "Licence");
 * You may not use this work except in compliance with the Licence.
 * You may obtain a copy of the Licence at:
 *
 * https://joinup.ec.europa.eu/software/page/eupl
 *
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the Licence is distributed on an "AS IS" basis,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Licence for the specific language governing permissions and 
 * limitations under the Licence.
 */
package jdplus.stl.base.api;

import jdplus.toolkit.base.api.data.WeightFunction;
import jdplus.toolkit.base.api.processing.AlgorithmDescriptor;
import jdplus.toolkit.base.api.processing.ProcSpecification;
import java.util.List;

/**
 *
 * @author Jean Palate 
 */
@lombok.Value
@lombok.Builder(toBuilder = true, builderClassName = "Builder")
public class IStlSpec implements ProcSpecification {

    @lombok.Value
    public static class PeriodSpec {
        
        public static PeriodSpec createDefault(int period, boolean nojump){
            return new PeriodSpec(LoessSpec.defaultTrend(period, nojump), SeasonalSpec.createDefault(period, nojump));
        }

        private LoessSpec trendSpec;
        private SeasonalSpec seasonalSpec;

    }

    private boolean multiplicative;
    @lombok.Singular
    private List periodSpecs;
    private int innerLoopsCount, outerLoopsCount;
    private double robustWeightThreshold;

    private WeightFunction robustWeightFunction;

    public static final double RWTHRESHOLD = 0.001;
    public static final WeightFunction RWFUNCTION = WeightFunction.BIWEIGHT;

    public static Builder robustBuilder() {
        return new Builder()
                .innerLoopsCount(1)
                .outerLoopsCount(15)
                .robustWeightFunction(RWFUNCTION)
                .robustWeightThreshold(RWTHRESHOLD);
    }

    public static Builder builder() {
        return new Builder()
                .innerLoopsCount(2)
                .outerLoopsCount(0)
                .robustWeightFunction(RWFUNCTION)
                .robustWeightThreshold(RWTHRESHOLD);
    }

    public static final IStlSpec DEFAULT = createDefault(true, 7);

    /**
     * Creates a default specification for a series that has a given periodicity
     *
     * @param robust True for robust filtering, false otherwise.
     * @param periods
     * @return
     */
    public static IStlSpec createDefault(boolean robust, int... periods) {
        Builder builder;
        if (robust) {
            builder = robustBuilder();
        } else {
            builder = builder();
        }
        for (int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy