Quantcast
Channel: Math.NET Numerics - Math.NET
Viewing all 224 articles
Browse latest View live

How can I find Math.Net Numerics Technical Theory or Referance

$
0
0

I’m working on a project and in this project I’m using in Math.Net Numerics Interpolate class.
Then, I want to learn that how can i find technical referance.
For example;
Math.Net Numerics akima spline can be found as a Hiroshi Akhima.
But the others such a cubic, normal, linear spline. Which equations can be counted as a refer to the results

1 post - 1 participant

Read full topic


Getting critical values for t-student criteria

Which is faster - SetSubMatrix vs interative copy of a column

$
0
0

Hello, just getting started with MatNET.Numerics. I am porting some Matlab code to C#.

I frequently need to copy a column of a Matrix to another Matrix (same number of rows). Making the code run fast is paramount. Is it faster to create a for loop, and copy each individual element, or should I be using SetSubMatrix()? E.g.:

for (int i = 0; i < matrixA.RowCount; ++i)
{
    matrixA.At(i, myNewCol, matrixB.At(i, myOldCol));
}

vs

matrixA.SetSubMatrix(0, myNewCol, matrixB.SubMatrix(0, matrixB.RowCount, myOldCol, 1));

Which is faster?

1 post - 1 participant

Read full topic

Equivalent functionality of Matlab sortrows()

$
0
0

Is there a MathNET.Numerics equivalent of Matlab’s sortrows(A, column), where A is a Matrix<double>?

1 post - 1 participant

Read full topic

Equivalent functionality of Matlab unique()

$
0
0

Is there a MathNET.Numerics equivalent of Matlab’s unique(A, 'rows') (or unique(A)), where A is a Matrix<double>?

1 post - 1 participant

Read full topic

Use AlmostEqual() as default EqualityComparer?

$
0
0

I am using a lot of Matrix<double> / Vector<double> structures, and need to deal with the idiosyncrasies of floating point calculations. Is there a way to use any of the AlmostEqual() methods as the default EqualityComparer and/or Comparable functionality for Math.NET Matrices/Vectors?

1 post - 1 participant

Read full topic

Using the LevenbergMarquadtMinimizer

$
0
0

I have a script in the R language which takes an equation of the following form, with inputs for the m, w, r, and q variables, and it then optimizes for the variable a using Levenberg-Marquardt optimization:
m = (((1+aw)^5+5arq)^0.2-1)/a

I’m a bit lost as to how to implement this using Math.NET, I’ve looked at the LevenbergMarquardtMinimizer and the NonLinearCurveFittingsTests but I don’t really understand how to set up the model. Admittedly the math is a bit beyond me, but I would appreciate any help!

2 posts - 2 participants

Read full topic

Mersenne Twister Thread Safe

$
0
0

Hi,

Our Monte Carlo code has been using Mersenne Twister for several years now. Thank you! I am currently in the process of modifying our C# code to run in parallel across several CPUs (currently I have changed our “for” loop to a “Parallel.For” loop). I see that Mersenne Twister has a “thread safe” option. I am interested in learning about what this means in terms of the random number sequence. Ideally we would like the same results to occur (given the same seed) if one or multiple CPUs are invoked. Will “thread safe” do this for us?

Thanks for any advice or suggestions you might have to offer.
Best regards,
Carole

2 posts - 2 participants

Read full topic


FFT Amplitude issue

$
0
0

Hi,
I try to convert simple sine wave from time domain to frequency domain.the issue is, Amplitude is not same.

here is my configuration
i am using Math.Net.numeric ver.4.12.0.0
Signal Length 1024
Sample Rate 512
Signal Frequency 10
Amplitude 1

here is my code

var points = Generate.Sinusoidal(1024, 512, 10, 1);

for (int i = 0; i < points .Length; i++)
{
chart1.Series[“Series1”].Points.AddXY
(i,points [i]);

}
Fourier.Forward(points ,FourierOptions.Default);

for (int i = 0; i < points .Length; i++)
{
chart2.Series[“Series1”].Points.AddXY
(i, points [i].Magnitude);

}

on top chart i have amplitude 1 while in bottom chart i have 16.

2 posts - 1 participant

Read full topic

1D Linear Interpolation in VB.net

$
0
0

I’m trying to recreate a curve, given with two arrays (one for x and one for y), using Math.NET with VB.net. In particular I need to rebuild this curve using 1D Linear Interpolation. I looked into numerics.mathdotnet section, but I haven’t been able to rebuild this curve. I have three input arrays: the x-points of the native curve, the y-points of the native curve and the x-points of interpolated curve. I have to create an output with the y-points of the interpolated curve. How could I do? Thanks in advance. Greetings.

1 post - 1 participant

Read full topic

How to set boundaries for interpolation / extrapolation?

$
0
0

I have the following code:

LinearSpline spline = LinearSpline.InterpolateSorted(new double[] { 0, 1, 2, 4 }, new double[] { 
-0.5, -0.5, -0.3, -0.2 });

spline.Interpolate(10);

I want to get “-0.2” as result instead of “0,099”. How can I set the right and lefts boundaries?

3 posts - 2 participants

Read full topic

Best way to grow a matrix?

$
0
0

I have a routine where I am adding an unknown amount of rows to a Matrix. What is the fastest, most efficient way to grow the Matrix? Anything better than:

Matrix<double> origDb = Matrix.Build.Dense(22, 22);
...
int additionalRows = 22;
Matrix<double> newDb = Matrix.Build.Dense(origDb.RowCount + additionalRows, origDb.ColumnCount);
newDb.SetSubMatrix(0, 0, origDb);
origDb = newDb;

?

1 post - 1 participant

Read full topic

How to use the BfgsBMinimizer and Neldermeadex class

$
0
0

I’m going to implement the following code (Python) in Math.Net:

def fun():
    #somecode
    return v

def con(args):
    x1min, x1max, x2min, x2max= args
    cons = ({'type': 'ineq', 'fun': lambda x: x[0] - x1min},
              {'type': 'ineq', 'fun': lambda x: -x[0] + x1max},
             {'type': 'ineq', 'fun': lambda x: x[1] - x2min},
                {'type': 'ineq', 'fun': lambda x: -x[1] + x2max})
    return cons

args1 = (0.5,1500,0,30)  #x1min, x1max, x2min, x2max
cons = con(args1)

x0 = np.asarray((2,1.5))

best = op.minimize(fun(), x0, constraints=cons,options={
                'maxiter': 10000,
                'maxfun': 50000
            })
print(best)

With BfgsBMinimizer, I don’t have the ‘Gradient’ function.

With Neldermeadex, I don’t know how to bound the variables.

I need some help,thx.

1 post - 1 participant

Read full topic

How to jump-start with mathnet as a novice?

$
0
0

I have a concrete problem to solve. However, I have difficulty to start with MathNet Minimization.
I learned to use the Maxtrix stuff. But the Minimization facilities baffle me.
Let me be concrete:
I have a C# method f for which I need to find a minimum. The method describes a catenary, with a few vertical loads. (so not a clean cosh-function, but an irregularly rising and decreasing one ). The signature looks like

double f(Vector v);

in which v is a 2-element vector, representing initial values (a 2D minimization). The return value must approach zero.

I understand that I must choose a minimizer (eg. NewtonMinimizer?), and have an “ObjectiveFunction”.
Questions: what is an ObjectiveFunction and why is it “Objective”?
Is it something like my f method? and how would I build one from f, if yes?
From what i descibed above, can I define a gradient function? (Some minimizers need one). Or do I need one at all?
Are there complete , commented and detailed examples to be found anywhere on the net?

1 post - 1 participant

Read full topic

TrustRegionNewtonCGMinimizer test and reference to publication

$
0
0

Can’t find tests for TrustRegionNewtonCGMinimizer. I would also appreciate a reference to the description of the method.

1 post - 1 participant

Read full topic


GRG Non Linear Solver Equivalent

$
0
0

I am looking to use Math.NET to implement the excel GRG Non Linear solver in C#. This seems to fall under the non linear optimization topic in Math.NET and I was able to find a few examples of optimization in https://github.com/mathnet/mathnet-numerics/tree/master/src/Numerics.Tests/OptimizationTests

It wasn’t clear to me if I could use this Optimization package to implement a non-linear optimization algorithm where I can supply the function (to be minimized) and the constraint function as matrices, in addition to bound constraints on the variables.

Could someone knowledgeable please clarify this point for me?

1 post - 1 participant

Read full topic

System.NotSupportedException in MathNet.Numerics.dll

$
0
0

Hi.

I have a VB .NET application where I want to use some of the MathNet functionality. I already use Fit.Curve which does work fine. Now I want to do FFT. When I use IntegralTransforms.Fourier.Forward2D() I get the System.NotSupportedException. Is there anything obvious which I missed?

1 post - 1 participant

Read full topic

What happens to memory used in Fit.Curve when MathNet.Numerics.Optimization.MaximumIterationsException

$
0
0

I have the following C# code to do a Gaussian function curve fitting. I am having out-of-memory issue when MathNet.Numerics.Optimization.MaximumIterationsException is raised.

How does Fit.Curve consume memory as it iterates up to maxIterations = 1000? what happens to those memory when MaximumIterationsException is raised. Does the calling code need to do some kind of garbage collection?

        //Define gaussian function
        var gaussian = new Func<double, double, double, double, double>((amplitude, mean, stddev, x) =>
            amplitude * Math.Exp(-0.5 * Math.Pow((x - mean), 2) / Math.Pow(stddev, 2)));


        var (finalAmplitude, finalMean, finalStdDev) = Fit.Curve(xs, ys, gaussian, initialAmplitude, initialMean, initialStdDev);

1 post - 1 participant

Read full topic

VB.NET & MathNet Linear Algebra Vector Declaration

$
0
0

Has anybody a few code lines to declar the vectors correct in VB.NET with MathNet.Numeric?
Thanks a lot, Best regards, Martini

1 post - 1 participant

Read full topic

Native dlls in Native providers packages

$
0
0

Hi,

Looking at the alpha releases of the native providers, i can’t find the actual native dlls in the package. This is true for all native providers i checked, including MKL and OpenBLAS that used to have it on former releases. Do i miss something?

1 post - 1 participant

Read full topic

Viewing all 224 articles
Browse latest View live