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 lik开发者_运维百科e 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...
精彩评论