CosineWindow<T>
Models & Types · AiDotNet.WindowFunctions
Implements the Cosine window function (sometimes called Sine window) for signal processing applications.
Implements: IWindowFunction<T>
For Beginners
A window function is a mathematical tool that helps analyze signals more accurately.
The Cosine window:
- Creates a smooth half-sine wave shape from 0 to 1 and back to 0
- Has a simple mathematical form compared to other windows
- Provides a gentle tapering effect at the edges of your data
Think of it like gradually turning the volume up and then down when listening to audio. Instead of an abrupt start and stop (which can cause distortion in analysis), the Cosine window smoothly increases from zero, reaches its maximum in the middle, and then smoothly decreases back to zero at the end. This helps reduce unwanted artifacts when analyzing frequencies in your data.
How It Works
The Cosine window function is a simple yet effective window defined by the sine function: w(n) = sin(pn/(N-1)) where n is the sample index and N is the window size. Despite its name, this window actually uses the sine function mathematically, but it’s called the Cosine window due to historical convention in signal processing.
Example
using AiDotNet.WindowFunctions;
using AiDotNet.Tensors.LinearAlgebra;
var window = new CosineWindow<double>();
Vector<double> w = window.Create(16);
Console.WriteLine($"CosineWindow: {w.Length}-point window, center = {w[w.Length / 2]:F4}");
Constructors
| Constructor | Summary |
|---|---|
CosineWindow() |
Initializes a new instance of the CosineWindow class. |
Methods
| Method | Summary |
|---|---|
Vector<T> Create(int windowSize) |
Creates a Cosine window of the specified size. |
WindowFunctionType GetWindowFunctionType() |
Gets the type identifier for this window function. |