WIP: feature/emd #521
@ -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
|
||||
}
|
||||
|
||||
lounres
commented
```kotlin
private fun <T : Comparable<T>> Series<T>.maxima(): List<Int> {
```
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user
I would recommend writing