If you are interested in robust implementation, I would suggest using GSL - it is one of the best open source numeric library that I know of in terms of functions and stability.
PS : it is pretty easy to use GSL dlls in C# with Pinvoke, ample tutorials in the internet
I've had very good results recently using ALGLIB (ALGLIB). I took their C# files, and merged them into a single file in its own namespace in a dummy NinjaTrader indicator file (in its own namespace so it can be called from strategies also). Easy to do (I didn't modify any alglib code) but I can post my file if anyone is interested, it's licensed under GPL.
The reason I started using it was to speed up things I had been doing in Matlab. I've gone through a lot of work to get NinjaTrader to call compiled Matlab functions, so that I could use Matlab functionality under the NinjaTrader backtesting/datafeed/execution framework. I wanted to avoid porting Matlab code to C#. It worked, but the process was painful on 2 fronts. First problem was getting a particular Matlab routine to work; every routine seems to have different calling conventions, and correctly building the data structures that the Matlab routines want is a painful process.
Even after they work, they are kind of slow for several reasons. Plenty fast for indicators, but I wanted faster for strategy development. I don't know what "compiled matlab" compiles into (I think it's some kind of intermediate code with a C++ wrapper around it and some dotnet interface dlls) but it's not as fast as native code. The Matlab language encourages inefficient programming practices, which is understandable, because their goal is efficient development of algorithms more than efficient execution. And another problem was that I could never make it run multi-threaded (I didn't try really hard but it appears that the Matlab engine isn't thread-safe), so I couldn't use the NT7 optimizer with multiple threads.
So even though it worked, I wasn't terribly satisfied, and I started thinking: I've gone to a heck of a lot of work to avoid porting Matlab code to C#, maybe it would be better to just bite the bullet and port some Matlab code to C# and see how that goes. So I did that this week. I used Alglib mainly for its least squares fit and matrix inverse and multiply routines, but it includes a lot more. I had to write a lot of simple "helper" routines to mimic some matlab functionality (matrix transpose, concatenate, etc). I already had the Matlab routines callable from C#, so it was easy to verify that my transcoded routines worked the same.
I'm quite happy with the results so far. I haven't done a lot of benchmarking but one of my backtests runs almost 3x faster, and there's a lot more going on the just the numerics, so the speedup of the numeric routines must be a lot more than that. That gain is multiplied because I can now run multiple threads in the optimizer, which I couldn't do at all before. So running strategies that use numerics under the NT7 optimizer is now practical for me, where it wasn't before, and that's a big win for me.
I didn't look at the DotNumerics package before I started. DotNumerics includes a lot of the helper routines that I had to write. But you have to work under their class structure. Alglib works with standard C# arrays (although the calling conventions are strange and have a learning curve, you have to pass the array sizes as parameters). Also, Alglib is an active project, whereas DotNumerics hadn't had an update since 2009.
The following 6 users say Thank You to kevind for this post: