WIP: feature/emd #521

Draft
teldufalsari wants to merge 11 commits from teldufalsari/kmath:feature/emd into dev
Showing only changes of commit 47a9bf0e9a - Show all commits

View File

@ -196,16 +196,12 @@ private fun <BA> SeriesAlgebra<Double, *, BA, *>.relativeDifference(
.div(previous pow 2)
.fold(0.0) { acc, d -> acc + d } // TODO replace with Series<>.sum() method when it's implemented
private fun <T: Comparable<T>> 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<Double>.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
}
/**