mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-15 09:08:04 +00:00
xml doc rewrite
This commit is contained in:
+35
-1
@@ -1,9 +1,35 @@
|
||||
using System;
|
||||
namespace QuanTAlib;
|
||||
|
||||
/// <summary>
|
||||
/// GMA: Gaussian Moving Average
|
||||
/// A moving average that uses weights based on the Gaussian (normal) distribution curve.
|
||||
/// This creates a smooth, bell-shaped weighting scheme that gives maximum weight to the
|
||||
/// center of the period and gradually decreasing weights towards the edges.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The GMA calculation process:
|
||||
/// 1. Creates a Gaussian distribution of weights centered on the period
|
||||
/// 2. Normalizes the weights to sum to 1
|
||||
/// 3. Applies the weights through convolution
|
||||
///
|
||||
/// Key characteristics:
|
||||
/// - Smooth, symmetric weight distribution
|
||||
/// - Natural bell curve weighting
|
||||
/// - Reduces noise while preserving signal characteristics
|
||||
/// - Less sensitive to outliers than simple moving averages
|
||||
/// - Implemented using efficient convolution operations
|
||||
///
|
||||
/// Implementation:
|
||||
/// Based on Gaussian distribution principles from statistics
|
||||
/// </remarks>
|
||||
|
||||
public class Gma : AbstractBase
|
||||
{
|
||||
private readonly Convolution _convolution;
|
||||
|
||||
/// <param name="period">The number of data points used in the GMA calculation.</param>
|
||||
/// <exception cref="ArgumentException">Thrown when period is less than 1.</exception>
|
||||
public Gma(int period)
|
||||
{
|
||||
if (period < 1)
|
||||
@@ -16,12 +42,20 @@ public class Gma : AbstractBase
|
||||
Init();
|
||||
}
|
||||
|
||||
/// <param name="source">The data source object that publishes updates.</param>
|
||||
/// <param name="period">The number of data points used in the GMA calculation.</param>
|
||||
public Gma(object source, int period) : this(period)
|
||||
{
|
||||
var pubEvent = source.GetType().GetEvent("Pub");
|
||||
pubEvent?.AddEventHandler(source, new ValueSignal(Sub));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates the Gaussian-based convolution kernel for the GMA calculation.
|
||||
/// </summary>
|
||||
/// <param name="period">The period for which to generate the kernel.</param>
|
||||
/// <param name="sigma">The standard deviation parameter controlling the spread of the Gaussian curve. Default is 1.0.</param>
|
||||
/// <returns>An array of normalized Gaussian-based weights for the convolution operation.</returns>
|
||||
public static double[] GenerateKernel(int period, double sigma = 1.0)
|
||||
{
|
||||
double[] kernel = new double[period];
|
||||
@@ -71,4 +105,4 @@ public class Gma : AbstractBase
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user