math.net

Math.Net system of linear equations with a 0 value in solution

南楼画角 提交于 2019-12-10 23:13:59
问题 I am trying to solve a Matrix in Math.Net when one of the actual solutions to the matrix is 0, but I am getting -NaN- as results. Here is an example matrix which has already been reduced for simplicity. 1 0 1 | 10000 0 1 -1 | 1000 0 0 0 | 0 Code example: public void DoExample() { Matrix<double> A = Matrix<double>.Build.DenseOfArray(new double[,] { { 1, 0, 1 }, { 0, 1, -1 }, { 0, 0, 0 }, }); Vector<double> B = Vector<double>.Build.Dense(new double[] { 10000, 1000, 0 }); var result = A.Solve(B)

Cross correlation using mathdotnet

房东的猫 提交于 2019-12-10 06:20:08
问题 I have recently started using Mathdotnet Numerics statistical package to do data analysis in c#. I am looking for the cross correlation function. Does Mathdotnet have an API for this? Previously I have been using MATLAB xcorr or Python numpy.correlate . So I am looking for a C# equivalent of these. I have looked through their documentation but it isn't very straightforward. https://numerics.mathdotnet.com/api/ 回答1: Correlation can be calculated by any of the methods from MathNet.Numerics

Solving system of linear equations using mathdotnet?

ぃ、小莉子 提交于 2019-12-07 02:07:17
问题 I want to solve equations like, (4-x)*2 = (y-1)*10 + 2 x = y*2 + 1 The equations are available in string form. Is there a way to express a equation in mathdotnet? I can only find ways to write expressions. 回答1: Math.NET Numerics can solve any linear system numerically, but I suppose that's not what you're looking for. Math.NET Symbolics can deal with symbolic expressions, although this project is in an early stage and does not yet understand the concept of equations. However, we can still use

How to apply a Zero-Phase filter using MathDotNet library?

为君一笑 提交于 2019-12-04 20:16:39
Is there a specific function or class in the Math.NET library to obtain a Zero-Phase (non causal) IIR filter? If not, how can this be achieved using current functions? I believe this can be obtained by filtering the signal and then filtering the reverse, but I'm not sure the result is correct. The following sample shows how to obtain a Zero-Phase filter by using the reverse-filtering technique and it also compares the result with that of a conventional lowpass filter. The signal being filtered is a 5Hz sine wave + white gaussian noise. //signal + noise double fs = 1000; //sampling rate double

How to shuffle a “DenseMatrix” in F#

ⅰ亾dé卋堺 提交于 2019-12-04 04:51:42
问题 In Matlab we can write the following code to shuffle a matrix: data = data(:, randperm(size(data,2))); there is what I write with Math.NET: let csvfile = @"../UFLDL-tutorial-F#/housing.csv" let housingAsLines = File.ReadAllLines(csvfile) |> Array.map (fun t -> t.Split(',') |> Array.map (fun t -> float t)) let housingAsMatrix= DenseMatrix.OfRowArrays housingAsLines let housingAsMatrixT = housingAsMatrix.Transpose() let v1 = DenseVector.Create(housingAsMatrixT.ColumnCount,1.0) housingAsMatrixT

How to shuffle a “DenseMatrix” in F#

南楼画角 提交于 2019-12-02 01:27:05
In Matlab we can write the following code to shuffle a matrix: data = data(:, randperm(size(data,2))); there is what I write with Math.NET: let csvfile = @"../UFLDL-tutorial-F#/housing.csv" let housingAsLines = File.ReadAllLines(csvfile) |> Array.map (fun t -> t.Split(',') |> Array.map (fun t -> float t)) let housingAsMatrix= DenseMatrix.OfRowArrays housingAsLines let housingAsMatrixT = housingAsMatrix.Transpose() let v1 = DenseVector.Create(housingAsMatrixT.ColumnCount,1.0) housingAsMatrixT.InsertRow(0,v1) // How to shuffle a "DenseMatrix" in F# To simulate matrix operation in Matlab, using

Parallel.For not utilising all cores

丶灬走出姿态 提交于 2019-12-01 14:43:52
问题 I'm doing heavy mathematical computations using Math.Net Numerics parallely inside Parallel.For block. When I run code in my local system with 4 cores(2*2), it's using all 4 cores. But when I run same code in our dev server with 8 cores(4*2), it's using only 4 cores. I've tried setting MaxDegreeOfParallism,but couldn't help. Any idea why all cores are not being utilised. Below is sample code. Parallel.For(0,10000,(i)=> { // heavy math computations using matrices }); 回答1: From MSDN By default,

How to refactor code to make it functional style?

≡放荡痞女 提交于 2019-12-01 08:58:56
Playing with F#, I'm trying to think of code in a more functional way. A large part of my work happens to be numerical in nature so I'm thinking whether this re-education makes sense. Is writing numerical code in a functional way like trying to fit a square peg in a round hole or is it simply a matter of a steep learning curve irrespective of the application? For example, lets take a snippet which demonstrates the weak law of large numbers: open System open System.IO open System.Windows.Forms open System.Windows.Forms.DataVisualization open FSharp.Data open FSharp.Charting open FSharp.Core