Find the 3-period simple moving average of [10, 12, 14, 13, 15].
Show the steps
- Simple moving average\mathrm{SMA}_t = \frac{1}{k}\sum_{i=0}^{k-1} x_{t-i}with
x = [10, 12, 14, 13, 15], k = 3→sma = [12, 13, 14], last = 14, count = 3
Moving averages, exponential smoothing, autocorrelation, ARIMA basics, stationarity tests, change points, forecasting accuracy and Kalman filtering.
Time Series (time-series-ai999x) is an offline Python package for time series. It covers moving averages, exponential smoothing, autocorrelation, ARIMA basics, stationarity tests, change points, forecasting accuracy and Kalman filtering.
It has 77 capabilities — 77 computational procedures — in 14 topics, the largest being ARMA theory, Exponential smoothing, ARIMA models, Forecast accuracy, Kalman filtering and Trend fitting. Ask a question in words with ask(), or call a capability by name with typed inputs with solve(). Every answer carries its value and unit, the steps that produced it and the formula in LaTeX.
When a question is not determined — a value is missing, an input is out of range, or the request is outside the package — it says so and names what it needs, instead of guessing. It runs on an ordinary CPU without a network connection (Python >=3.10), and the same question always gets the same answer.
pip install time-series-ai999x hf download AI999X/time-series-ai999x --local-dir time-series-ai999x
Each question below was put to time-series-ai999x and the answer shown is the one it returned, with the steps it took.
Find the 3-period simple moving average of [10, 12, 14, 13, 15].
x = [10, 12, 14, 13, 15], k = 3sma = [12, 13, 14], last = 14, count = 3Apply Holt's linear trend method with alpha = 0.5 and beta = 0.3 to [10, 12, 15, 16, 19, 21].
x = [10, 12, 15, 16, 19, 21], alpha = 0.5, beta = 0.3forecast = 22.65328591, level = 20.65533969, trend = 1.997946219, sse = 7.492761855Perform the Ljung-Box test with 3 lags on [4, 6, 5, 8, 7, 9, 8, 10, 9, 12, 11, 13].
x = [4, 6, 5, 8, 7, 9, 8, 10, 9, 12, 11, 13], h = 3q = 9.319101598, p_value = 0.0253357685, df = 3Find the MAPE for actual values [10, 12, 14, 13] and forecasts [11, 12, 13, 15].
y = [10, 12, 14, 13], f = [11, 12, 13, 15]mape = 8.131868132, n = 4m.solve("kalman_filter_local_level", x="10.4, 11.1, 10.7, 11.9, 12.3", q=0.5, r=2, m0=10, p0=5) x = [10.4, 11.1, 10.7, 11.9, 12.3], q = 0.5, r = 2, m0 = 10, p0 = 5estimate = 11.62410315, variance = 0.7906396594, gain = 0.3953198297, estimates = [10.29333333, 10.69327731, 10.69614922, 11.18222422, 11.62410315], log_likelihood = -8.617118062Forecast 3 steps ahead for an AR(1) process with mean 50, phi = 0.7 and last value 58.
x = 58, phi = 0.7, mu = 50, h = 3forecast = 52.744Find the mean and variance of the AR(1) process with constant 2, phi = 0.6 and sigma2 = 4.
phi = 0.6, sigma2 = 4, c = 2mean = 5, variance = 6.25, acf_k = 0.6, acov_k = 3.75Find the change point in the mean of [5, 6, 5, 7, 6, 12, 13, 12, 14].
x = [5, 6, 5, 7, 6, 12, 13, 12, 14]change_index = 5, mean_before = 5.8, mean_after = 12.75, cost = 5.55, reduction = 107.3388889Every snippet was run as shown; the output under it is what it printed.
import time_series_ai999x as m
a = m.ask("Find the 3-period simple moving average of [10, 12, 14, 13, 15].")
print(a.outcome)
print(a.values)
for step in a.steps:
print(step["name"])SOLVED
{'sma': [12.0, 13.0, 14.0], 'last': 14.0, 'count': 3}
Simple moving average
import time_series_ai999x as m
a = m.solve("kalman_filter_local_level", x="10.4, 11.1, 10.7, 11.9, 12.3", q=0.5, r=2, m0=10, p0=5)
print(a.outcome)
print(a.values)SOLVED
{'estimate': 11.624103148133084, 'variance': 0.7906396594267739, 'gain': 0.395319829713387, 'estimates': [10.293333333333333, 10.693277310924369, 10.696149217809866, 11.182224215246636, 11.624103148133084], 'log_likelihood': -8.6171180618}
import time_series_ai999x as m
# an input is missing: the answer says what it needs instead of guessing
a = m.solve("kalman_filter_local_level")
print(a.outcome)
print(a.message)NEEDS_INPUT
kalman_filter_local_level needs x, q, r, m0, p0 (the measurements, oldest first; process noise variance; measurement noise variance; initial state estimate; initial variance). Example: solve('kalman_filter_local_level', x='10.4, 11.1, 10.7, 11.9, 12.3', q=0.5, r=2, m0=10, p0=5).
time-series-ai999x "Find the 3-period simple moving average of [10, 12, 14, 13, 15]."
sma = [12.0, 13.0, 14.0], last = 14, count = 3 1. Simple moving average: mean of each window of k consecutive values with x = [10, 12, 14, 13, 15], k = 3 -> sma = [12.0, 13.0, 14.0], last = 14, count = 3 Assumptions: 1 <= k <= n …
Every value in these figures was computed by the package, each point a run of solve(); in a notebook, plot() and plot_relation() draw a capability's curves the same way.
12 of its 77 formulas; every one is in the capability browser below.
Search by name, formula, input or topic. Each capability opens to show what it takes, what it returns, when it applies, and a question it answered.
ar1_forecastThe h-step forecast mu + phi^h (x_n - mu) of a stationary AR(1) with mean mu, and (when the innovation variance is given) its forecast error variance and 95 % prediction interval.
x the last observed value x_nphi AR coefficient, |phi| < 1mu the process meanh forecast horizon (default 1) integer optionalsigma2 innovation variance (optional, for the interval) optionalforecast mu + phi^h (x_n - mu)variance sigma^2 (1 - phi^(2h)) / (1 - phi^2)lower lower 95 % limitupper upper 95 % limitar_least_squaresFit x_t = c + phi_1 x_{t-1} + ... + phi_p x_{t-p} + e_t by ordinary least squares on t = p+1..n; the innovation variance is the residual sum of squares divided by n - p.
x the series, oldest first vectorp the AR order p integerconst the constant cphi the coefficients phi_1..phi_pphi1 phi_1sigma2 residual sum of squares / (n - p)ar_yule_walkerEstimate the coefficients phi_1..phi_p and the innovation variance of an AR(p) model from data by the Yule-Walker equations (sample autocovariances divided by n, mean removed).
x the series, oldest first vectorp the AR order p integerphi the coefficients phi_1..phi_pphi1 phi_1sigma2 the innovation variance c_0 (1 - sum phi_j r_j)ar_forecasth-step forecasts of x_t = c + phi_1 x_{t-1} + ... + phi_p x_{t-p} + e_t from the last p observations (future shocks set to 0).
x the series, oldest first (at least p values) vectorphi the coefficients phi_1..phi_p vectorc the constant c (default 0) optionalh forecast horizon (default 1) integer optionalforecasts the forecasts for steps 1..hforecast the h-step forecastarima_p10_forecasth-step forecasts of an ARIMA(p,1,0) model without constant: the differences follow a stationary AR(p); forecast differences are accumulated onto the last observation.
x the series, oldest first (at least p + 2 values) vectorphi AR coefficients of the differences vectorh forecast horizon (default 1) integer optionalforecasts the forecasts for steps 1..hforecast the h-step forecastpartial_autocorrelations_from_autocorrelationsThe partial autocorrelations phi_11..phi_pp implied by autocorrelations rho_1..rho_p (Durbin-Levinson).
rho the autocorrelations rho_1..rho_p vectorpacf partial autocorrelations at lags 1..plast phi_ppyule_walker_from_autocorrelationsSolve the Yule-Walker equations for the AR(p) coefficients given the autocorrelations rho_1..rho_p, and the ratio of the innovation variance to the process variance.
rho the autocorrelations rho_1..rho_p vectorphi the AR coefficients phi_1..phi_pphi1 phi_1variance_ratio sigma^2 / gamma_0 = 1 - sum phi_j rho_jforecast_error_varianceThe variance (and standard deviation) of the h-step-ahead forecast error of a stationary ARMA(p,q) with known parameters: sigma^2 (psi_0^2 + ... + psi_{h-1}^2).
phi AR coefficients ([0] for none) vectortheta MA coefficients ([0] for none) vectorsigma2 innovation variance sigma^2h forecast horizon integervariance forecast error variancesd forecast error standard deviationma2_invertibilityWhether x_t = e_t + theta1 e_{t-1} + theta2 e_{t-2} is invertible: the largest modulus of the inverse roots (roots of z^2 + theta1 z + theta2) must be below 1.
theta1 theta_1theta2 theta_2invertible yes or nomax_modulus largest modulus of the inverse rootsroots real or complexar1_propertiesFor a stationary AR(1) x_t = c + phi x_{t-1} + e_t: the mean c/(1 - phi), the variance sigma^2/(1 - phi^2), and the lag-k autocorrelation phi^k and autocovariance.
phi AR coefficient, |phi| < 1sigma2 innovation variance sigma^2k the lag k (default 1) integer optionalc the constant c (default 0) optionalmean c / (1 - phi)variance sigma^2 / (1 - phi^2)acf_k phi^kacov_k variance x phi^kpi_weightsThe weights pi_1..pi_K of x_t = sum_{j>=1} pi_j x_{t-j} + e_t for an invertible ARMA(p,q).
phi AR coefficients ([0] for none) vectortheta MA coefficients ([0] for none), invertible vectorK number of weights (default 10) integer optionalpi pi_1..pi_Kpi1 pi_1 = phi_1 + theta_1psi_weightsThe weights psi_1..psi_K of x_t = sum_{j>=0} psi_j e_{t-j} (psi_0 = 1) for a stationary ARMA(p,q); they are also the impulse response.
phi AR coefficients ([0] for none) vectortheta MA coefficients ([0] for none) vectorK number of weights (default 10) integer optionalpsi psi_1..psi_Kpsi1 psi_1 = phi_1 + theta_1ar2_stationarityWhether x_t = phi1 x_{t-1} + phi2 x_{t-2} + e_t is stationary: the largest modulus of the inverse characteristic roots (roots of z^2 - phi1 z - phi2) must be below 1.
phi1 phi_1phi2 phi_2stationary yes or nomax_modulus largest modulus of the inverse rootsroots real or complexar2_theoretical_acfThe autocorrelations rho_1..rho_K of a stationary AR(2) process from the Yule-Walker recursion rho_1 = phi1/(1 - phi2), rho_k = phi1 rho_{k-1} + phi2 rho_{k-2}.
phi1 phi_1phi2 phi_2K number of lags (default 5) integer optionalacf rho_1..rho_Krho1 rho_1arma11_theoretical_acfThe autocorrelations rho_1..rho_K of x_t = phi x_{t-1} + e_t + theta e_{t-1}.
phi AR coefficient, |phi| < 1theta MA coefficient (plus-sign convention)K number of lags (default 5) integer optionalacf rho_1..rho_Krho1 rho_1arma_theoretical_acfThe autocorrelations rho_1..rho_K of a stationary ARMA(p,q) process x_t = sum phi_i x_{t-i} + e_t + sum theta_j e_{t-j}.
phi AR coefficients phi_1..phi_p (stationary; [0] for none) vectortheta MA coefficients theta_1..theta_q ([0] for none) vectorK number of lags (default 5) integer optionalacf rho_1..rho_Krho1 rho_1ma_theoretical_acfThe autocorrelations rho_1..rho_K of x_t = e_t + theta_1 e_{t-1} + ... + theta_q e_{t-q}; they vanish beyond lag q.
theta the MA coefficients theta_1..theta_q (plus-sign convention) vectorK number of lags (default q + 1) integer optionalacf rho_1..rho_Krho1 rho_1arma_theoretical_pacfThe partial autocorrelations phi_11..phi_KK of a stationary ARMA(p,q) process (Durbin-Levinson on its exact autocorrelations).
phi AR coefficients ([0] for none) vectortheta MA coefficients ([0] for none) vectorK number of lags (default 5) integer optionalpacf phi_11..phi_KKpacf1 phi_11 = rho_1ma1_theoretical_pacfThe partial autocorrelations phi_11..phi_KK of x_t = e_t + theta e_{t-1} (they decay, never cut off).
theta MA coefficient, |theta| != 1K number of lags (default 5) integer optionalpacf phi_11..phi_KKpacf1 phi_11 = theta/(1 + theta^2)arma_varianceThe process variance gamma_0 and lag-1 autocovariance gamma_1 of a stationary ARMA(p,q) process with innovation variance sigma^2.
phi AR coefficients ([0] for none) vectortheta MA coefficients ([0] for none) vectorsigma2 innovation (white-noise) variance sigma^2gamma0 the variance of the processgamma1 the lag-1 autocovariancebartlett_standard_errorBartlett's standard error of r_k under the hypothesis that the autocorrelations beyond lag k - 1 are zero, and the 95 % band half-width used in correlograms.
x the series, oldest first vectork the lag k integerse Bartlett standard error of r_khalf_width_95 1.959964 x seacf the sample autocorrelation r_kbox_pierce_testThe Box-Pierce test portmanteau statistic for no autocorrelation up to lag h and its chi-square p-value (h - model_df degrees of freedom; autocorrelations with denominator n).
x the series (or residuals), oldest first vectorh the number of lags h integermodel_df parameters of a fitted ARMA model subtracted from the degrees of freedom (default 0) integer optionalq the test statisticp_value upper-tail chi-square probability, df = h - model_dfdf degrees of freedom h - model_dfljung_box_testThe Ljung-Box test portmanteau statistic for no autocorrelation up to lag h and its chi-square p-value (h - model_df degrees of freedom; autocorrelations with denominator n).
x the series (or residuals), oldest first vectorh the number of lags h integermodel_df parameters of a fitted ARMA model subtracted from the degrees of freedom (default 0) integer optionalq the test statisticp_value upper-tail chi-square probability, df = h - model_dfdf degrees of freedom h - model_dfsample_autocorrelationThe sample autocorrelation r_k of a series (and r_1..r_k), with autocovariances divided by n and taken about the sample mean.
x the series, oldest first vectork the lag k (1 <= k <= n - 1) integeracf the sample autocorrelation r_kacf_list r_1, ..., r_ksample_autocovarianceThe sample autocovariance c_k of a series, divided by n and taken about the sample mean.
x the series, oldest first vectork the lag k (0 <= k <= n - 1) integeracov the sample autocovariance c_kgamma0 c_0, the variance divided by nsample_partial_autocorrelationThe sample partial autocorrelation phi_kk of a series (and phi_11..phi_kk) by the Durbin-Levinson recursion on the sample autocorrelations (denominator n).
x the series, oldest first vectork the lag k (1 <= k < n/2) integerpacf the partial autocorrelation at lag kpacf_list partial autocorrelations at lags 1..kcusum_change_pointThe change point estimated by the cumulative sum of deviations from the overall mean, S_k = sum_{t<=k}(x_t - xbar): the k with the largest |S_k|.
x the series, oldest first vectorchange_index k with the largest |S_k| (first segment x_1..x_k)max_cusum max |S_k|mean_before mean of x_1..x_kmean_after mean of x_{k+1}..x_npenalised_change_pointsThe segmentation minimising the within-segment sum of squares plus a penalty per change point (optimal partitioning, as found by PELT): the number and positions of the changes in the mean.
x the series, oldest first vectorpenalty penalty per change point (> 0)n_changes number of change pointschange_indices ends of all segments but the lastcost within-segment sum of squares of the chosen segmentationchange_point_mean_shiftThe single change point that minimises the total within-segment sum of squares (a shift in the mean), with the means before and after.
x the series, oldest first vectormin_size minimum segment length (default 2) integer optionalchange_index k: the first segment is x_1..x_kmean_before mean of x_1..x_kmean_after mean of x_{k+1}..x_ncost total within-segment sum of squaresreduction sum of squares removed by the splittabular_cusumThe upper and lower tabular CUSUM statistics for a target mean mu0 with allowance k, and the first time either exceeds the decision interval h.
x the observations, oldest first vectormu0 target (in-control) meank allowance (reference value) k >= 0h decision interval h > 0c_plus final upper CUSUM C+_nc_minus final lower CUSUM C-_nalarm_index first t with C+_t > h or C-_t > h (0 if none)side upper, lower, both or nonetwo_change_pointsThe two change points that minimise the total within-segment sum of squares (three mean levels), found by exhaustive dynamic search.
x the series, oldest first vectormin_size minimum segment length (default 2) integer optionalchange_1 end of the first segmentchange_2 end of the second segmentmeans the three segment meanscost total within-segment sum of squaresseasonal_indices_additiveSeasonal indices of classical additive decomposition: detrend by the centred moving average, average each season, normalise the indices to sum to 0.
x the series, oldest first (at least two full seasons) vectorm season length integerindices the m seasonal indices, starting with the season of x_1first the index of the first observation's seasonseasonal_indices_multiplicativeSeasonal indices of classical multiplicative decomposition: detrend by the centred moving average, average each season, normalise the indices to average 1.
x the series, oldest first (at least two full seasons) vectorm season length integerindices the m seasonal indices, starting with the season of x_1first the index of the first observation's seasonseasonally_adjusted_additiveThe seasonally adjusted series of classical additive decomposition: each value minus its seasonal index.
x the series, oldest first (at least two full seasons) vectorm season length integeradjusted the seasonally adjusted serieslast the latest adjusted valueseasonally_adjusted_multiplicativeThe seasonally adjusted series of classical multiplicative decomposition: each value divided by its seasonal index.
x the series, oldest first (at least two full seasons) vectorm season length integeradjusted the seasonally adjusted serieslast the latest adjusted valuecross_correlation_best_lagThe lag k in -K..K with the largest |r_xy(k)|, r_xy(k) = corr(x_{t+k}, y_t): a positive k means y leads x by k periods.
x the first series vectory the second series (same length) vectorK the largest lag searched integerlag the lag with the largest absolute cross-correlationccf r_xy at that lagcross_correlation_at_lagThe sample cross-correlation r_xy(k) = corr(x_{t+k}, y_t) of two equally long series (y leads x by k).
x the first series vectory the second series (same length) vectork the lag k >= 0 integerccf the cross-correlation r_xy(k)ses_best_alphaAmong candidate smoothing constants, the one whose simple exponential smoothing (l_0 = x_1) gives the smallest sum of squared one-step errors, with that SSE and its forecast.
x the series, oldest first vectoralphas candidate smoothing constants, each in (0, 1] vectoralpha the best smoothing constantsse its sum of squared one-step errorsforecast its forecast of the next periodholt_damped_trendHolt's method with a damped trend (damping parameter phi): the h-step forecast is l_n + (phi + phi^2 + ... + phi^h) b_n. Initial states l_0 = x_1, b_0 = x_2 - x_1 unless stated.
x the series, oldest first vectoralpha level smoothing constant, 0 < alpha <= 1beta trend smoothing constant, 0 < beta <= 1 (b_t = beta (l_t - l_{t-1}) + (1 - beta) b_{t-1})phi damping parameter, 0 < phi <= 1l0 initial level l_0 (default x_1) optionalb0 initial trend b_0 (default x_2 - x_1) optionalh forecast horizon in periods (default 1) integer optionalforecast the h-step-ahead forecastlevel the final level l_ntrend the final trend b_nsse sum of squared one-step errorsexponential_smoothing_updateThe next forecast by simple exponential smoothing from the previous forecast, the actual value and the smoothing constant: F_new = F + alpha (A - F).
F the previous forecastA the actual value of that periodalpha smoothing constant, 0 < alpha <= 1forecast the new forecasterror the forecast error A - Fholt_linear_trendHolt's linear (double) exponential smoothing: level and trend updated each period, h-step forecast l_n + h b_n. Initial states l_0 = x_1 and b_0 = x_2 - x_1 (before the first observation) unless stated.
x the series, oldest first vectoralpha level smoothing constant, 0 < alpha <= 1beta trend smoothing constant, 0 < beta <= 1 (b_t = beta (l_t - l_{t-1}) + (1 - beta) b_{t-1})l0 initial level l_0 (default x_1) optionalb0 initial trend b_0 (default x_2 - x_1) optionalh forecast horizon in periods (default 1) integer optionalforecast the h-step-ahead forecastlevel the final level l_ntrend the final trend b_nsse sum of squared one-step errorsholt_winters_additiveHolt-Winters exponential smoothing with additive trend and additive seasonality: the h-step forecast, final level and trend, and the sum of squared one-step errors. initialization: l_0 = mean of the first season, b_0 = (mean of season 2 - mean of season 1)/m, s_j = x_j - l_0 (additive) or x_j / l_0 (multiplicative) for the first m observations.
x the series, oldest first (at least two full seasons) vectorm season length integeralpha level smoothing constantbeta trend smoothing constantgamma seasonal smoothing constanth forecast horizon in periods (default 1) integer optionalforecast the h-step-ahead forecastlevel final level l_ntrend final trend b_nsse sum of squared one-step errorsholt_winters_multiplicativeHolt-Winters exponential smoothing with additive trend and multiplicative seasonality: the h-step forecast, final level and trend, and the sum of squared one-step errors. initialization: l_0 = mean of the first season, b_0 = (mean of season 2 - mean of season 1)/m, s_j = x_j - l_0 (additive) or x_j / l_0 (multiplicative) for the first m observations.
x the series, oldest first (at least two full seasons) vectorm season length integeralpha level smoothing constantbeta trend smoothing constantgamma seasonal smoothing constanth forecast horizon in periods (default 1) integer optionalforecast the h-step-ahead forecastlevel final level l_ntrend final trend b_nsse sum of squared one-step errorsholt_updateUpdate Holt's level and trend with one new observation and forecast h periods ahead.
l previous levelb previous trendy the new observationalpha level smoothing constantbeta trend smoothing constanth forecast horizon (default 1) integer optionallevel new leveltrend new trendforecast level + h trendsimple_exponential_smoothingSimple exponential smoothing with smoothing constant alpha: the forecast of the next period and the sum of squared one-step errors. The initial level l_0 is the first observation unless stated.
x the series, oldest first vectoralpha the smoothing constant, 0 < alpha <= 1l0 the initial level l_0 before the first observation (default: x_1) optionalforecast the forecast of the next period (the final level l_n)sse sum of squared one-step errors, e_t = x_t - l_{t-1}mean_absolute_errorThe mean absolute error of forecasts against actual values.
y the actual values vectorf the forecasts (same length) vectormae Mean absolute errorn number of forecastsmean_absolute_percentage_errorThe mean absolute percentage error (in percent) of forecasts against actual values.
y the actual values vectorf the forecasts (same length) vectormape Mean absolute percentage errorn number of forecastsmean_absolute_scaled_errorMASE: the forecasts' mean absolute error divided by the in-sample mean absolute error of the (seasonal) naive forecast on the training data.
y_train the training (in-sample) data vectory the actual values vectorf the forecasts (same length as y) vectorsp seasonal period of the naive benchmark (default 1) integer optionalmase the mean absolute scaled errormae the forecasts' MAEscale in-sample MAE of the lag-sp naive forecastmean_forecast_errorThe mean forecast error (bias): positive when the forecasts are too low on average.
y the actual values vectorf the forecasts (same length) vectormean_error Mean forecast error (bias)n number of forecastsmean_squared_errorThe mean squared error of forecasts against actual values.
y the actual values vectorf the forecasts (same length) vectormse Mean squared errorn number of forecastsroot_mean_squared_errorThe root mean squared error of forecasts against actual values.
y the actual values vectorf the forecasts (same length) vectorrmse Root mean squared errorn number of forecastssymmetric_mapeThe symmetric MAPE in percent: 100/n sum 2|y - f| / (|y| + |f|).
y the actual values vectorf the forecasts (same length) vectorsmape Symmetric mean absolute percentage errorn number of forecastsexponential_interpolationFill a missing value at time t0 assuming constant growth between the neighbouring observations (linear interpolation of the logarithms).
t the times (strictly increasing) vectory the values at those times vectort0 the time of the missing valuevalue the interpolated value at t0linear_interpolationFill a missing value at time t0 by the straight line between the neighbouring observations.
t the times (strictly increasing) vectory the values at those times vectort0 the time of the missing valuevalue the interpolated value at t0kalman_filter_constant_velocityTrack position and velocity from noisy position measurements with the constant-velocity Kalman filter (discrete white-noise acceleration with variance q, time step dt): final state and covariance.
x the measured positions, oldest first vectordt time stepq acceleration (process) noise variancer position measurement noise variancep0 initial position estimatev0 initial velocity estimatevar0 initial variance of position and of velocity (uncorrelated)position final position estimatevelocity final velocity estimatep11 final position variancep12 final position-velocity covariancep22 final velocity variancekalman_filter_local_levelFilter a sequence of measurements with the scalar Kalman filter for x_t = x_{t-1} + w_t, z_t = x_t + v_t (predict, then update, at every step): the final estimate, variance, gain, all filtered estimates and the Gaussian log-likelihood of the one-step prediction errors.
x the measurements, oldest first vectorq process noise variancer measurement noise variancem0 initial state estimatep0 initial varianceestimate final filtered estimatevariance final variancegain final gainestimates filtered estimates for every measurementlog_likelihood sum of log N(v_t; 0, S_t)kalman_updateCombine a prior estimate (mean, variance) with a measurement (value, noise variance): the posterior mean and variance and the Kalman gain.
m prior meanp prior variance (> 0)z the measurementr measurement noise variance (> 0)mean posterior meanvariance posterior variancegain Kalman gain p/(p+r)kalman_stepOne predict-and-update step of the scalar Kalman filter for a random-walk state x_t = x_{t-1} + w_t observed as z_t = x_t + v_t.
m previous estimatep previous estimate variancez the new measurementq process noise variancer measurement noise variancemean updated estimatevariance updated variancegain Kalman gainprior_variance predicted variance p + qrts_smoother_local_levelSmoothed state estimates of the random-walk (local level) model: the Kalman filter forward, then the Rauch-Tung-Striebel recursion backward.
x the measurements, oldest first vectorq process noise variancer measurement noise variancem0 initial state estimatep0 initial variancesmoothed smoothed estimates for every timefirst smoothed estimate at time 1first_variance its variancekalman_steady_state_gainThe limiting Kalman gain and variances of the random-walk (local level) model with process variance q and measurement variance r (the solution of the scalar Riccati equation).
q process noise variance (> 0)r measurement noise variance (> 0)gain steady-state gainprior_variance steady-state predicted variance P-posterior_variance steady-state filtered variancekalman_steady_state_constant_velocityThe limiting position and velocity gains (and predicted position variance) of the constant-velocity Kalman filter with discrete white-noise acceleration q, time step dt and measurement variance r.
dt time stepq acceleration noise variance (> 0)r measurement noise variance (> 0)k_position steady-state position gaink_velocity steady-state velocity gainprior_p11 steady-state predicted position variancecentred_moving_averageThe centred moving average of length k: a symmetric k-term mean for odd k, the 2 x k moving average (half weights at both ends) for even k, as used in classical decomposition.
x the series, oldest first vectork the length of the moving average integercma the centred moving averages, from time first_index onfirst_index the time t (1-based) of the first centred value (k//2 + 1)first the first centred moving averageexponential_moving_averageThe exponential moving average with span k (alpha = 2/(k+1)), started at the first value.
x the series, oldest first vectork the span (number of periods) integerema the exponential moving average at every time (EMA_1 = x_1)last the latest exponential moving averagealpha the weight 2/(k+1)linearly_weighted_moving_averageThe k-period linearly weighted moving average: weights 1, 2, ..., k from the oldest to the newest value of each window.
x the series, oldest first vectork the window length integerlwma the weighted moving averages, one per complete windowlast the latest weighted moving average (forecast of the next period)simple_moving_averageThe k-period simple (trailing) moving average of a series; its last value is the moving-average forecast of the next period.
x the series, oldest first vectork the window length (number of periods) integersma the moving averages, one per complete window (the first covers x_1..x_k)last the latest moving average (forecast of the next period)count number of moving averages (n - k + 1)augmented_dickey_fuller_testThe augmented Dickey-Fuller tau statistic with p lagged differences: the t-ratio of gamma in Delta x_t = gamma x_{t-1} + sum_j delta_j Delta x_{t-j} (+ constant, + trend) + e_t. The statistic only.
x the series, oldest first vectorp number of lagged differences integerregression deterministic terms: c = constant (default), ct = constant and trend, n = none choice optionaltau the ADF statisticgamma the coefficient of x_{t-1}se its standard errornobs observations in the regression (n - 1 - p)dickey_fuller_testThe Dickey-Fuller tau statistic: the t-ratio of gamma in the regression Delta x_t = gamma x_{t-1} (+ constant, + trend) + e_t. The statistic only: compare it with Dickey-Fuller critical values.
x the series, oldest first vectorregression deterministic terms: c = constant (default), ct = constant and trend, n = none choice optionaltau the Dickey-Fuller statistic gamma/segamma the coefficient of x_{t-1}se its standard errornobs observations in the regression (n - 1)kpss_testThe KPSS statistic for level (c) or trend (ct) stationarity with a Bartlett-kernel long-run variance using a given number of lags. The statistic only: compare it with KPSS critical values.
x the series, oldest first vectornlags Bartlett lags in the long-run variance integerregression c = level stationarity (default), ct = trend stationarity choice optionalkpss the KPSS statisticlong_run_variance Bartlett long-run variance of the residualscompound_average_growth_rateThe compound (geometric) average growth rate per period of a positive series (CAGR when the periods are years), and the total growth from the first to the last value.
x the series, oldest first (positive values) vectorrate compound average growth rate per period, as a fractionrate_percent the same rate in percenttotal_growth total growth x_n/x_1 - 1, as a fractionperiods number of periods n - 1differencingDifference a series d times (and seasonally D times at lag s): the series that an ARIMA(p, d, q) or seasonal ARIMA model works on.
x the series, oldest first vectord number of regular (lag-1) differences, 0..3 (default 1) integer optionalD number of seasonal differences, 0..2 (default 0) integer optionals seasonal lag (needed when D > 0) integer optionaldifferenced the differenced serieslast its latest valuelength its length n - d - D sexponential_trend_forecastFit x_t = a e^(b t) (t = 1..n) by least squares on ln x_t, the growth rate per period e^b - 1, and the forecast of period n + h.
x the series, oldest first (positive) vectorh periods ahead (default 1) integer optionala the scale ab the exponent rate bgrowth_rate e^b - 1 per periodforecast a e^(b (n + h))linear_trend_forecastFit the least-squares trend line x_t = a + b t (t = 1..n) and forecast period n + h.
x the series, oldest first vectorh periods ahead to forecast (default 1) integer optionalslope trend per period bintercept a (the trend value at t = 0)forecast a + b (n + h)r_squared coefficient of determinationtrend_seasonal_regressionFit x_t = a + b t + (effect of t's season) by least squares with seasonal dummies (the first season is the baseline, effect 0; the series starts in season 1) and forecast period n + h.
x the series, oldest first, starting in season 1 vectorm season length integerh periods ahead (default 1) integer optionalforecast the fitted value at t = n + hintercept aslope b per periodseason_effects the m seasonal effects (season 1 = 0)mann_kendall_testThe Mann-Kendall statistic S, its variance (with the tie correction), the continuity-corrected normal score z and the two-sided p-value for a monotonic trend.
x the series, oldest first vectors S = sum_{i<j} sign(x_j - x_i)var_s variance of S with tie correctionz (S - sign S) / sqrt(var S)p_value two-sided normal p-valuequadratic_trend_forecastFit x_t = b0 + b1 t + b2 t^2 (t = 1..n) by least squares and forecast period n + h.
x the series, oldest first vectorh periods ahead (default 1) integer optionalb0 constantb1 coefficient of tb2 coefficient of t^2forecast the trend value at t = n + hdrift_forecastThe drift method: the average change per period (x_n - x_1)/(n - 1) and the forecast x_n + h x drift.
x the series, oldest first vectorh periods ahead (default 1) integer optionaldrift average change per periodforecast x_n + h driftsens_slopeSen's robust trend slope (median of all pairwise slopes, t = 1..n) and the intercept median(x) - slope median(t).
x the series, oldest first vectorslope median of (x_j - x_i)/(j - i), i < jintercept median(x) - slope (n+1)/215 files, 44.9 MB in total. The largest:
| File | Size |
|---|---|
| model.safetensors | 18.9 MB |
| dist/time_series_ai999x-1.0.0-py3-none-any.whl | 17.3 MB |
| onnx/search/encoder.int8.onnx | 4.9 MB |
| docs/time_series_ai999x_capabilities.pdf | 2.8 MB |
| onnx/search/index.json | 403.3 KB |
| docs/time_series_ai999x_capabilities.html | 230.2 KB |
| onnx/search/tokenizer.json | 176.4 KB |
| docs/time_series_ai999x_capabilities.md | 174.1 KB |
| README.md | 20 KB |
| LICENSE | 11.4 KB |
| evaluation/release_gate.md | 2.3 KB |
| evaluation/KNOWLEDGE_CARD.md | 1.4 KB |
Time Series answers questions in time series: moving averages, exponential smoothing, autocorrelation, ARIMA basics, stationarity tests, change points, forecasting accuracy and Kalman filtering. Each answer gives the value with its unit, the steps and the formula in LaTeX.
With pip: pip install time-series-ai999x. The same files are on Hugging Face (hf download AI999X/time-series-ai999x --local-dir time-series-ai999x) and GitHub.
Yes. It is a Python package that runs on an ordinary CPU without a network connection (Python >=3.10); no GPU and no API key are needed.
77 capabilities in 14 topics, including ARMA theory, Exponential smoothing, ARIMA models, Forecast accuracy, Kalman filtering.
Field: Mathematics & Statistics. Tasks: Question Answering, Token Classification, Text Classification, Time Series Forecasting, Sentence Similarity, Feature Extraction.
Asked "Find the 3-period simple moving average of [10, 12, 14, 13, 15].", it answers: sma = [12.0, 13.0, 14.0], last = 14, count = 3.
It says so and names what is missing or out of range, instead of guessing a number.