项目地址: GitHub - signaflo/java-timeseries: Time series analysis in Java
maven:
<dependency>
<groupId>com.github.signaflo</groupId>
<artifactId>timeseries</artifactId>
<version>0.4</version>
</dependency>
测试代码:
import com.github.signaflo.timeseries.Ts;
import com.github.signaflo.timeseries.forecast.Forecast;
import com.github.signaflo.timeseries.model.arima.ArimaCoefficients;
import com.github.signaflo.timeseries.TimeSeries;
import com.github.signaflo.timeseries.model.arima.Arima;
public class TimeSeriesAnalysis {
public static void main(String[] args) throws Exception {
TimeSeries timeSeries = Ts.newMonthlySeries(2000, 1,
new double[]{0,0,0,0,0,0,0,100,0,0,0,0,0,0,200,0,0,0,0,0,0,0,0,0,0,100,0,0,0,0,0,0,300,0,0,0});
Arima.FittingStrategy fittingStrategy = Arima.FittingStrategy.CSSML;
ArimaCoefficients coefficients = ArimaCoefficients.builder()
.setMACoeffs(-0.6760904)
.setSeasonalMACoeffs(-0.5718134)
.setDifferences(1)
.setSeasonalDifferences(1)
.setSeasonalFrequency(12)
.build();
Arima model = Arima.model(timeSeries, coefficients, fittingStrategy);
Forecast forecast = model.forecast(24);
double[] lower = forecast.lowerPredictionInterval().asArray();
double[] upper = forecast.upperPredictionInterval().asArray();
double[] pointEstimates = forecast.pointEstimates().asArray();
}
}
源代码的test里面有作者写的测试代码: