Problem recognizing Numerics functions


(Peter Vanderwaart) #1

I have these using statements:

using MathNet.Numerics.Statistics;
using MathNet.Numerics.Distributions;

And I have these invocations of the functions:

          var stats = Statistics.MeanStandardDeviation(tmp);
          var F = new Func<Vector<double>,int,double>((b,i) => Distributions.CDF(0.0,1.0,mx[i][0]*b[0]+mx[i][1]*b[1]+mx[i][2]*b[2]));

Visual Studio will not recognize MeanStandardDeviation without the prefix of “Statistics”. And it will not recognize CDF, or Distributions.CDF, or Numerics.Distributions.CDF at all. I’m totally stymied about using CDF.

When creating the using statement for Distributions, I type “MathNet.Numerics…” it pops up the menu from which I can choose Distributions, but it does not recognize it when I try to use it.


(Christoph Rüegg) #2

Ah, there may be some confusion about namespaces and classes. Statistics is a class within the MathNet.Numerics.Statistics namespace (docs). So even after opening the Statistics namespace, we still need to provide the Statistics class name when calling one of its static functions - unless we use a feature of the very newest C# language version where it is now possible to open a static class, such that its functions are directly available (similar to F#). However, most functions of the Statistics class are also extension methods, so you can also use the shorter tmp.MeanStandardDeviation() notation.

For CDF, there is no universal cdf function, so this won’t work. But most specific distributions provide a static CDF function, for example for the normal/gaussian distributions you can use Normal.CDF.


(Peter Vanderwaart) #3

It works. Thank you for the explanation.