简体   繁体   中英

Is there a .Net (prefer F# or C#) implementation of the Hilbert-Huang Transform?

Hilbert-Huang Transform, Empirical Mode Decomposition...

I have found it implemented in R and Matlab. I'd like to find an open source implementation of it in C#/F#/.NET.

Here's my implementation of the Hilbert transform from Matlab. I've done some comparisons with Matlab's output and this code seems to produce identical answers, but I have not done any kind of extensive testing.

This uses the publicly-available MathNet library to do the FFT/iFFT calculations.

public static Complex[] MatlabHilbert(double[] xr)
    {
        var fft = new MathNet.Numerics.IntegralTransforms.Algorithms.DiscreteFourierTransform();
        var x = (from sample in xr select new Complex(sample, 0)).ToArray();
        fft.BluesteinForward(x, FourierOptions.Default);
        var h = new double[x.Length];
        var fftLengthIsOdd = (x.Length | 1) == 1;
        if (fftLengthIsOdd)
        {
            h[0] = 1;
            for (var i = 1; i < xr.Length / 2; i++) h[i] = 2;
        }
        else
        {
            h[0] = 1;
            h[(xr.Length / 2)] = 1;
            for (var i = 1; i < xr.Length / 2; i++) h[i] = 2;
        }
        for (var i = 0; i < x.Length; i++) x[i] *= h[i];
        fft.BluesteinInverse(x, FourierOptions.Default);
        return x;
    }

The amount of quality open source numerical code for .NET is tiny. I struggled to find a decent FFT only a couple of years ago. So I seriously doubt you'll find a decent existing implementation of this algorithm because it is pretty obscure!

Your best bet is to build a Hilbert-Huang Transform in terms of an FFT (like the one from either of my F# books or the F#.NET Journal articles) which is, I guess, what you did in MATLAB and R?

I'm curious why you would want this though? It doesn't look very compelling to me...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM