Repository navigation
Module_Statistics_TimeSeriesAnalysis_zh
cyclone_dll edited this page Sep 13, 2026
·
7 revisions
Vorcyc.Mathematics.Statistics.TimeSeriesAnalysis 是一个提供时间序列分析方法的类,包括平滑、分解、预测、自相关、偏自相关、移动平均和指数平滑。
以下方法均位于类 :Vorcyc.Mathematics.Statistics.TimeSeriesAnalysis
📒目录
- 🔖 Smooth 方法
- 🔖 Decompose 方法
- 🔖 Forecast 方法
- 🔖 Autocorrelation 方法
- 🔖 PartialAutocorrelation 方法
- 🔖 MovingAverage 方法
- 🔖 ExponentialSmoothing 方法
- 🔖 Holt / Holt–Winters(0.10.18)
Vorcyc.Mathematics.Statistics.TimeSeriesAnalysis 是一个提供时间序列分析方法的类,包括平滑、分解、预测、自相关、偏自相关、移动平均和指数平滑。
-
public static T[] Smooth<T>(this Span<T> series, int windowSize) where T : IFloatingPointIeee754<T>- 实现时间序列的平滑。
- 参数:
-
series: 时间序列数据。 -
windowSize: 平滑窗口的大小。
-
- 返回值: 平滑后的时间序列。
-
public static (T[] Trend, T[] Seasonal, T[] Residual) Decompose<T>(this Span<T> series, int period) where T : IFloatingPointIeee754<T>- 实现时间序列的分解,返回趋势、季节性和残差。
- 参数:
-
series: 时间序列数据。 -
period: 季节周期。
-
- 返回值: 包含趋势、季节性和残差的元组。
-
public static T[] Forecast<T>(this Span<T> series, int forecastPeriod) where T : IFloatingPointIeee754<T>- 实现时间序列的预测,返回预测值。
- 参数:
-
series: 时间序列数据。 -
forecastPeriod: 预测期数。
-
- 返回值: 预测值数组。
-
public static T[] Autocorrelation<T>(this Span<T> series, int lagMax) where T : IFloatingPointIeee754<T>- 计算时间序列的自相关函数。
- 参数:
-
series: 时间序列数据。 -
lagMax: 最大滞后期数。
-
- 返回值: 自相关函数值数组。
-
public static T[] PartialAutocorrelation<T>(this Span<T> series, int lagMax) where T : IFloatingPointIeee754<T>- 计算时间序列的偏自相关函数。
- 参数:
-
series: 时间序列数据。 -
lagMax: 最大滞后期数。
-
- 返回值: 偏自相关函数值数组。
-
public static T[] MovingAverage<T>(this Span<T> series, int windowSize) where T : IFloatingPointIeee754<T>- 计算时间序列的移动平均。
- 参数:
-
series: 时间序列数据。 -
windowSize: 移动平均窗口的大小。
-
- 返回值: 移动平均值数组。
-
public static T[] ExponentialSmoothing<T>(this Span<T> series, T alpha) where T : IFloatingPointIeee754<T>- 实现时间序列的指数平滑。
- 参数:
-
series: 时间序列数据。 -
alpha: 平滑系数。
-
- 返回值: 指数平滑后的时间序列。
这些方法在同一个 TimeSeriesAnalysis 分部类(TimeSeriesAnalysis_Extended.cs)。
-
public static T[] Holt<T>(this ReadOnlySpan<T> series, T alpha, T beta)- 二次指数平滑的拟合值。
-
public static (T[] Fitted, HoltState<T> State) HoltWithState<T>(this ReadOnlySpan<T> series, T alpha, T beta)- 同一递推,另返回末 level 与 trend(不是
fitted[^1] - fitted[^2])。
- 同一递推,另返回末 level 与 trend(不是
-
public static T[] ForecastHolt<T>(this ReadOnlySpan<T> series, int forecastPeriod, T alpha, T beta)- 按
LastLevel + h · LastTrend外推。
- 按
-
public static (T[] Fitted, T[] Forecast) HoltWinters<T>(...)- 加法 Holt–Winters;预报使用末季向量
S[(h-1) mod m]。
- 加法 Holt–Winters;预报使用末季向量
-
public static (T[] Fitted, T[] Forecast, HoltWintersState<T> State) HoltWintersWithState<T>(...)- 同时返回
LastLevel、LastTrend、LastSeasonal,便于不重新拟合地继续预报。
- 同时返回
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);以下是一个使用 TimeSeriesAnalysis 类中多个方法的示例,并在示例中加入了注释:
using System;
using Vorcyc.Mathematics.Statistics;
public class TimeSeriesAnalysisExample
{
public static void Main()
{
// 定义时间序列数据
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 };
// 平滑
double[] smoothedSeries = series.Smooth(3);
Console.WriteLine("Smoothed Series: " + string.Join(", ", smoothedSeries));
// 分解
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));
// 预测
double[] forecast = series.Forecast(5);
Console.WriteLine("Forecast: " + string.Join(", ", forecast));
// 自相关函数
double[] acf = series.Autocorrelation(5);
Console.WriteLine("Autocorrelation: " + string.Join(", ", acf));
// 偏自相关函数
double[] pacf = series.PartialAutocorrelation(5);
Console.WriteLine("Partial Autocorrelation: " + string.Join(", ", pacf));
// 移动平均
double[] movingAverage = series.MovingAverage(3);
Console.WriteLine("Moving Average: " + string.Join(", ", movingAverage));
// 指数平滑
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 扩展
-
📒 示例