Repository navigation
Module_Statistics_TimeSeriesAnalysis
Location: Home / Statistics module / Time series analysis
Vorcyc.Mathematics.Statistics.TimeSeriesAnalysis provides time series analysis methods including smoothing, decomposition, forecasting, autocorrelation, partial autocorrelation, moving average, and exponential smoothing.
All methods below are on class:
Vorcyc.Mathematics.Statistics.TimeSeriesAnalysis
📒Contents
- 🔖 Smooth method
- 🔖 Decompose method
- 🔖 Forecast method
- 🔖 Autocorrelation method
- 🔖 PartialAutocorrelation method
- 🔖 MovingAverage method
- 🔖 ExponentialSmoothing method
- 🔖 Holt / Holt–Winters (0.10.18)
Vorcyc.Mathematics.Statistics.TimeSeriesAnalysis provides time series analysis methods including smoothing, decomposition, forecasting, autocorrelation, partial autocorrelation, moving average, and exponential smoothing.
-
public static T[] Smooth<T>(this Span<T> series, int windowSize) where T : IFloatingPointIeee754<T>- Smooths a time series.
- Parameters:
-
series: Time series data. -
windowSize: Smoothing window size.
-
- Returns: Smoothed time series.
-
public static (T[] Trend, T[] Seasonal, T[] Residual) Decompose<T>(this Span<T> series, int period) where T : IFloatingPointIeee754<T>- Decomposes a time series into trend, seasonal, and residual components.
- Parameters:
-
series: Time series data. -
period: Seasonal period.
-
- Returns: Tuple of trend, seasonal, and residual arrays.
-
public static T[] Forecast<T>(this Span<T> series, int forecastPeriod) where T : IFloatingPointIeee754<T>- Forecasts future values of a time series.
- Parameters:
-
series: Time series data. -
forecastPeriod: Number of periods to forecast.
-
- Returns: Forecast values array.
-
public static T[] Autocorrelation<T>(this Span<T> series, int lagMax) where T : IFloatingPointIeee754<T>- Computes the autocorrelation function of a time series.
- Parameters:
-
series: Time series data. -
lagMax: Maximum lag.
-
- Returns: Autocorrelation function values.
-
public static T[] PartialAutocorrelation<T>(this Span<T> series, int lagMax) where T : IFloatingPointIeee754<T>- Computes the partial autocorrelation function of a time series.
- Parameters:
-
series: Time series data. -
lagMax: Maximum lag.
-
- Returns: Partial autocorrelation function values.
-
public static T[] MovingAverage<T>(this Span<T> series, int windowSize) where T : IFloatingPointIeee754<T>- Computes the moving average of a time series.
- Parameters:
-
series: Time series data. -
windowSize: Moving average window size.
-
- Returns: Moving average values.
-
public static T[] ExponentialSmoothing<T>(this Span<T> series, T alpha) where T : IFloatingPointIeee754<T>- Applies exponential smoothing to a time series.
- Parameters:
-
series: Time series data. -
alpha: Smoothing coefficient.
-
- Returns: Exponentially smoothed time series.
These live on the same TimeSeriesAnalysis partial class (TimeSeriesAnalysis_Extended.cs).
-
public static T[] Holt<T>(this ReadOnlySpan<T> series, T alpha, T beta)- Double exponential smoothing fitted values.
-
public static (T[] Fitted, HoltState<T> State) HoltWithState<T>(this ReadOnlySpan<T> series, T alpha, T beta)- Same recurrence, plus the terminal level and trend (not
fitted[^1] - fitted[^2]).
- Same recurrence, plus the terminal level and trend (not
-
public static T[] ForecastHolt<T>(this ReadOnlySpan<T> series, int forecastPeriod, T alpha, T beta)- Extrapolates
LastLevel + h · LastTrend.
- Extrapolates
-
public static (T[] Fitted, T[] Forecast) HoltWinters<T>(...)- Additive Holt–Winters; forecast uses the last-season vector
S[(h-1) mod m].
- Additive Holt–Winters; forecast uses the last-season vector
-
public static (T[] Fitted, T[] Forecast, HoltWintersState<T> State) HoltWintersWithState<T>(...)- Also returns
LastLevel,LastTrend, andLastSeasonalso a caller can continue without refitting.
- Also returns
var (fitted, state) = series.HoltWithState(0.8, 0.3);
double[] ahead = series.ForecastHolt(5, 0.8, 0.3);
var (hwFit, hwFc, hwState) = series.HoltWintersWithState(12, 6, 0.4, 0.1, 0.2);Example using multiple methods from the TimeSeriesAnalysis class, with comments:
using System;
using Vorcyc.Mathematics.Statistics;
public class TimeSeriesAnalysisExample
{
public static void Main()
{
// Define time series data
Span<double> series = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 };
// Smooth
double[] smoothedSeries = series.Smooth(3);
Console.WriteLine("Smoothed Series: " + string.Join(", ", smoothedSeries));
// Decompose
var (trend, seasonal, residual) = series.Decompose(3);
Console.WriteLine("Trend: " + string.Join(", ", trend));
Console.WriteLine("Seasonal: " + string.Join(", ", seasonal));
Console.WriteLine("Residual: " + string.Join(", ", residual));
// Forecast
double[] forecast = series.Forecast(5);
Console.WriteLine("Forecast: " + string.Join(", ", forecast));
// Autocorrelation
double[] acf = series.Autocorrelation(5);
Console.WriteLine("Autocorrelation: " + string.Join(", ", acf));
// Partial autocorrelation
double[] pacf = series.PartialAutocorrelation(5);
Console.WriteLine("Partial Autocorrelation: " + string.Join(", ", pacf));
// Moving average
double[] movingAverage = series.MovingAverage(3);
Console.WriteLine("Moving Average: " + string.Join(", ", movingAverage));
// Exponential smoothing
double[] exponentialSmoothing = series.ExponentialSmoothing(0.5);
Console.WriteLine("Exponential Smoothing: " + string.Join(", ", exponentialSmoothing));
}
}-
- 🔖 ArrayExtension class
- 🔖 BaseConverter class
- 🔖 BitMathExtension class
- 🔖 Combinatorics class
- 🔖 ConstantsFp32 class
- 🔖 NumberMapper class
- 🔖 PinnableArray<T> class
- 🔖 SimpleRNG_Fp32 and SimpleRNG_Fp64 classes
- 🔖 TrigonometryHelper class
- 🔖 VMath class
- 🔖 Pinned buffers (Buffers)
- 🔖 IPinnedBuffer<T> interface
- 🔖 POHBuffer<T> class
- 🔖 NativeBuffer<T> class
-
- 🔖 0.9 classifier walkthrough
- 🔖 KNN<T> class
- 🔖 MultipleLinearRegression<T> class
- 🔖 SimpleLinearRegression<T> class
- 🔖 SupportVectorMachine<TSelf> class
- 🔖 DBSCAN<T> class
- 🔖 ExpectationMaximization<T> class
- 🔖 GMM<T> class
- 🔖 HierarchicalClustering<T> class
- 🔖 KMeansClusterer<T> class
- 🔖 VectorQuantization<T> class
- 🔖 FactorAnalysis<T> class
- 🔖 PCA<TSelf> class
- 🔖 TSNE<T> class
- 🔖 Distance metric classes
-
📒 Examples
-
📒 GPU 策略说明
- 🔖 为何放弃主包 GPU
- 🔖 当前性能路径
- 🔖 若仍需要更强算力
-
📒 计算上下文模块
-
📒 核心模块
-
📒 深度学习模块
-
📒 线性代数模块
-
📒 机器学习模块
- 🔖 0.9 分类器完整示例
- 🔖 KNN<T> 类
- 🔖 MultipleLinearRegression<T> 类
- 🔖 SimpleLinearRegression<T> 类
- 🔖 SupportVectorMachine<TSelf> 类
- 🔖 DBSCAN<T> 类
- 🔖 ExpectationMaximization<T> 类
- 🔖 GMM<T> 类
- 🔖 HierarchicalClustering<T> 类
- 🔖 KMeansClusterer<T> 类
- 🔖 VectorQuantization<T> 类
- 🔖 FactorAnalysis<T> 类
- 🔖 PCA<TSelf> 类
- 🔖 TSNE<T> 类
- 🔖 距离度量类
-
📒 信号处理模块
-
📒 数值模块
-
📒 统计模块
- 🔖 基础统计函数
- 🔖 高级统计函数
- 🔖 稳健统计 / RunningMoments
- 🔖 其它统计函数
- 🔖 分布相关函数
- 🔖 时间序列分析
- 🔖 IComparable 扩展
- 🔖 ExtremeValueFinder
- 🔖 INumber 扩展
-
📒 FFTW 扩展
-
📒 示例