Copyright | (c) Justin Le 2019 |
---|---|
License | BSD3 |
Maintainer | justin@jle.im |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Tools for creating your own custom sift stopping conditions.
Since: 0.2.0.0
Synopsis
- newtype Sifter v n a = Sifter {}
- data SiftResult v n a
- = SRResidual !(Vector v n a)
- | SRIMF !(Vector v n a) !Int
- data SingleSift v n a = SingleSift {}
- type SM v n a = Reader (Vector v n a)
- defaultSifter :: (Vector v a, Fractional a, Ord a) => Sifter v n a
- siftStdDev :: forall v n a. (Vector v a, Fractional a, Ord a) => a -> Sifter v n a
- siftTimes :: Int -> Sifter v n a
- siftEnergyDiff :: (Vector v a, KnownNat n, Floating a, Ord a) => a -> a -> Sifter v n a
- siftSCond :: (Vector v a, KnownNat n, Fractional a, Ord a) => Int -> Sifter v (n + 1) a
- siftAnd :: Sifter v n a -> Sifter v n a -> Sifter v n a
- siftOr :: Sifter v n a -> Sifter v n a -> Sifter v n a
- envMean :: (Vector v a, KnownNat n, Floating a) => SingleSift v n a -> SM v n a a
- energyDiff :: (Vector v a, Floating a) => SingleSift v n a -> SM v n a a
- normalizeProj :: (Vector v a, KnownNat n, Floating a) => (SingleSift v n a -> SM v n a a) -> SingleSift v n a -> SM v n a a
- siftCauchy :: (Fractional b, Ord b) => (SingleSift v n a -> b) -> b -> Sifter v n a
- siftPairs :: Ord b => (SingleSift v n a -> SingleSift v n a -> SM v n a b) -> b -> Sifter v n a
- siftProj :: Ord b => (SingleSift v n a -> SM v n a b) -> b -> Sifter v n a
- siftPairs_ :: (SingleSift v n a -> SingleSift v n a -> SM v n a Bool) -> Sifter v n a
- siftProj_ :: (SingleSift v n a -> SM v n a Bool) -> Sifter v n a
- sift :: forall v n a. (Vector v a, KnownNat n, Floating a, Ord a) => EMDOpts v (n + 1) a -> Vector v (n + 1) a -> SiftResult v (n + 1) a
- envelopes :: (Vector v a, KnownNat n, Fractional a, Ord a) => SplineEnd a -> Maybe BoundaryHandler -> Vector v (n + 1) a -> Maybe (Vector v (n + 1) a, Vector v (n + 1) a)
- rms :: (Vector v a, KnownNat n, Floating a) => Vector v n a -> a
Documentation
A sift stopping condition.
It is a Pipe
consumer that takes single sift step results upstream and
terminates with '()' as soon as it is satisfied with the latest sift
step.
Use combinators like siftOr
and siftAnd
to combine sifters, and the
various sifters in Numeric.EMD.Sift to create sifters from commonly
established ones or new ones from scratch.
Since: 0.2.0.0
data SiftResult v n a Source #
The result of a sifting operation. Each sift either yields a residual, or a new IMF.
SRResidual !(Vector v n a) | |
SRIMF !(Vector v n a) !Int | number of sifting iterations |
data SingleSift v n a Source #
Result of a single sift
type SM v n a = Reader (Vector v n a) Source #
Monad where Sifter
actions live. The reader parameter is the
"original vector".
Sifters
defaultSifter :: (Vector v a, Fractional a, Ord a) => Sifter v n a Source #
Default Sifter
defaultSifter =siftStdDev
0.3siftOr
siftTimes
50
R package uses
, Matlab uses no limitsiftTimes
20
:: (Vector v a, Fractional a, Ord a) | |
=> a | minimal threshold |
-> Sifter v n a |
Sift based on the "standard deviation test", outlined in original paper.
siftTimes :: Int -> Sifter v n a Source #
Create a sifter that stops after a given fixed number of sifts.
Useful to use alongside siftOr
to set an "upper limit" on the number
of sifts.
:: (Vector v a, KnownNat n, Floating a, Ord a) | |
=> a | Threshold for Energy Difference |
-> a | Threshold for mean envelope RMS |
-> Sifter v n a |
Cheng, Yu, Yang suggest pairing together an energy difference threshold with a threshold for mean envelope RMS. This is a convenience function to construct that pairing.
Sift based on the "S-parameter" condition: Stop after a streak n
of
almost-same numbers of zero crossings and turning points.
siftAnd :: Sifter v n a -> Sifter v n a -> Sifter v n a infixr 3 Source #
Combine two sifters in "and" fashion: The final sifter will complete when both sifters complete.
siftOr :: Sifter v n a -> Sifter v n a -> Sifter v n a infixr 2 Source #
Combine two sifters in "or" fashion: The final sifter will complete when either sifter completes.
Make Sifters
envMean :: (Vector v a, KnownNat n, Floating a) => SingleSift v n a -> SM v n a a Source #
Project the root mean square of the mean of the maximum and minimum envelopes.
energyDiff :: (Vector v a, Floating a) => SingleSift v n a -> SM v n a a Source #
Project the square root of the "Energy difference".
normalizeProj :: (Vector v a, KnownNat n, Floating a) => (SingleSift v n a -> SM v n a a) -> SingleSift v n a -> SM v n a a Source #
Given a "projection function" (like envMean
or energyDiff
),
re-scale the result based on the RMS of the original signal.
:: (Fractional b, Ord b) | |
=> (SingleSift v n a -> b) | Projection function |
-> b | Threshold \(\delta\) |
-> Sifter v n a |
General class of "cauchy-like" sifters: Given a projection function
from a SingleSift
, stop as soon as successive projections become
smaller than a given threshold, propertionally.
Given \(f(x_t)\), stop when:
\[ \frac{(f(x_t) - f(x_{t-1}))^2}{f^2(x_{t-1})} < \delta \]
siftPairs :: Ord b => (SingleSift v n a -> SingleSift v n a -> SM v n a b) -> b -> Sifter v n a Source #
Create a sifter that stops when some projection on two consecutive
SingleSift
s is smaller than a given threshold.
:: Ord b | |
=> (SingleSift v n a -> SM v n a b) | projection |
-> b | threshold |
-> Sifter v n a |
Create a sifter that stops when some projection on SingleSift
is
smaller than a given threshold.
siftPairs_ :: (SingleSift v n a -> SingleSift v n a -> SM v n a Bool) -> Sifter v n a Source #
Create a sifter that stops based on some predicate on two consecutive
SingleSift
s being True
.
siftProj_ :: (SingleSift v n a -> SM v n a Bool) -> Sifter v n a Source #
Create a sifter that stops based on some predicate on the initial
vector and SingleSift
being True
.
Internal
sift :: forall v n a. (Vector v a, KnownNat n, Floating a, Ord a) => EMDOpts v (n + 1) a -> Vector v (n + 1) a -> SiftResult v (n + 1) a Source #
Iterated sifting process, used to produce either an IMF or a residual.
envelopes :: (Vector v a, KnownNat n, Fractional a, Ord a) => SplineEnd a -> Maybe BoundaryHandler -> Vector v (n + 1) a -> Maybe (Vector v (n + 1) a, Vector v (n + 1) a) Source #
Returns cubic splines of local minimums and maximums. Returns
Nothing
if there are not enough local minimum or maximums to create
the splines.
rms :: (Vector v a, KnownNat n, Floating a) => Vector v n a -> a Source #
Get the root mean square of a vector