Copyright | (c) Justin Le 2019 |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Numeric.EMD
Description
Empirical Mode Decomposition in pure Haskell.
Main interface is emd
, with defaultEO
. A tracing version that
outputs a log to stdout is also available, as emdTrace
. This can be
used to help track down a specific IMF that might be taking more time
than desired.
This package uses "sized vectors" as its main interface, to ensure:
- The resulting
EMD
contains IMFs that are all the same length as the input vector - We provide a vector of size of at least one.
There are many functions to convert unsized vectors to sized vectors in
Data.Vector.Sized and associated modules, including
toSized
(for when you know the size at compile-time)
and withSized
(for when you don't).
Synopsis
- emd :: forall (v :: Type -> Type) a (n :: Nat). (Vector v a, KnownNat n, Floating a, Ord a) => EMDOpts v (n + 1) a -> Vector v (n + 1) a -> EMD v (n + 1) a
- emdTrace :: forall (v :: Type -> Type) a (n :: Nat) m. (Vector v a, KnownNat n, Floating a, Ord a, MonadIO m) => EMDOpts v (n + 1) a -> Vector v (n + 1) a -> m (EMD v (n + 1) a)
- emd' :: forall (v :: Type -> Type) a (n :: Nat) m r. (Vector v a, KnownNat n, Floating a, Ord a, Applicative m) => (SiftResult v (n + 1) a -> m r) -> EMDOpts v (n + 1) a -> Vector v (n + 1) a -> m (EMD v (n + 1) a)
- iemd :: forall (v :: Type -> Type) a (n :: Nat). (Vector v a, Num a) => EMD v n a -> Vector v n a
- data EMD (v :: Type -> Type) (n :: Nat) a = EMD {
- emdIMFs :: ![Vector v n a]
- emdResidual :: !(Vector v n a)
- data EMDOpts (v :: Type -> Type) (n :: Nat) a = EO {
- eoSifter :: Sifter v n a
- eoSplineEnd :: SplineEnd a
- eoBoundaryHandler :: Maybe BoundaryHandler
- defaultEO :: forall (v :: Type -> Type) a (n :: Nat). (Vector v a, Fractional a, Ord a) => EMDOpts v n a
- data BoundaryHandler
- data Sifter (v :: Type -> Type) (n :: Nat) a
- defaultSifter :: forall (v :: Type -> Type) a (n :: Nat). (Vector v a, Fractional a, Ord a) => Sifter v n a
- data SplineEnd a
- = SENotAKnot
- | SENatural
- | SEClamped a a
- sift :: forall (v :: Type -> Type) (n :: Nat) 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
- data SiftResult (v :: Type -> Type) (n :: Nat) a
- = SRResidual !(Vector v n a)
- | SRIMF !(Vector v n a) !Int
- envelopes :: forall (v :: Type -> Type) a (n :: Nat). (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)
Empirical Mode Decomposition
emd :: forall (v :: Type -> Type) a (n :: Nat). (Vector v a, KnownNat n, Floating a, Ord a) => EMDOpts v (n + 1) a -> Vector v (n + 1) a -> EMD v (n + 1) a Source #
EMD decomposition of a given time series with a given sifting stop condition.
Takes a sized vector to ensure that:
- The resulting
EMD
contains IMFs that are all the same length as the input vector - We provide a vector of size of at least one.
emdTrace :: forall (v :: Type -> Type) a (n :: Nat) m. (Vector v a, KnownNat n, Floating a, Ord a, MonadIO m) => EMDOpts v (n + 1) a -> Vector v (n + 1) a -> m (EMD v (n + 1) a) Source #
emd
, but tracing results to stdout as IMFs are found. Useful for
debugging to see how long each step is taking.
emd' :: forall (v :: Type -> Type) a (n :: Nat) m r. (Vector v a, KnownNat n, Floating a, Ord a, Applicative m) => (SiftResult v (n + 1) a -> m r) -> EMDOpts v (n + 1) a -> Vector v (n + 1) a -> m (EMD v (n + 1) a) Source #
emd
with a callback for each found IMF.
iemd :: forall (v :: Type -> Type) a (n :: Nat). (Vector v a, Num a) => EMD v n a -> Vector v n a Source #
data EMD (v :: Type -> Type) (n :: Nat) a Source #
An
is an Empirical Mode Decomposition of a time series
with EMD
v n an
items of type a
stored in a vector v
.
The component-wise sum of emdIMFs
and emdResidual
should yield
exactly the original series (see iemd
).
Constructors
EMD | |
Fields
|
Instances
Generic (EMD v n a) Source # | |||||
Defined in Numeric.EMD Associated Types
| |||||
Show (v a) => Show (EMD v n a) Source # | |||||
(Vector v a, KnownNat n, Binary (v a)) => Binary (EMD v n a) Source # | Since: 0.1.3.0 | ||||
NFData (v a) => NFData (EMD v n a) Source # | Since: 0.1.5.0 | ||||
Defined in Numeric.EMD | |||||
Eq (v a) => Eq (EMD v n a) Source # | |||||
Ord (v a) => Ord (EMD v n a) Source # | |||||
type Rep (EMD v n a) Source # | |||||
Defined in Numeric.EMD type Rep (EMD v n a) = D1 ('MetaData "EMD" "Numeric.EMD" "emd-0.2.0.0-F9l493bwzP9Hbc3ei27y7V" 'False) (C1 ('MetaCons "EMD" 'PrefixI 'True) (S1 ('MetaSel ('Just "emdIMFs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Vector v n a]) :*: S1 ('MetaSel ('Just "emdResidual") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Vector v n a)))) |
Configuration
data EMDOpts (v :: Type -> Type) (n :: Nat) a Source #
Options for EMD composition.
Constructors
EO | |
Fields
|
Instances
defaultEO :: forall (v :: Type -> Type) a (n :: Nat). (Vector v a, Fractional a, Ord a) => EMDOpts v n a Source #
data BoundaryHandler Source #
Boundary conditions for splines.
Constructors
BHClamp | Clamp envelope at end points (Matlab implementation) |
BHSymmetric | Extend boundaries symmetrically |
Instances
Generic BoundaryHandler Source # | |||||
Defined in Numeric.EMD.Internal Associated Types
Methods from :: BoundaryHandler -> Rep BoundaryHandler x # to :: Rep BoundaryHandler x -> BoundaryHandler # | |||||
Show BoundaryHandler Source # | |||||
Defined in Numeric.EMD.Internal Methods showsPrec :: Int -> BoundaryHandler -> ShowS # show :: BoundaryHandler -> String # showList :: [BoundaryHandler] -> ShowS # | |||||
Binary BoundaryHandler Source # | Since: 0.1.3.0 | ||||
Defined in Numeric.EMD.Internal Methods put :: BoundaryHandler -> Put # get :: Get BoundaryHandler # putList :: [BoundaryHandler] -> Put # | |||||
Eq BoundaryHandler Source # | |||||
Defined in Numeric.EMD.Internal Methods (==) :: BoundaryHandler -> BoundaryHandler -> Bool # (/=) :: BoundaryHandler -> BoundaryHandler -> Bool # | |||||
Ord BoundaryHandler Source # | |||||
Defined in Numeric.EMD.Internal Methods compare :: BoundaryHandler -> BoundaryHandler -> Ordering # (<) :: BoundaryHandler -> BoundaryHandler -> Bool # (<=) :: BoundaryHandler -> BoundaryHandler -> Bool # (>) :: BoundaryHandler -> BoundaryHandler -> Bool # (>=) :: BoundaryHandler -> BoundaryHandler -> Bool # max :: BoundaryHandler -> BoundaryHandler -> BoundaryHandler # min :: BoundaryHandler -> BoundaryHandler -> BoundaryHandler # | |||||
type Rep BoundaryHandler Source # | |||||
data Sifter (v :: Type -> Type) (n :: Nat) a Source #
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
Instances
(Vector v a, Fractional a, Ord a) => Default (Sifter v n a) Source # | Since: 0.1.3.0 |
Defined in Numeric.EMD.Sift |
defaultSifter :: forall (v :: Type -> Type) a (n :: Nat). (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
End condition for spline
Constructors
SENotAKnot | "Not-a-knot" condition: third derivatives are continuous at endpoints. Default for matlab spline. |
SENatural | "Natural" condition: curve becomes a straight line at endpoints. |
SEClamped a a | "Clamped" condition: Slope of curves at endpoints are explicitly given. Since: 0.1.2.0 |
Instances
Generic (SplineEnd a) Source # | |||||
Defined in Numeric.EMD.Internal.Spline Associated Types
| |||||
Show a => Show (SplineEnd a) Source # | |||||
Binary a => Binary (SplineEnd a) Source # | Since: 0.1.3.0 | ||||
Eq a => Eq (SplineEnd a) Source # | |||||
Ord a => Ord (SplineEnd a) Source # | |||||
Defined in Numeric.EMD.Internal.Spline | |||||
type Rep (SplineEnd a) Source # | |||||
Defined in Numeric.EMD.Internal.Spline type Rep (SplineEnd a) = D1 ('MetaData "SplineEnd" "Numeric.EMD.Internal.Spline" "emd-0.2.0.0-F9l493bwzP9Hbc3ei27y7V" 'False) (C1 ('MetaCons "SENotAKnot" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "SENatural" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SEClamped" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))) |
Internal
sift :: forall (v :: Type -> Type) (n :: Nat) 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.
data SiftResult (v :: Type -> Type) (n :: Nat) a Source #
The result of a sifting operation. Each sift either yields a residual, or a new IMF.
Constructors
SRResidual !(Vector v n a) | |
SRIMF !(Vector v n a) !Int | number of sifting iterations |
envelopes :: forall (v :: Type -> Type) a (n :: Nat). (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.