emd-0.1.7.0: Empirical Mode Decomposition and Hilbert-Huang Transform

Numeric.HHT

Description

The main data type is HHT, which can be generated using hht or hhtEmd. See Numeric.EMD for information on why this module uses "sized vectors", and how to convert unsized vectors to sized vectors.

Since: 0.1.2.0

Synopsis

# Hilbert-Huang Transform

newtype HHT v n a Source #

A Hilbert-Huang Transform. An HHT v n a is a Hilbert-Huang transform of an n-item time series of items of type a represented using vector v.

Create using hht or hhtEmd.

Constructors

 HHT FieldshhtLines :: [HHTLine v n a]
Instances
 Eq (v a) => Eq (HHT v n a) Source # Instance detailsDefined in Numeric.HHT Methods(==) :: HHT v n a -> HHT v n a -> Bool #(/=) :: HHT v n a -> HHT v n a -> Bool # Ord (v a) => Ord (HHT v n a) Source # Instance detailsDefined in Numeric.HHT Methodscompare :: HHT v n a -> HHT v n a -> Ordering #(<) :: HHT v n a -> HHT v n a -> Bool #(<=) :: HHT v n a -> HHT v n a -> Bool #(>) :: HHT v n a -> HHT v n a -> Bool #(>=) :: HHT v n a -> HHT v n a -> Bool #max :: HHT v n a -> HHT v n a -> HHT v n a #min :: HHT v n a -> HHT v n a -> HHT v n a # Show (v a) => Show (HHT v n a) Source # Instance detailsDefined in Numeric.HHT MethodsshowsPrec :: Int -> HHT v n a -> ShowS #show :: HHT v n a -> String #showList :: [HHT v n a] -> ShowS # Generic (HHT v n a) Source # Instance detailsDefined in Numeric.HHT Associated Typestype Rep (HHT v n a) :: Type -> Type # Methodsfrom :: HHT v n a -> Rep (HHT v n a) x #to :: Rep (HHT v n a) x -> HHT v n a # (Vector v a, KnownNat n, Binary (v a)) => Binary (HHT v n a) Source # Since: 0.1.3.0 Instance detailsDefined in Numeric.HHT Methodsput :: HHT v n a -> Put #get :: Get (HHT v n a) #putList :: [HHT v n a] -> Put # NFData (v a) => NFData (HHT v n a) Source # Since: 0.1.5.0 Instance detailsDefined in Numeric.HHT Methodsrnf :: HHT v n a -> () # type Rep (HHT v n a) Source # Instance detailsDefined in Numeric.HHT type Rep (HHT v n a) = D1 (MetaData "HHT" "Numeric.HHT" "emd-0.1.7.0-inplace" True) (C1 (MetaCons "HHT" PrefixI True) (S1 (MetaSel (Just "hhtLines") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [HHTLine v n a])))

data HHTLine v n a Source #

A Hilbert Trasnform of a given IMF, given as a "skeleton line".

Constructors

 HHTLine FieldshlMags :: !(Vector v n a)IMF HHT Magnitude as a time serieshlFreqs :: !(Vector v n a)IMF HHT instantaneous frequency as a time series (between 0 and 1)
Instances
 Eq (v a) => Eq (HHTLine v n a) Source # Instance detailsDefined in Numeric.HHT Methods(==) :: HHTLine v n a -> HHTLine v n a -> Bool #(/=) :: HHTLine v n a -> HHTLine v n a -> Bool # Ord (v a) => Ord (HHTLine v n a) Source # Instance detailsDefined in Numeric.HHT Methodscompare :: HHTLine v n a -> HHTLine v n a -> Ordering #(<) :: HHTLine v n a -> HHTLine v n a -> Bool #(<=) :: HHTLine v n a -> HHTLine v n a -> Bool #(>) :: HHTLine v n a -> HHTLine v n a -> Bool #(>=) :: HHTLine v n a -> HHTLine v n a -> Bool #max :: HHTLine v n a -> HHTLine v n a -> HHTLine v n a #min :: HHTLine v n a -> HHTLine v n a -> HHTLine v n a # Show (v a) => Show (HHTLine v n a) Source # Instance detailsDefined in Numeric.HHT MethodsshowsPrec :: Int -> HHTLine v n a -> ShowS #show :: HHTLine v n a -> String #showList :: [HHTLine v n a] -> ShowS # Generic (HHTLine v n a) Source # Instance detailsDefined in Numeric.HHT Associated Typestype Rep (HHTLine v n a) :: Type -> Type # Methodsfrom :: HHTLine v n a -> Rep (HHTLine v n a) x #to :: Rep (HHTLine v n a) x -> HHTLine v n a # (Vector v a, KnownNat n, Binary (v a)) => Binary (HHTLine v n a) Source # Since: 0.1.3.0 Instance detailsDefined in Numeric.HHT Methodsput :: HHTLine v n a -> Put #get :: Get (HHTLine v n a) #putList :: [HHTLine v n a] -> Put # NFData (v a) => NFData (HHTLine v n a) Source # Since: 0.1.5.0 Instance detailsDefined in Numeric.HHT Methodsrnf :: HHTLine v n a -> () # type Rep (HHTLine v n a) Source # Instance detailsDefined in Numeric.HHT type Rep (HHTLine v n a) = D1 (MetaData "HHTLine" "Numeric.HHT" "emd-0.1.7.0-inplace" False) (C1 (MetaCons "HHTLine" PrefixI True) (S1 (MetaSel (Just "hlMags") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Vector v n a)) :*: S1 (MetaSel (Just "hlFreqs") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Vector v n a))))

hhtEmd :: forall v n a. (Vector v a, Vector v (Complex a), KnownNat n, FFTWReal a) => EMD v (n + 1) a -> HHT v n a Source #

Compute the Hilbert-Huang transform from a given Empirical Mode Decomposition.

hht :: forall v n a. (Vector v a, Vector v (Complex a), KnownNat n, FFTWReal a) => EMDOpts a -> Vector v (n + 1) a -> HHT v n a Source #

Directly compute the Hilbert-Huang transform of a given time series. Essentially is a composition of hhtEmd and emd. See hhtEmd for a more flexible version.

## Hilbert-Huang Spectrum

Arguments

 :: (Vector v a, KnownNat n, Ord k, Num a) => (a -> k) binning function. takes rev/tick freq between 0 and 1. -> HHT v n a -> Vector n (Map k a)

Compute the full Hilbert-Huang Transform spectrum. At each timestep is a sparse map of frequency components and their respective magnitudes. Frequencies not in the map are considered to be zero.

Takes a "binning" function to allow you to specify how specific you want your frequencies to be.

See hhtSparseSpetrum for a sparser version, and hhtDenseSpectrum for a denser version.

Arguments

 :: (Vector v a, KnownNat n, Ord k, Num a) => (a -> k) binning function. takes rev/tick freq between 0 and 1. -> HHT v n a -> Map (Finite n, k) a

A sparser vesion of hhtSpectrum. Compute the full Hilbert-Huang Transform spectrum. Returns a sparse matrix representing the power at each time step (the Finite n) and frequency (the k).

Takes a "binning" function to allow you to specify how specific you want your frequencies to be.

Since: 0.1.4.0

Arguments

 :: (Vector v a, KnownNat n, KnownNat m, Num a) => (a -> Finite m) binning function. takes rev/tick freq between 0 and 1. -> HHT v n a -> Vector n (Vector m a)

A denser version of hhtSpectrum. Compute the full Hilbert-Huang Transform spectrum, returning a dense matrix (as a vector of vectors) representing the power at each time step and each frequency.

Takes a "binning" function that maps a frequency to one of m discrete slots, for accumulation in the dense matrix.

Since: 0.1.4.0

## Properties of spectrum

Arguments

 :: (Vector v a, KnownNat n, Ord k, Num a) => (a -> k) binning function. takes rev/tick freq between 0 and 1. -> HHT v n a -> Map k a

Compute the marginal spectrum given a Hilbert-Huang Transform. It is similar to a Fourier Transform; it provides the "total power" over the entire time series for each frequency component.

A binning function is accepted to allow you to specify how specific you want your frequencies to be.

instantaneousEnergy :: forall v n a. (Vector v a, KnownNat n, Num a) => HHT v n a -> Vector v n a Source #

Compute the instantaneous energy of the time series at every step via the Hilbert-Huang Transform.

Arguments

 :: (Vector v a, KnownNat n, Ord k, Fractional a) => (a -> k) binning function. takes rev/tick freq between 0 and 1. -> HHT v n a -> Map k a

Degree of stationarity, as a function of frequency.

expectedFreq :: forall v n a. (Vector v a, KnownNat n, Fractional a) => HHT v n a -> Vector v n a Source #

Returns the "expected value" of frequency at each time step, calculated as a weighted average of all contributions at every frequency at that time step.

Since: 0.1.4.0

dominantFreq :: forall v n a. (Vector v a, KnownNat n, Ord a) => HHT v n a -> Vector v n a Source #

Returns the dominant frequency (frequency with largest magnitude contribution) at each time step.

Since: 0.1.4.0

## Options

data EMDOpts a Source #

Options for EMD composition.

Constructors

 EO FieldseoSiftCondition :: SiftCondition astop condition for siftingeoSplineEnd :: SplineEnd aend conditions for envelope splineseoBoundaryHandler :: Maybe BoundaryHandlerprocess for handling boundary
Instances
 Eq a => Eq (EMDOpts a) Source # Instance detailsDefined in Numeric.EMD Methods(==) :: EMDOpts a -> EMDOpts a -> Bool #(/=) :: EMDOpts a -> EMDOpts a -> Bool # Ord a => Ord (EMDOpts a) Source # Instance detailsDefined in Numeric.EMD Methodscompare :: EMDOpts a -> EMDOpts a -> Ordering #(<) :: EMDOpts a -> EMDOpts a -> Bool #(<=) :: EMDOpts a -> EMDOpts a -> Bool #(>) :: EMDOpts a -> EMDOpts a -> Bool #(>=) :: EMDOpts a -> EMDOpts a -> Bool #max :: EMDOpts a -> EMDOpts a -> EMDOpts a #min :: EMDOpts a -> EMDOpts a -> EMDOpts a # Show a => Show (EMDOpts a) Source # Instance detailsDefined in Numeric.EMD MethodsshowsPrec :: Int -> EMDOpts a -> ShowS #show :: EMDOpts a -> String #showList :: [EMDOpts a] -> ShowS # Source # Instance detailsDefined in Numeric.EMD Associated Typestype Rep (EMDOpts a) :: Type -> Type # Methodsfrom :: EMDOpts a -> Rep (EMDOpts a) x #to :: Rep (EMDOpts a) x -> EMDOpts a # Binary a => Binary (EMDOpts a) Source # Since: 0.1.3.0 Instance detailsDefined in Numeric.EMD Methodsput :: EMDOpts a -> Put #get :: Get (EMDOpts a) #putList :: [EMDOpts a] -> Put # Fractional a => Default (EMDOpts a) Source # Since: 0.1.3.0 Instance detailsDefined in Numeric.EMD Methodsdef :: EMDOpts a # type Rep (EMDOpts a) Source # Instance detailsDefined in Numeric.EMD type Rep (EMDOpts a) = D1 (MetaData "EMDOpts" "Numeric.EMD" "emd-0.1.7.0-inplace" False) (C1 (MetaCons "EO" PrefixI True) (S1 (MetaSel (Just "eoSiftCondition") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (SiftCondition a)) :*: (S1 (MetaSel (Just "eoSplineEnd") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (SplineEnd a)) :*: S1 (MetaSel (Just "eoBoundaryHandler") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe BoundaryHandler)))))

Default EMDOpts

Constructors

 BHClamp Clamp envelope at end points (Matlab implementation) BHSymmetric Extend boundaries symmetrically
Instances
 Source # Instance detailsDefined in Numeric.EMD Methods Source # Instance detailsDefined in Numeric.EMD Methods Source # Instance detailsDefined in Numeric.EMD MethodsshowList :: [BoundaryHandler] -> ShowS # Source # Instance detailsDefined in Numeric.EMD Associated Typestype Rep BoundaryHandler :: Type -> Type # Methods Source # Since: 0.1.3.0 Instance detailsDefined in Numeric.EMD MethodsputList :: [BoundaryHandler] -> Put # Source # Instance detailsDefined in Numeric.EMD type Rep BoundaryHandler = D1 (MetaData "BoundaryHandler" "Numeric.EMD" "emd-0.1.7.0-inplace" False) (C1 (MetaCons "BHClamp" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "BHSymmetric" PrefixI False) (U1 :: Type -> Type))

data SiftCondition a Source #

Stop conditions for sifting process

Data type is lazy in its fields, so this infinite data type:

nTimes n = SCTimes n SCOr nTimes (n + 1)


will be treated identically as:

nTimes = SCTimes


Constructors

 SCStdDev !a Stop using standard SD method SCTimes !Int Stop after a fixed number of sifting iterations SCOr (SiftCondition a) (SiftCondition a) One or the other SCAnd (SiftCondition a) (SiftCondition a) Stop when both conditions are met
Instances
 Eq a => Eq (SiftCondition a) Source # Instance detailsDefined in Numeric.EMD Methods(==) :: SiftCondition a -> SiftCondition a -> Bool #(/=) :: SiftCondition a -> SiftCondition a -> Bool # Ord a => Ord (SiftCondition a) Source # Instance detailsDefined in Numeric.EMD Methods(<) :: SiftCondition a -> SiftCondition a -> Bool #(<=) :: SiftCondition a -> SiftCondition a -> Bool #(>) :: SiftCondition a -> SiftCondition a -> Bool #(>=) :: SiftCondition a -> SiftCondition a -> Bool #max :: SiftCondition a -> SiftCondition a -> SiftCondition a #min :: SiftCondition a -> SiftCondition a -> SiftCondition a # Show a => Show (SiftCondition a) Source # Instance detailsDefined in Numeric.EMD MethodsshowsPrec :: Int -> SiftCondition a -> ShowS #show :: SiftCondition a -> String #showList :: [SiftCondition a] -> ShowS # Source # Instance detailsDefined in Numeric.EMD Associated Typestype Rep (SiftCondition a) :: Type -> Type # Methodsfrom :: SiftCondition a -> Rep (SiftCondition a) x #to :: Rep (SiftCondition a) x -> SiftCondition a # Binary a => Binary (SiftCondition a) Source # Since: 0.1.3.0 Instance detailsDefined in Numeric.EMD Methodsput :: SiftCondition a -> Put #get :: Get (SiftCondition a) #putList :: [SiftCondition a] -> Put # Source # Since: 0.1.3.0 Instance detailsDefined in Numeric.EMD Methods type Rep (SiftCondition a) Source # Instance detailsDefined in Numeric.EMD type Rep (SiftCondition a) = D1 (MetaData "SiftCondition" "Numeric.EMD" "emd-0.1.7.0-inplace" False) ((C1 (MetaCons "SCStdDev" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 a)) :+: C1 (MetaCons "SCTimes" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int))) :+: (C1 (MetaCons "SCOr" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (SiftCondition a)) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (SiftCondition a))) :+: C1 (MetaCons "SCAnd" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (SiftCondition a)) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (SiftCondition a)))))

Default SiftCondition

data SplineEnd a Source #

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
 Eq a => Eq (SplineEnd a) Source # Instance detailsDefined in Numeric.EMD.Internal.Spline Methods(==) :: SplineEnd a -> SplineEnd a -> Bool #(/=) :: SplineEnd a -> SplineEnd a -> Bool # Ord a => Ord (SplineEnd a) Source # Instance detailsDefined in Numeric.EMD.Internal.Spline Methodscompare :: SplineEnd a -> SplineEnd a -> Ordering #(<) :: SplineEnd a -> SplineEnd a -> Bool #(<=) :: SplineEnd a -> SplineEnd a -> Bool #(>) :: SplineEnd a -> SplineEnd a -> Bool #(>=) :: SplineEnd a -> SplineEnd a -> Bool #max :: SplineEnd a -> SplineEnd a -> SplineEnd a #min :: SplineEnd a -> SplineEnd a -> SplineEnd a # Show a => Show (SplineEnd a) Source # Instance detailsDefined in Numeric.EMD.Internal.Spline MethodsshowsPrec :: Int -> SplineEnd a -> ShowS #show :: SplineEnd a -> String #showList :: [SplineEnd a] -> ShowS # Source # Instance detailsDefined in Numeric.EMD.Internal.Spline Associated Typestype Rep (SplineEnd a) :: Type -> Type # Methodsfrom :: SplineEnd a -> Rep (SplineEnd a) x #to :: Rep (SplineEnd a) x -> SplineEnd a # Binary a => Binary (SplineEnd a) Source # Since: 0.1.3.0 Instance detailsDefined in Numeric.EMD.Internal.Spline Methodsput :: SplineEnd a -> Put #get :: Get (SplineEnd a) #putList :: [SplineEnd a] -> Put # type Rep (SplineEnd a) Source # Instance detailsDefined in Numeric.EMD.Internal.Spline type Rep (SplineEnd a) = D1 (MetaData "SplineEnd" "Numeric.EMD.Internal.Spline" "emd-0.1.7.0-inplace" 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))))

# Hilbert transforms (internal usage)

hilbert :: forall v n a. (Vector v a, Vector v (Complex a), KnownNat n, FFTWReal a) => Vector v n a -> Vector v n (Complex a) Source #

Real part is original series and imaginary part is hilbert transformed series. Creates a "helical" form of the original series that rotates along the complex plane.

Note that since 0.1.7.0, this uses the same algorithm as the matlab implementation https://www.mathworks.com/help/signal/ref/hilbert.html

hilbertIm :: forall v n a. (Vector v a, Vector v (Complex a), KnownNat n, FFTWReal a) => Vector v n a -> Vector v n a Source #

Hilbert transformed series. Essentially the same series, but phase-shifted 90 degrees. Is so-named because it is the "imaginary part" of the proper hilbert transform, hilbert.

Note that since 0.1.7.0, this uses the same algorithm as the matlab implementation https://www.mathworks.com/help/signal/ref/hilbert.html

hilbertPolar :: forall v n a. (Vector v a, Vector v (Complex a), KnownNat n, FFTWReal a) => Vector v (n + 1) a -> (Vector v (n + 1) a, Vector v (n + 1) a) Source #

The polar form of hilbert: returns the magnitude and phase of the discrete hilbert transform of a series.

The computation of magnitude is unique, but computing phase gives us some ambiguity. The interpretation of the hilbert transform for instantaneous frequency is that the original series "spirals" around the complex plane as time progresses, like a helix. So, we impose a constraint on the phase to uniquely determine it: $$\phi_{t+1}$$ is the minimal valid phase such that $$\phi_{t+1} \geq \phi_{t}$$. This enforces the phase to be monotonically increasing at the slowest possible detectable rate.

Note that this function effectively resets the initial phase to be zero, conceptually rotating hilbert to begin on the real axis.

Since: 0.1.6.0

hilbertMagFreq :: forall v n a. (Vector v a, Vector v (Complex a), KnownNat n, FFTWReal a) => Vector v (n + 1) a -> (Vector v (n + 1) a, Vector v n a) Source #

Given a time series, return a time series of the magnitude of the hilbert transform and the frequency of the hilbert transform, in units of revolutions per tick. Is only expected to taken in proper/legal IMFs.

The frequency will always be between 0 and 1, since we can't determine anything faster given the discretization, and we exclude negative values as physically unmeaningful for an IMF.