Getting Started
Welcome to SignalSharp! This guide will help you install the library and get started with basic signal processing tasks.
Installation
To install SignalSharp, you can use the .NET CLI:
dotnet add package SignalSharp
Alternatively, you can add SignalSharp to your project via the NuGet Package Manager UI in Visual Studio, JetBrains Rider, or your preferred IDE.
Library Overview
SignalSharp provides a range of tools organized into several categories:
- Change Point Detection: Algorithms like PELT and CUSUM find points in time where signal properties change significantly.
- Smoothing: Techniques such as Moving Average and the Savitzky-Golay Filter help reduce noise and highlight underlying trends.
- Resampling: Includes methods for downsampling signals and computing segment statistics (mean, median, etc.).
- Cost Functions: Various functions (L1, L2, RBF, Likelihood-based) used by algorithms like PELT to quantify segment characteristics. See the PELT documentation for details.
Basic Usage Example: Applying the Savitzky-Golay Filter
Let's demonstrate a common use case: smoothing a noisy signal using the Savitzky-Golay filter. This filter fits polynomial segments to the data, which can reduce noise while preserving the shape of features like peaks better than a simple moving average.
Prepare your data: Start with an array representing your signal.
// Sample noisy signal double[] noisySignal = {1.0, 2.5, 2.0, 3.5, 4.0, 5.0, 4.5, 6.0};
Apply the filter: Use
SavitzkyGolayFilter.Apply
method. You need to specify thewindowLength
(odd number, how many points to use for each polynomial fit) and thepolynomialOrder
(degree of the polynomial, must be less thanwindowLength
).using SignalSharp.Smoothing.SavitzkyGolay; // Import the necessary namespace using System; // For Console.WriteLine // Sample noisy signal double[] noisySignal = {1.0, 2.5, 2.0, 3.5, 4.0, 5.0, 4.5, 6.0}; // Define filter parameters int windowLength = 5; // Use 5 points for each polynomial fit int polynomialOrder = 2; // Fit a 2nd degree (quadratic) polynomial // Apply the filter double[] smoothedSignal = SavitzkyGolayFilter.Apply( inputSignal: noisySignal, windowLength: windowLength, polynomialOrder: polynomialOrder ); // Display the results Console.WriteLine("Original Signal: " + string.Join(", ", noisySignal)); Console.WriteLine("Smoothed Signal: " + string.Join(", ", smoothedSignal));
(Note: The exact output depends on the filter parameters and implementation details, but it will be a smoothed version of the input.)
Next Steps
This example shows just one capability of SignalSharp. To learn more about specific algorithms and see detailed usage examples:
- Explore the documentation pages for Detection, Smoothing, and Resampling.
- Check the API Reference section linked within each algorithm's documentation page.
Dive into the specific documentation relevant to your task to understand the available options and best practices.