UNPKG

ml-gsd

Version:
24 lines 815 B
import { getMinMaxIntervalsDy } from "./getMinMaxIntervals.js"; import { getPeakFromIntervals } from "./getPeaksFromIntervals.js"; export function secondDerivative(input) { const { x, y, yData, dY, ddY, dX, yThreshold } = input; const minddY = []; const { intervalL, intervalR } = getMinMaxIntervalsDy(y, x, dY, dX); // By the intermediate value theorem We cannot find 2 consecutive maximum or minimum for (let i = 1; i < y.length - 1; ++i) { // Minimum in second derivative if (ddY[i] < ddY[i - 1] && ddY[i] < ddY[i + 1]) { minddY.push(i); } } return getPeakFromIntervals({ minData: minddY, intervalL, intervalR, x, yData, yThreshold, ddY, }); } //# sourceMappingURL=secondDerivative.js.map