ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
PeakDetection< sampleSize > Class Template Reference

Detects peaks in time-series data using statistical methods. More...

#include <PeakDetection.h>

Public Member Functions

 PeakDetection (uint8_t lag=12, float threshold=0.75f, float influence=0.5f)
 Constructs a PeakDetection object with the specified parameters.
 
void Calculate (float *data, bool *peaks)
 Processes the data and identifies peaks.
 

Private Member Functions

void GetStdDev (uint8_t start, uint8_t length, float *data, float &avgRet, float &stdRet)
 Calculates the mean and standard deviation for a range of data.
 

Private Attributes

uint8_t lag
 Number of data points to use for moving average and standard deviation.
 
float threshold
 Threshold for peak detection, expressed as a multiple of the standard deviation.
 
float influence
 Influence of detected peaks on subsequent calculations.
 
float filData [sampleSize]
 Filtered data array for influence adjustment.
 
float avg [sampleSize]
 Moving average of the data.
 
float std [sampleSize]
 Moving standard deviation of the data.
 

Detailed Description

template<size_t sampleSize>
class PeakDetection< sampleSize >

Detects peaks in time-series data using statistical methods.

This class identifies peaks by calculating a moving average and standard deviation of the data and comparing each value against a dynamically adjusted threshold.

Template Parameters
sampleSizeThe size of the data window used for peak detection.

Definition at line 27 of file PeakDetection.h.

Constructor & Destructor Documentation

◆ PeakDetection()

template<size_t sampleSize>
PeakDetection ( uint8_t  lag = 12,
float  threshold = 0.75f,
float  influence = 0.5f 
)

Constructs a PeakDetection object with the specified parameters.

Parameters
lagThe number of data points for the moving average and standard deviation (default: 12).
thresholdThe threshold for detecting peaks, expressed as a multiple of the standard deviation (default: 0.75).
influenceThe influence of detected peaks on subsequent calculations (default: 0.5).

Member Function Documentation

◆ Calculate()

template<size_t sampleSize>
void Calculate ( float data,
bool peaks 
)

Processes the data and identifies peaks.

Parameters
dataPointer to the input data array.
peaksOutput array of boolean values indicating whether each point is a peak.

◆ GetStdDev()

template<size_t sampleSize>
void GetStdDev ( uint8_t  start,
uint8_t  length,
float data,
float avgRet,
float stdRet 
)
private

Calculates the mean and standard deviation for a range of data.

Parameters
startThe starting index of the range.
lengthThe number of elements in the range.
dataPointer to the data array.
avgRetOutput parameter for the calculated mean.
stdRetOutput parameter for the calculated standard deviation.

Member Data Documentation

◆ avg

template<size_t sampleSize>
float avg[sampleSize]
private

Moving average of the data.

Definition at line 33 of file PeakDetection.h.

◆ filData

template<size_t sampleSize>
float filData[sampleSize]
private

Filtered data array for influence adjustment.

Definition at line 32 of file PeakDetection.h.

◆ influence

template<size_t sampleSize>
float influence
private

Influence of detected peaks on subsequent calculations.

Definition at line 31 of file PeakDetection.h.

◆ lag

template<size_t sampleSize>
uint8_t lag
private

Number of data points to use for moving average and standard deviation.

Definition at line 29 of file PeakDetection.h.

◆ std

template<size_t sampleSize>
float std[sampleSize]
private

Moving standard deviation of the data.

Definition at line 34 of file PeakDetection.h.

◆ threshold

template<size_t sampleSize>
float threshold
private

Threshold for peak detection, expressed as a multiple of the standard deviation.

Definition at line 30 of file PeakDetection.h.


The documentation for this class was generated from the following file: