packages feed

emd 0.1.5.1 → 0.1.6.0

raw patch · 3 files changed

+46/−6 lines, 3 filesdep ~vector-sizedPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: vector-sized

API changes (from Hackage documentation)

+ Numeric.HHT: hilbertPolar :: forall v n a. (Vector v a, KnownNat n, RealFloat a) => Vector v (n + 1) a -> (Vector v (n + 1) a, Vector v (n + 1) a)

Files

CHANGELOG.md view
@@ -1,6 +1,15 @@ Changelog ========= +Version 0.1.6.0+---------------++*September 24, 2019*++<https://github.com/mstksg/emd/releases/tag/v0.1.6.0>++*   Add `hilbertPhase` to *Numeric.HHT*.+ Version 0.1.5.1 --------------- 
emd.cabal view
@@ -4,12 +4,13 @@ -- -- see: https://github.com/sol/hpack ----- hash: 6f95be4c5fda6113919d6156cb567274470a1d3ec81ea31a2efdc8efbb2b4d28+-- hash: ff41309ce78de40674bacd4a2d67e4f7be21c4e08e289bc0faff8f38d771e3fc  name:           emd-version:        0.1.5.1+version:        0.1.6.0 synopsis:       Empirical Mode Decomposition and Hilbert-Huang Transform-description:    Please see the README on GitHub at <https://github.com/mstksg/emd#readme>+description:    Empirical Mode decomposition and Hilbert-Huang Transform in pure+                Haskell. category:       Math homepage:       https://github.com/mstksg/emd#readme bug-reports:    https://github.com/mstksg/emd/issues@@ -52,7 +53,7 @@     , transformers     , typelits-witnesses     , vector-    , vector-sized+    , vector-sized >=1.4   default-language: Haskell2010  test-suite emd-test@@ -87,5 +88,5 @@     , mwc-random     , statistics     , vector-    , vector-sized+    , vector-sized >=1.4   default-language: Haskell2010
src/Numeric/HHT.hs view
@@ -47,6 +47,7 @@   -- * Hilbert transforms (internal usage)   , hilbert   , hilbertIm+  , hilbertPolar   , hilbertMagFreq   ) where @@ -281,10 +282,39 @@     -> (SVG.Vector v (n + 1) a, SVG.Vector v n a) hilbertMagFreq v = (hilbertMag, hilbertFreq)   where-    v' = hilbertIm v+    v'           = hilbertIm v     hilbertMag   = SVG.zipWith (\x x' -> magnitude (x :+ x')) v v'     hilbertPhase = SVG.zipWith (\x x' -> phase (x :+ x')) v v'     hilbertFreq  = SVG.map ((`mod'` 1) . (/ (2 * pi))) $ SVG.tail hilbertPhase - SVG.init hilbertPhase++-- | 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+hilbertPolar+    :: forall v n a. (VG.Vector v a, KnownNat n, RealFloat a)+    => SVG.Vector v (n + 1) a+    -> (SVG.Vector v (n + 1) a, SVG.Vector v (n + 1) a)+hilbertPolar v = (hilbertMag, hilbertPhase)+  where+    hilbertMag :: SVG.Vector v (n + 1) a+    hilbertFreq :: SVG.Vector v n a+    (hilbertMag, hilbertFreq) = hilbertMagFreq v+    hilbertPhase :: SVG.Vector v (n + 1) a+    hilbertPhase = SVG.scanl' (+) 0 hilbertFreq+  -- | Real part is original series and imaginary part is hilbert transformed -- series.  Creates a "helical" form of the original series that rotates