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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With