- frattyquant
**Posts:**362**Joined:**

Can anyone recommend a good numerical library for C#, I basically need random number generation, some linear algebra, distributions and basis optimization. I'm a newbie in C#, so ideally nothing too complicated. Thanks

You might have to look at a few libraries to satisfy all your requirements. For the basic linear algebra there are many options, but as you start looking for optimization libraries the choices get more tricky.Start with Math.NET Numerics, which is free and actively under development, coming out of the merger of two older projects, dnAnalytics and Math.NET. I don't think it has any optimization stuff, but has wrappers for native LA libraries like Intel's MKL. I've used this from time to time for simple linear algebra with no problems.ALGLIB which is a long-running multi-language algorithms library, with some optimization (mainly unconstrained) and a wide range of different topics. There is good and bad from its multi-language approach: it doesn't feel like a regular .NET library, but you might use the same algorithms from different languages. Certainly worth browsing around for while.A bit more specialized, but perhaps worth a look is Meta.Numerics which is strong on special functions and statistics.You might also investigate some of the commercial options, including CenterSpace NMath which has math and stats libraries, including constrained nonlinear optimization using SQP and Extreme Optimization which is a very comprehensive and prominent .NET numerical library for many years.-GovertExcel-DNA - Free and easy .NET for Excel.

Last edited by Govert on March 6th, 2011, 11:00 pm, edited 1 time in total.

- frattyquant
**Posts:**362**Joined:**

Thanks! I was considering Math.Net, and I'm going to give it a shot after your endorsement.

QuoteOriginally posted by: GovertALGLIB which is a long-running multi-language algorithms library, with some optimization (mainly unconstrained) and a wide range of different topics. There is good and bad from its multi-language approach: it doesn't feel like a regular .NET library, but you might use the same algorithms from different languages. Certainly worth browsing around for while.ALGLIB looks really interesting. I hope they open source their code generator which seems to be the key to the quality of their code base.

- shatinanalytics
**Posts:**10**Joined:**

I use NAG Fortran Mark 22 dll's in C# for all my quant tasks

- Cuchulainn
**Posts:**62608**Joined:****Location:**Amsterdam-
**Contact:**

(double post)

Last edited by Cuchulainn on March 23rd, 2011, 11:00 pm, edited 1 time in total.

Step over the gap, not into it. Watch the space between platform and train.

http://www.datasimfinancial.com

http://www.datasim.nl

http://www.datasimfinancial.com

http://www.datasim.nl

- Cuchulainn
**Posts:**62608**Joined:****Location:**Amsterdam-
**Contact:**

QuoteOriginally posted by: shatinanalyticsI use NAG Fortran Mark 22 dll's in C# for all my quant tasksI used Fortran NAG ages ago and even then it could do lots.There is no point trying to write a full blown C# numerics library. It wil take forever to reach the same maturity level. Last but not least, is there anyone around to do it?

Last edited by Cuchulainn on March 23rd, 2011, 11:00 pm, edited 1 time in total.

Step over the gap, not into it. Watch the space between platform and train.

http://www.datasimfinancial.com

http://www.datasim.nl

http://www.datasimfinancial.com

http://www.datasim.nl

I have used AlgLib for a long time for my own research in statistical arbitrage. It contains a lot of required features like linear algebra, optimization, descriptive statistics, FFT and much more. But the API of this library is not very convenient. Thus, recently I have decided to switch to FinMath. It is a commercial numerical library for .NET Framework written with emphasis on financial applications. FinMath uses Intel Math Kernel Library as a back-end for computations. It is extremely fast while providing very good and flexible object-oriented interface designed to be easily used by non-professional programmers. With FinMath I can perform principal component analysis or stepwise regression just in 1-2 lines of code! And it takes less than a second to perform such algorithms on data from whole SP500 market. Also, it's documented pretty well, all necessary information could be found on documentation page. From now on, if I need to perform quantitative research in financial it will be my first-choice.

Last edited by PavelG on December 11th, 2011, 11:00 pm, edited 1 time in total.

Readers of this thread may be interested in the Microsoft "Cloud Numerics" lab that was announced today. The "Cloud Numerics" lab is a numerical and data analytics library for data scientists, quantitative analysts, and others who write C# applications in Visual Studio. More information can be found from the link above.Disclaimer: I am a member of the Cloud Numerics team at Microsoft.

Last edited by AGatISC on January 9th, 2012, 11:00 pm, edited 1 time in total.

- chocolatemoney
**Posts:**322**Joined:**

Any experience with statfactory FCore or F# for Numerics?I am not very happy with the design of math.net - first of, the decision to have a Vector class with its weird left and right multiplication.Thanks. PS: My requirements:- quick, running on MKL. - as close as possible to matlab, with compact operators for alg. ops. and conditional slicing.- F# native, if possible

Last edited by chocolatemoney on November 21st, 2013, 11:00 pm, edited 1 time in total.

- Cuchulainn
**Posts:**62608**Joined:****Location:**Amsterdam-
**Contact:**

I have come to doubt doing serious numerics in .NET after this

Step over the gap, not into it. Watch the space between platform and train.

http://www.datasimfinancial.com

http://www.datasim.nl

http://www.datasimfinancial.com

http://www.datasim.nl

ILNumerics is a good one for a high-performance managed implementation (like C, not like tuned MKL, though) and friendly if you're coming from MATLAB.You'd have to tell us what you think about the vector multiplication, though.-GovertExcel-DNA - Free and easy .NET for Excel

- chocolatemoney
**Posts:**322**Joined:**

I just questioned the need of a Vector class. I come from the school of thoughts a vector is a 1xn or nx1 matrix, and I'd like to choose if I'd like to have a row or a col vector, and I rather have one single operator (*) that does the alg. multiplication where I take care of transposing, rather than having the library silently doing that for me if dimensionality checks fail. Sure, in math.net you can just work with matrices but then I need to sit and write down my own constructors for 1xn and nx1 matrices, which I I could do but I'd rather start from a clean sheet.ILNumerics is great, but I'd rather sacrifice some perf and avoid dealing with IL(IN/OUT)Array for the time being. I have tons of small matrices extracted from dataframes (Deedle: https://github.com/BlueMountainCapital/Deedle), hence it would be important for me to have the smallest overhead in the conversion from seq to the Matrix type

- chocolatemoney
**Posts:**322**Joined:**

[.. continues from above ..]It is very important to me to have nice slicing and conditional slicing operators.I was even considering writing an ad-hoc dataframe class wrapped around a proper matrix class, rather than shifting data back and forth to the Deedle dataframe; but I am not sure if I'll have time to do that. I need to get my algorithms done as quickly as possible.

- Cuchulainn
**Posts:**62608**Joined:****Location:**Amsterdam-
**Contact:**

Here is a list of librariesI am looking for a fast one for SVD, Householder QR, as well as orthogonal polynomials.Which one is best? Math.NET vs Alglib?? QuoteMath.NET Numerics is a linear algebra, open source library written in C#. It has a robust contributor community ensuring stable releases and healthy feature support. Math.NET is used broadly in fields from science to engineering and notably finance. Popular in financial sectors, Math.NET has a wide library of mathematical functions from linear algebra to integral transforms and probability models. You can access this library from inside your algorithms by calling it in at the top of your code!

Last edited by Cuchulainn on June 13th, 2016, 10:00 pm, edited 1 time in total.

http://www.datasimfinancial.com

http://www.datasim.nl

GZIP: On