diff --git a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/series/EmpiricalModeDecomposition.kt b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/series/EmpiricalModeDecomposition.kt index 301247698..ea8a0aa62 100644 --- a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/series/EmpiricalModeDecomposition.kt +++ b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/series/EmpiricalModeDecomposition.kt @@ -196,16 +196,12 @@ private fun SeriesAlgebra.relativeDifference( .div(previous pow 2) .fold(0.0) { acc, d -> acc + d } // TODO replace with Series<>.sum() method when it's implemented -private fun > isExtreme(prev: T, elem: T, next: T): Boolean = - (elem > prev && elem > next) || (elem < prev && elem < next) - /** * Brute force count all extrema of a series. */ -@Deprecated("Does not match the algorithm currently in use.") private fun Series.countExtrema(): Int { require(size >= 3) { "Expected series with at least 3 elements, but got $size elements" } - return (1 .. size - 2).count { isExtreme(this[it - 1], this[it], this[it + 1]) } + return peaks().size + troughs().size } /**