Table of Contents

Class Resampling

Namespace
SignalSharp.Resampling
Assembly
SignalSharp.dll

Provides various methods for resampling signals, including downsampling, segment statistics, and approximation techniques.

public static class Resampling
Inheritance
Resampling
Inherited Members

Remarks

Resampling is a critical process in signal processing and data analysis. It involves altering the sampling rate of a signal to either reduce (downsample) or increase (upsample) the number of samples. This is particularly useful when dealing with signals of different sampling rates, reducing data size, or preparing data for further analysis.

The Resampling class includes methods for downsampling, computing segment-based statistics (mean, median, max, min), applying a moving average, and approximating a signal using Chebyshev polynomials. Each method is designed to handle common tasks in signal processing with efficiency and accuracy.

Consider using the resampling methods in scenarios where:

  • Signal data needs to be reduced in size while retaining essential information.
  • Segment-based statistics are required for analysis or feature extraction.
  • A smoothing technique like moving average is needed to reduce noise.
  • An efficient approximation of the signal is necessary for further processing or analysis.

Methods

Downsample(double[], int)

Downsamples the given signal by the specified factor.

public static double[] Downsample(double[] signal, int factor)

Parameters

signal double[]

The input signal to be downsampled.

factor int

The downsampling factor.

Returns

double[]

The downsampled signal.

Exceptions

ArgumentNullException

Thrown when the signal is null.

ArgumentOutOfRangeException

Thrown when the factor is less than or equal to zero.

SegmentMax(double[], int)

Computes the maximum value of each segment in the signal, divided by the specified factor.

public static double[] SegmentMax(double[] signal, int factor)

Parameters

signal double[]

The input signal.

factor int

The segment size factor.

Returns

double[]

An array containing the maximum value of each segment.

Exceptions

ArgumentNullException

Thrown when the signal is null.

ArgumentOutOfRangeException

Thrown when the factor is less than or equal to zero.

SegmentMean(double[], int)

Computes the mean of each segment in the signal, divided by the specified factor.

public static double[] SegmentMean(double[] signal, int factor)

Parameters

signal double[]

The input signal.

factor int

The segment size factor.

Returns

double[]

An array containing the mean of each segment.

Exceptions

ArgumentNullException

Thrown when the signal is null.

ArgumentOutOfRangeException

Thrown when the factor is less than or equal to zero.

SegmentMedian(double[], int, bool)

Computes the median of each segment in the signal, divided by the specified factor.

public static double[] SegmentMedian(double[] signal, int factor, bool useQuickSelect = true)

Parameters

signal double[]

The input signal.

factor int

The segment size factor.

useQuickSelect bool

Indicates whether to use the QuickSelect algorithm for median computation.

Returns

double[]

An array containing the median of each segment.

Remarks

The SegmentMedian(double[], int, bool) method divides the input signal into segments of size defined by the factor parameter and computes the median of each segment. The median is a robust measure of central tendency, less affected by outliers compared to the mean.

The useQuickSelect parameter determines the algorithm used for median computation:

  • true - Uses the QuickSelect algorithm, which has an average-case time complexity of O(n), making it efficient for larger datasets. QuickSelect is a selection algorithm to find the k-th smallest element in an unordered list, and it can be adapted to find the median by selecting the middle element.
  • false - Uses a straightforward sort-and-select method, which has a time complexity of O(n log n). This method sorts the segment and then selects the middle element (or the average of the two middle elements for even-sized segments). It is simpler but may be slower for large segments.

Exceptions

ArgumentNullException

Thrown when the signal is null.

ArgumentOutOfRangeException

Thrown when the factor is less than or equal to zero.

SegmentMin(double[], int)

Computes the minimum value of each segment in the signal, divided by the specified factor.

public static double[] SegmentMin(double[] signal, int factor)

Parameters

signal double[]

The input signal.

factor int

The segment size factor.

Returns

double[]

An array containing the minimum value of each segment.

Exceptions

ArgumentNullException

Thrown when the signal is null.

ArgumentOutOfRangeException

Thrown when the factor is less than or equal to zero.