robust_peaks | R Documentation |
My version, starting from Brian Ripley's and informed by all the others. The previous versions found peaks & toughs, but could get false hits when there was a flat run of the same value. This is not uncommon in testing data, particularly at low speeds and high data sampling rates, where the crosshead can pause at the top or bottom of travel and generate several data points all at the same load/extension.
robust_peaks(series, span = 5)
series |
The vector of numbers to find peaks in. Assumed to start low and move towards a peak first. |
span |
The number of points to check looking for each peak. Must be odd and >= 3. Default is 5. |
We solve this by recognising that the starting point must be a trough (as we are moving away from start towards maximum) and that the peaks and troughs must come in strict succession. That is, each peak must be followed by a trough, and so on. Any additional peaks/troughs are false.
This version only works with data that increase away from the start point. That means that compressive tests, where the absolute Load & Extension go negative from the start point, must be inverted before testing for peaks.
A vector of (-1 / 0 / 1) if series[i] is ( trough / "normal" / peak ). Always padded to the length of the input, and awlays starts with a trough.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.