NMath Reference Guide

## Peak |

Class PeakFinderSavitzkyGolay uses smooth Savitzky-Golay
derivatives to find peaks in data and acts as a collection for the
found peaks.

Inheritance Hierarchy

Syntax

The PeakFinderSavitzkyGolay type exposes the following members.

Constructors

Name | Description | |
---|---|---|

PeakFinderSavitzkyGolay(DoubleVector, Int32) | An instance of a Savitkzy-Golay peak finder, using a third degree polynomial. | |

PeakFinderSavitzkyGolay(DoubleVector, Int32, Int32) | An instance of a Savitkzy-Golay peak finder. The width of the filter must be less than the length of the data, and the polynomial degree must be less than the filter width. |

Properties

Name | Description | |
---|---|---|

AbscissaInterval | Gets\Sets the abscissa interval for the data. This is used to scale the derivatives to the correct units. | |

InputData |
Gets / Sets the input data. Set nullifies current peak list.
(Inherited from PeakFinderBase) | |

Item |
Gets the extrema via index operator.
(Inherited from PeakFinderBase) | |

NumberPeaks |
Gets the number of peaks found.
(Inherited from PeakFinderBase) | |

RootFindingTolerance | Gets\Sets the root finders error tolerance. Default is 0.00001; | |

SlopeSelectivity | Slope selectivity is between [0,Double.MaxValue] (default = 0.0). Peak finding selectivity increases with larger values. A value of 0 returns all peaks (all smoothed derivative zero crossings). |

Methods

Name | Description | |
---|---|---|

ApplySortOrder |
Applies the desired sort order on the found peaks.
(Inherited from PeakFinderBase) | |

Clone | Creates a deep copy of this SavitzkyGolayPeakFinder instance. | |

GetAllPeaks |
Returns a list of all C# Extrema (Inherited from PeakFinderBase) | |

LocatePeakIndices |
Locates the Indices in the vector preceeding the peak.
(Overrides PeakFinderBaseLocatePeakIndices) | |

LocatePeaks |
Locates the all peak abscissae and their smoothed ordinates
in current data set.
(Overrides PeakFinderBaseLocatePeaks) | |

RetainPeaks(FuncExtrema, Boolean) |
Retains C# Extrema C# `this` C# FilterDelegate (Inherited from PeakFinderBase) | |

RetainPeaks(FuncExtrema, Extrema, Extrema, Boolean, Boolean) |
Retains C# Extrema C# `this` C# FilterDelegate C# DropEdgePeaks (Inherited from PeakFinderBase) | |

SelectPeaks | Obsolete.Deprecated. Selects and returns a list of C# Extrema C# FilterDelegate (Inherited from PeakFinderBase) | |

SelectPeaksForwardOrder |
Selects and returns a list of C# Extrema C# FilterDelegate (Inherited from PeakFinderBase) | |

SelectPeaksReverseOrder |
Selects and returns a list of C# Extrema C# FilterDelegate (Inherited from PeakFinderBase) |

Fields

Name | Description | |
---|---|---|

findpeaks_ | If false, report valleys, otherwise report peaks. | |

peakabscissae_ |
List of the peaks abscissae.
(Inherited from PeakFinderBase) | |

peakvalues_ |
List of peaks ordinates.
(Inherited from PeakFinderBase) |

Remarks

Typically the degree of the smoothing polynomial is between 3 and 5. The
selectivity of the peak finder can be reduced by increasing the
SlopeSelectivity. If SlopeSelectivity is set to 0 (default), all
found peaks are reported. For proper scaling of the peak abscissa locations, set
AbscissaInterval to the data sample interval.

The filter's parameters must satisfied the follow two rules. 1. The filter width must be less than the length of the data. 2. The polynomial degree must be less than the filter width.

Example

C#

// Build a sinc() function. double step_size = 0.1; DoubleVector x = new DoubleVector(5000, 0.01, step_size); DoubleVector sinc = NMathFunctions.Sin(x) / x; // Build a peak finder with a width of 6, and 4th degree smoothing polynomial. PeakFinderSavitzkyGolay pf = new PeakFinderSavitzkyGolay(sinc, 6, 4); pf.AbscissaInterval = step_size; // Scale abscissa locations. pf.SlopeSelectivity = 0; // Return all peaks. pf.LocatePeaks(); // Locate peaks // Dump peaks to console. for (int i = 0; i < pf.NumberPeaks; i++) Console.WriteLine("Found peak at = ({0},{1})", pf[i].X, pf[i].Y);

See Also