mathnetnumerics Discussions Rss Feedhttp://mathnetnumerics.codeplex.com/Thread/List.aspxmathnetnumerics Discussions Rss DescriptionNew Post: Sparse matrix performancehttp://mathnetnumerics.codeplex.com/discussions/543114<div style="line-height: normal;">I needed a fast Kronecker product for sparse matrices recently, so here's the updated code. Feel free to use ...
<br />
<br />
Source: <a href="http://wo80.bplaced.net/files/MathNet.Numerics.Extensions-src.zip" rel="nofollow">MathNet.Numerics.Extensions-src.zip</a>
<br />
<br />
Benchmark (old vs. new):<br />
<pre><code>Kronecker ( 5x 5) X (2410x2410) 5362ms 9ms OK
Kronecker ( 5x10) X (2410x2410) 5218ms 9ms OK
Kronecker (10x 5) X (2410x2410) 7279ms 9ms OK</code></pre>
</div>wo80Thu, 16 Oct 2014 13:14:14 GMTNew Post: Sparse matrix performance 20141016011414PNew Post: Mean replacement (matlab)http://mathnetnumerics.codeplex.com/discussions/569856<div style="line-height: normal;">hello togehter,
<br />
<br />
i tried a lot, but i could find any solution for the replacement of mean in matlab
<br />
for vectors and matrices.
<br />
Perhaps one of you has already a solution of a implementation of this with math.NET?
<br />
<br />
best regards,
<br />
michael<br />
</div>devil69Wed, 15 Oct 2014 14:28:47 GMTNew Post: Mean replacement (matlab) 20141015022847PNew Post: Error Message in Cholesky Factorizationhttp://mathnetnumerics.codeplex.com/discussions/568272<div style="line-height: normal;">I am trying to calculate Cholesky factorization of a sparse 320 by 320 matrix with 2424 nonzeros. I know the matrix is symmetric and positive definite (eigenvalues are spread between 0.03 and 7328.95. by the way EVD takes a long time for this relatively small matrix).
<br />
However, when I want to use Cholesky factorization, I get an error message : "Matrix must be positive definite."
<br />
Of course, the matrix is not well-conditioned but it is not also terrible. I am able to factorize matrices with larger condition number. What do you think the problem would be?
<br />
Thanks<br />
</div>burak11Wed, 24 Sep 2014 15:53:59 GMTNew Post: Error Message in Cholesky Factorization 20140924035359PNew Post: add several vectorshttps://mathnetnumerics.codeplex.com/discussions/567261<div style="line-height: normal;">Alternatively, if the vectors are very large you could try whether the following is faster:<br />
<pre><code>var result = new double[length];
foreach(var array in arrays)
{
Control.LinearAlgebraProvider.AddArrays(array, result, result);
}</code></pre>
Of course, if the vectors were actual Math.NET Numerics vectors you could do:<br />
<pre><code>var vectors = new List<Vector<double>>();
vectors.Aggregate((a, b) => a + b);</code></pre>
Thanks,<br />
Christoph<br />
</div>cdrnetSun, 21 Sep 2014 07:03:34 GMTNew Post: add several vectors 20140921070334ANew Post: StyleCophttp://mathnetnumerics.codeplex.com/discussions/561901<div style="line-height: normal;">Hi Candy,
<br />
<br />
I don't use anything beside JetBrains Resharper. To my understanding the StyleCop installer can optionally modify the Resharper configuration so that it is in line with the StyleCop rules, but I did not enabled this on my system because I personally disagree with quite a few of these rules (so I disable the rules instead).
<br />
<br />
Thanks,
<br />
Christoph<br />
</div>cdrnetSun, 21 Sep 2014 06:53:38 GMTNew Post: StyleCop 20140921065338ANew Post: add several vectorshttp://mathnetnumerics.codeplex.com/discussions/567261<div style="line-height: normal;">Assuming all of the "vectors" are the same length (if they aren't, then the result will be the same length as the shortest):<br />
<pre><code>List<double[]> lstVectors = ...;
double[] vectorSum = lstVectors.Aggregate((a,b) => a.Zip(b, (aa, bb) => aa + bb).ToArray());</code></pre>
Not the most efficient, but it ought to do the job.<br />
<br />
(For some reason the "plus" in the expression above is getting converted to the XML entity notation? But not in the editor Preview...)<br />
</div>MattHeffronFri, 19 Sep 2014 18:22:52 GMTNew Post: add several vectors 20140919062252PNew Post: Implementing Power, exponential and logarithmic function as best fit in C#http://mathnetnumerics.codeplex.com/discussions/567581<div style="line-height: normal;">Greetings,
<br />
Can somebody help me implementing following formula’s in C# for best fit?
<br />
<br />
Logarithmic Trendline
<br />
The Logarithmic trendline fits a line to ln(x), y–that is, y = a*ln(x) + b.
<br />
<br />
Exponential Trendline
<br />
The Exponential trendline fits the function y = a * e ^(b * x). This can also be computed using LinearRegression by fitting a line to x, ln(y). Taking the log of both sides of the function gives:
<br />
ln(y) = ln(a * e ^(b * x)) = ln(a) + bx
<br />
<br />
Power Trendline
<br />
The Power trendline fits the function y = a * x^b. This can be computed using LinearRegression by fitting a line to ln(x), ln(y). Taking the log of both sides of the equation gives:
<br />
ln(y) = ln(a * x^b) = ln(a) + b * ln(x)
<br />
<br />
All 3 functions can be implemented using lineair trendline.
<br />
For all 3 functions I need the: a and b factor and RSquared.
<br />
These 3 functions are common in Excell as trendline for best fit. Iám looking for a replacement for these Excel functions.
<br />
<br />
I already implemented:
<br />
Tuple<double, double> p = MathNet.Numerics.Fit.Line(xSloc, xPI)
<br />
For the normal lineair line: y = a + bx
<br />
<br />
But I don’t know how to implement the other 3 formules in MathNet.Numerics for best it.
<br />
<br />
The programming language is C#.
<br />
<br />
Thanks for a reply
<br />
<br />
Greetings
<br />
Peter Bellen
<br />
<a href="mailto:peter.bellen@12move.nl" rel="nofollow">peter.bellen@12move.nl</a><br />
</div>pbellenTue, 16 Sep 2014 15:28:27 GMTNew Post: Implementing Power, exponential and logarithmic function as best fit in C# 20140916032827PNew Post: (CubicSpline) Could I get value X from value Y?http://mathnetnumerics.codeplex.com/discussions/567275<div style="line-height: normal;">Maybe combine it with a root finder?<br />
</div>candychiuTue, 16 Sep 2014 14:09:03 GMTNew Post: (CubicSpline) Could I get value X from value Y? 20140916020903PNew Post: How do I obtain efficient addition of weighted Complex DenseMatrices? http://mathnetnumerics.codeplex.com/discussions/567450<div style="line-height: normal;">I'm trying to perform the following operation efficiently with Complex dense matrices
<br />
<br />
resultsSumMatrix = weightA x aMatrix + weightB x bMatrix
<br />
<br />
My matrices are often 2000 x 2000. I currently perform the above operation as follows, which seems slow:<br />
<pre><code>Complex[] aValues = aMatrix.Values;
Complex[] bValues = bMatrix.Values;
Complex[] resultValues = resultSumMatrix.Values;
int nValue = aValues.Length;
for (int i = 0; i < nValue; i++)
resultValues[i] = weightA*aValues[i] + weightB*bValues[i];</code></pre>
Are there any suggestions for getting faster performance? I find that writing native C++ for the above operation is tricky because CLR uses System.Numerics.Complex for complex numbers. <br />
</div>KevinMcTaggartMon, 15 Sep 2014 12:07:58 GMTNew Post: How do I obtain efficient addition of weighted Complex DenseMatrices? 20140915120758PNew Post: (CubicSpline) Could I get value X from value Y?http://mathnetnumerics.codeplex.com/discussions/567275<div style="line-height: normal;">I made a simple curve like this.<br />
<pre><code>double[] px = new double[] { 0.0, 5.0, 10.0 };
double[] py = new double[] { 0.0, 3.0, 10.0 };
CubicSpline spline1 = CubicSpline.InterpolateNatural(px, py);</code></pre>
axis-x is time, axis-y is value. and get value y coding <br />
<pre><code>double value = spline1.Interpolate(x);</code></pre>
But sometime i need to know how long the value will become specify value. And I create this<br />
<pre><code>CubicSpline spline2 = CubicSpline.InterpolateNatural(py, px);</code></pre>
Testing with these code<br />
<pre><code>Console.WriteLine(spline2.Interpolate(spline1.Interpolate(0))); // output: 0
Console.WriteLine(spline2.Interpolate(spline1.Interpolate(5))); // output: 5
Console.WriteLine(spline2.Interpolate(spline1.Interpolate(10))); // output: 10
Console.WriteLine(spline2.Interpolate(spline1.Interpolate(2.0))); // output: 1.553190912
Console.WriteLine(spline2.Interpolate(spline1.Interpolate(3.0))); // output: 2.51721969371429</code></pre>
Its correct at Key point, others are incorrect.
<br />
<br />
Is there any function i could use?<br />
</div>nomauciFri, 12 Sep 2014 16:09:24 GMTNew Post: (CubicSpline) Could I get value X from value Y? 20140912040924PNew Post: Build DenseMatrix from DenseVectorhttp://mathnetnumerics.codeplex.com/discussions/567263<div style="line-height: normal;">Dear community,
<br />
<br />
I want to build a DenseMatrix from several DenseVectors. I've been succeed but I've done via:
<br />
<br />
//delete next extra row
<br />
resultDenseMatrix = (DenseMatrix)result.SubMatrix(...);
<br />
//insert new vector
<br />
resultDenseMatrix = (DenseMatrix)result.InsertRow(...);
<br />
<br />
That seems pretty weird to me. Is there an easy way?
<br />
<br />
Thanks in advance, <br />
</div>agentDunhamFri, 12 Sep 2014 13:29:52 GMTNew Post: Build DenseMatrix from DenseVector 20140912012952PNew Post: add several vectorshttp://mathnetnumerics.codeplex.com/discussions/567261<div style="line-height: normal;">Dear community,
<br />
<br />
I'd like to know how to add in a smart way several vectors, that is,
<br />
<br />
I have a List<double[]> lstVectors, and I want to all vectors in the array and have in return another double[]. Is there anything already implemented?
<br />
<br />
Thanks in advance,<br />
</div>agentDunhamFri, 12 Sep 2014 13:23:20 GMTNew Post: add several vectors 20140912012320PNew Post: Please help me to find the correct classes and methods for this simple goodness of fit testshttps://mathnetnumerics.codeplex.com/discussions/567170<div style="line-height: normal;">Warning serious NOOB alert
<br />
<br />
Say, I have a dice that is 19 times as likely to produce a six as a one, because it has been tampered with.
<br />
When I throw this dice 60 times the expected versus observed frequencies of the six possible outcomes are:
<br />
<br />
1: 10, 1<br/>
<br />
2: 10, 10<br/>
<br />
3: 10, 10<br/>
<br />
4: 10, 10<br/>
<br />
5: 10, 10<br/>
<br />
6: 10: 19
<br />
<br />
I want to feed this expected-observed pairs to an algorithm to determine how likely it is that the dice indeed has been tampered with.
<br />
<br />
When I enter the value pairs on <a href="http://www.quantpsy.org/chisq/chisq.htm" rel="nofollow">this website</a> it calculates a Chi square value of 16.2 and a P value of 0.00629567, indicating that it is very unlikely that the observed results are in accordance with the expected distrbution of the values one to six.
<br />
<br />
I want to calculate the P value using math.net numerics, but although I can find a ChiSquared class I cannot find how to feed the expected-observed value pairs to it in order te get the P value.
<br />
<br />
How can it be done?
<br />
<br />
Thanks for you patience beforehand :-)<br />
</div>DabblerNLThu, 11 Sep 2014 19:58:39 GMTNew Post: Please help me to find the correct classes and methods for this simple goodness of fit tests 20140911075839PNew Post: Quadratic equation system solverhttp://mathnetnumerics.codeplex.com/discussions/566794<div style="line-height: normal;">Is it possible to use math.net framework to solve nonlinear equation system (4 quadratic equations, 4 variables)?<br />
<br />
Can you please give me a sample or give me a link to an existent one? I've searched the forum but I've not found any related question.<br />
<br />
Thank you in advance.<br />
</div>SimoColMon, 08 Sep 2014 14:42:58 GMTNew Post: Quadratic equation system solver 20140908024258PNew Post: Multiple Linear regression in C#http://mathnetnumerics.codeplex.com/discussions/564962<div style="line-height: normal;">I am having issues using Math.NET for Multiple Linear regression, I have 36 Independent variables and 1 dependent variable, so I am not sure how to set up the matrix to run the Linear regression. I would also like to point out that I am new to Math.Net but have been using C# for some time now. I do however use SPSS and SYSTAT daily to create regression by hand. I am looking for a way to automate this process.<br />
<br />
Thanks!<br />
<br />
A matrix that I am trying to create would be:<br />
<pre><code> var xdata = new double[,] { { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0 },
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } };
var ydata = new double[] { 5, 4, 7, 6, 6, 7
Vector<double> p = MathNet.Numerics.LinearRegression.MultipleRegression.NormalEquations(xdata, ydata);
</code></pre>
The 0,1 represent the 36 independent variables and the yData represents the dependent variables. Is this correct I cannot get it to run correctly. <br />
<br />
The line: Vector<double> p = MathNet.Numerics.LinearRegression.MultipleRegression.NormalEquations(xdata, ydata); <br />
does not seem to like the data.<br />
</div>tmorfordTue, 02 Sep 2014 14:22:48 GMTNew Post: Multiple Linear regression in C# 20140902022248PNew Post: ARMA - ARCH - GARCH Model Fittinghttp://mathnetnumerics.codeplex.com/discussions/445314<div style="line-height: normal;">Hey,
<br />
<br />
I am really wondering if you ever found a solutions for this, I am also looking to implement the GARCH model for a small project of mine and just out of interest!
<br />
<br />
Greets<br />
</div>ovanwijkWed, 27 Aug 2014 13:14:01 GMTNew Post: ARMA - ARCH - GARCH Model Fitting 20140827011401PNew Post: StyleCophttp://mathnetnumerics.codeplex.com/discussions/561901<div style="line-height: normal;">Hi, Christoph,
<br />
<br />
I'd like to ask which tool(s) do you use to bring the code to StyleCop compliant? I am working on a project which needs some standardization.<br />
<br />
Thanks for your help. Sorry for to post a non-related question.<br />
<br />
Candy<br />
</div>candychiuFri, 22 Aug 2014 20:29:02 GMTNew Post: StyleCop 20140822082902PNew Post: Is it possible to build a Slice/SubVector with shared storage?http://mathnetnumerics.codeplex.com/discussions/559981<div style="line-height: normal;">No, this is not currently possible, except with a user wrapper. How do you intend to use the resulting sub-vector? Does it need to behave like a normal vector?
<br />
<br />
Thanks,
<br />
Christoph<br />
</div>cdrnetTue, 12 Aug 2014 15:33:54 GMTNew Post: Is it possible to build a Slice/SubVector with shared storage? 20140812033354PNew Post: Using IIR for determining frequency rangehttp://mathnetnumerics.codeplex.com/discussions/560788<div style="line-height: normal;">For filtering you'd need the Math.NET Filtering library in addition to Math.NET Numerics. Note that Filtering is only available as preview release yet. Indeed, there seems to be an issue with IIR filter design, but it works with FIR filters.
<br />
<br />
Essentially you could apply several band-pass filters and then choose the frequency band where the resulting signal has the highest energy.
<br />
<br />
In LINQPad:<br />
<pre><code>void Main()
{
var sampleRate = 500; // 500 Hz sampling rate
var signal = Generate.Sinusoidal(1000,sampleRate,90,1.0); // 90 Hz sinus
BandEnergy(signal, sampleRate, 0, 25).Dump("0..25");
BandEnergy(signal, sampleRate, 25, 85).Dump("25..85");
BandEnergy(signal, sampleRate, 85, 180).Dump("85..180");
BandEnergy(signal, sampleRate, 180, 250).Dump("180..250");
}
double BandEnergy(double[] signal, double sampleRate, double lowCutoff, double highCutoff)
{
var filter = OnlineFilter.CreateBandpass(ImpulseResponse.Finite, sampleRate, lowCutoff, highCutoff);
var filtered = filter.ProcessSamples(signal);
return Vector<double>.Build.Dense(filtered).L2Norm();
}</code></pre>
returns:<br />
<pre><code>0..25
0.329663254046423
25..85
1.22288405899457
85..180
22.2095816072106
180..250
0.185562999270445 </code></pre>
Hence the dominant frequency band is 85..180 Hz, as expected for a 90 Hz sinus signal.
<br />
<br />
Thanks,
<br />
Christoph<br />
</div>cdrnetTue, 12 Aug 2014 09:27:39 GMTNew Post: Using IIR for determining frequency range 20140812092739ANew Post: Using IIR for determining frequency rangehttp://mathnetnumerics.codeplex.com/discussions/560788<div style="line-height: normal;">Hi,
<br />
I'm a total newbie in this field.
<br />
I was asked to analyze a fraction of a wav file (given timestamps) in order to find the dominant frequency (e.g. 85-180hz).
<br />
I was recommended to use IIR filtering.
<br />
can anyone lead me to to some docs/samples please?
<br />
Thanks,
<br />
udibs<br />
</div>udibsSun, 10 Aug 2014 19:46:23 GMTNew Post: Using IIR for determining frequency range 20140810074623P