Latest Updates
Latest Tweets
Fork me on GitHub
Monday
Jun272011

Creating a Matrix from a list of Vectors

Feature request 5691 was implemented in commit ca95f4f7.

We've added two new static methods in the Matrix<T> class, CreateFromRows and CreateFromColumns.

Example:

 var row1 = new DenseVector(new [] { 1.0 });
 var row2 = new DenseVector(new [] { 1.0, 2.0, 3.0, 4.0 });
 var row3 = new DenseVector(new [] { 1.0, 2.0 });
 var rowVectors = new List>{row1, row2, row3 };
 var matrix = Matrix.CreateFromRows(rowVectors);

This will create a 3x4 dense matrix. The number of columns is determined by the maximum length of the given vectors (zero is used to pad short rows). Note that the storage type of the first vector determines the storage type of the matrix (i.e. a sparse vector creates a sparse matrix). CreateFromColumns works similarly.

Thursday
May122011

$50 Bug and Feature Bounties

Help us improve Math.NET Numerics. We are offering $50 bounties for finding and fixing a bug, or implementing a feature request. To claim a bug bounty, provide a unit test that demonstrates a bug and provide a fix. For a feature bounty, complete a task or feature request in the Math.NET Numerics' Issue Tracker.

Additional terms:
1) documentation or resource string typos don't count as bugs.
2) bug fixes must include a unit test that demostrates the bug.
3) all new features must include unit tests.
4) only tasks and feature requests that are added by or accepted by the Math.NET team are eligible. 
5) bounties will be paid via PayPal.
6) a maximum of 30 boutnites will be paid.
7) the Math.NET Numerics team must accept the submitted fix or feature code. The team can reject any submission for any reason.

 

Sunday
May012011

Final Beta & Start of a Competition

Two years ago, the people who developed Math.Net Iridium and dnAnalytics, both open source numerical libraries for .NET, came together with the idea of creating one great numerical library for .NET. Based on our combined experiences, we designed a new library and called it Math.Net Numerics.

During the past two years, with financial support from Microsoft Research and together with some great new developers on the team, we are on the final leg of delivering Math.Net Numerics 1.0: the last release of Math.Net Numerics beta.

The .NET platform is a good place for scientific computing. Modulo a few essential things we'd like to see in the future, e.g. integration with SIMD instructions, the .NET runtime allows us to write fairly efficient numerical code. Nonetheless, there are places where improvements should be possible and we'd like to invite you to help us out.

Starting from today, we're running a contest on writing the most efficient matrix multiplication routine in .NET. We will incorporate the best code into Math.Net Numerics before we release v1.0 of the library.  As a thanks you, the winner will receive a 1500$ prize! (The runner up will win 500$.) The contest rules and benchmark harness are up at http://gemm.codeplex.com/. We hope you enter our competition and share your insights on making the best .NET numerical code out there!

Tuesday
Apr122011

Online computation of statistics

I was recently reading a blog post by a fellow machine learner on how to efficiently compute a variance or standard deviation. Imagine we have 1GB worth of doubles for which we want to compute the standard deviation.

Since the standard deviation is defined as E[(X - E[X])2] we could compute the mean of our list of doubles, subtract it from each element in the list, and average the resulting list. The problem with this method is that not only is it numerically suboptimal to do so (recall, when the standard deviation is small, we are potentially subtracting the two very similar numbers X and E[X] = catastrophic cancellation), it is also inefficient as it requires two passes over our data.

In a little Math.Net Numerics program (get it here), I use the Statistics class to compute the standard deviation for an array of 100,000,000 doubles (that's about 800MB of data). The code is extremely simple, except for some IO code which you can find in the full source, you only need to write

var sdev = Statistics.StandardDeviation(ReadFile(sr));

Math.Net Numerics is guaranteed to only loop over your data once, as well as be numerically stable. When streaming the data from file, no extra memory is used beyond a handful of doubles for bookkeeping and the computation finishes in 57 seconds (that's streaming from my laptop's hard drive at around 13MB/sec). When reading the whole array into memory, the computation finishes in about 5 seconds (but ofcourse will consume almost 800MB of RAM).

Check out the rest of MathNet.Numerics.Statistics for methods to compute other statistics efficiently. Enjoy! -Jurgen

Saturday
Feb262011

Our first bounty

As mentioned in the last post, we are having difficulty creating an ATLAS/LAPACK library for Windows. So we posted a $1000 bounty at FOSS Factory - http://www.fossfactory.org/project/p250 .

We also created a general Math.NET Numerics project for future bounties or user posted bounties - http://www.fossfactory.org/project/p252 . If you are wondering why the ATLAS bounty wasn't posted to this project, it is because the ATLAS script will usefully to people we'll beyond Math.NET Numerics.