UNPKG

ml-gsd

Version:
25 lines 939 B
export function tryMatchOneIntervalWithMinData(options) { const { x, lastK, minData, yThreshold, intervalWidth, intervalCenter, yData, } = options; let minDistance = Number.POSITIVE_INFINITY; let possible = -1; let newLastIndex = lastK; for (let k = newLastIndex + 1; k < minData.length; k++) { const centerIndex = minData[k]; if (yData[centerIndex] <= yThreshold) { continue; } const deltaX = x[centerIndex]; const currentDistance = Math.abs(deltaX - intervalCenter); if (currentDistance < intervalWidth) { if (currentDistance < minDistance) { possible = k; } newLastIndex = k; } if (currentDistance >= minDistance) break; minDistance = currentDistance; } return { lastIndex: newLastIndex, possible }; } //# sourceMappingURL=tryMatchOneIntervalWithMinData.js.map