A Java implementation of STL: A Seasonal-Trend Decomposition Procedure Based on Loess
To include this library in your project, add the following dependency
<dependency>
<groupId>com.github.brandtg</groupId>
<artifactId>stl-java</artifactId>
<version>0.1.1</version>
</dependency>
Assuming we have a time series of monthly data that is periodic with respect to years
double[] ts;
double[] ys; // ys.length == ts.lengthWe can run STL as follows
StlResult stl = new StlDecomposition(12 /* months in a year */).decompose(ts, ys);And optionally plot the results (n.b. StlPlotter is in test scope)
StlPlotter.plotOnScreen(stl, "Seasonal Decomposition");