mathnetnumerics Discussions Rss Feedhttp://mathnetnumerics.codeplex.com/Thread/List.aspxmathnetnumerics Discussions Rss DescriptionNew Post: RunningStatistics: Is there a way to track only a window of the last 5 samples?http://mathnetnumerics.codeplex.com/discussions/622048<div style="line-height: normal;">@bdodson thanks for your reply, it is actually expensive if running this for each user, and window of 5 was just an example, it may be a window of 100.
<br />
<br />
moving standard deviation / rolling standard deviation / sliding window is well known term. I wish Math.Net will include this method in the library, also with tests so I won't need to implement on my own and leave it to the pros.
<br />
<br />
ref:
<br />
<a href="http://matlabtricks.com/post-20/calculate-standard-deviation-case-of-sliding-window" rel="nofollow">http://matlabtricks.com/post-20/calculate-standard-deviation-case-of-sliding-window</a>
<br />
<br />
<a href="http://jonisalonen.com/2014/efficient-and-accurate-rolling-standard-deviation/" rel="nofollow">http://jonisalonen.com/2014/efficient-and-accurate-rolling-standard-deviation/</a><br />
</div>amiranonSun, 19 Apr 2015 11:04:03 GMTNew Post: RunningStatistics: Is there a way to track only a window of the last 5 samples? 20150419110403ANew Post: Numerics FFT result interpretationhttp://mathnetnumerics.codeplex.com/discussions/631552<div style="line-height: normal;">You actually have two peaks of the same magnitude, one at index 100 and one at index 900, hence 200 Hz (100 * 2 Hz).
<br />
<br />
This is expected since for real-valued signals the FT will be real-even and imagniary-odd, so there is a symmetry between positive and negative frequencies. Indeed, you'll be only interested in the positive frequencies at indices 0-500, which represent the frequencies 0-1 kHz in steps of 2 Hz (fs/N) - which is all you can represent with a 2 kHz sampling rate.
<br />
<br />
Be aware that you need to look at the magnitude of the frequency space values, not only their real value. In fact your input sample signal is odd, so the frequency space is imaginary only (the real values are all zero).<br />
</div>cdrnetSun, 19 Apr 2015 06:20:43 GMTNew Post: Numerics FFT result interpretation 20150419062043ANew Post: Numerics FFT result interpretationhttp://mathnetnumerics.codeplex.com/discussions/631552<div style="line-height: normal;">I am new to Math .net numerics and still trying to understand the FFT library. Based on the some examples, I've written following code:<br />
<pre><code> Complex[] samples = new Complex[1000];
double[] s = Generate.Sinusoidal(1000, 2000.0, 200.0, 10.0);
for (int i = 0; i < 1000; i++)
samples[i] = new Complex (s[i],0);
for (int i = 0; i < samples.Length; i++)
{
chart1.Series["Series1"].Points.AddXY
(i,samples[i].Real);
}
Fourier.Forward(samples,FourierOptions.Matlab);
for (int i = 0; i < samples.Length; i++)
{
chart2.Series["Series1"].Points.AddXY
(i, samples[i].Real);
}</code></pre>
<img src="http://i.imgur.com/YjSCa1a.png" alt="Image" />
<br />
<br />
based on my understanding of FFT, i should get impulse at 200Hz and frequency resolution should be fs/N.
<br />
But the peak is coming at 900th sample, which i'm not sure pointing to 200Hz. If my interpretation is correct?
<br />
Any help would be appreciated. Thanks in advance.<br />
</div>ragdarbariSat, 18 Apr 2015 21:22:47 GMTNew Post: Numerics FFT result interpretation 20150418092247PNew Post: RunningStatistics: Is there a way to track only a window of the last 5 samples?http://mathnetnumerics.codeplex.com/discussions/622048<div style="line-height: normal;">I (as an outside observer) can't find anything like this in the code. In principle you could write a Pop() function as long as you have the x value for the item you're removing by undoing what Push does. This doesn't work for the Minimum and Maximum properties of course (I just noticed that the RunningStatistics.Combine method doesn't handle those either even though it could).
<br />
<br />
Either way, someone would have to keep a rolling queue. If you're just tracking a window of 5 samples, it's actually not expensive at all to just recompute the statistics again with each new value (it's like 20 floating point ops I'd guess compared to maybe 5 to keep a running tally).<br />
</div>bdodsonThu, 16 Apr 2015 00:56:37 GMTNew Post: RunningStatistics: Is there a way to track only a window of the last 5 samples? 20150416125637ANew Post: RunningStatistics: Is there a way to track only a window of the last 5 samples?http://mathnetnumerics.codeplex.com/discussions/622048<div style="line-height: normal;">RunningStatistics: Is there a way to track only a window of the last 5 samples?
<br />
<br />
MathNet.Numerics.Statistics has only Push() method, there is no Pop() method.
<br />
<br />
Let's say my window size is set to 5, and I've already sampled 5 values using Push(), I would want at that point that when I sample the next (sixth) value, it would remove the first value.
<br />
<br />
Because there is no method for removing a sample from the sampled values in a running/accumulating standard deviation, I am not able to track only the last window of the whole sampled values.
<br />
<br />
that way I could use my own logic for a fixed-sized queue and would be able to keep tracking the mean, variance and std. deviation without recalculating the whole last window of samples every time I sample a new value.
<br />
<br />
If there is no "Pop" method (to remove the first value), then is there already a feature like WindowedStandardDeviation when using RunningStatistics that I'm missing?<br />
</div>amiranonSun, 12 Apr 2015 07:18:39 GMTNew Post: RunningStatistics: Is there a way to track only a window of the last 5 samples? 20150412071839ANew Post: Integrating SIMD support + Spatial codehttp://mathnetnumerics.codeplex.com/discussions/622039<div style="line-height: normal;">I was thinking of starting to integrate some SIMD support (using System.Numerics Vector<T> code) into Math.Net Numerics.
<br />
<br />
Probably the first thing I would try to do is vectorize things like DenseVector.DoAdd, DoNegate, DoSubtract, scalar multiply, dot product, etc.
<br />
<br />
I was thinking of just unrolling the loops by Vector<T>.Count and doing the actual operations using Vector<T>.
<br />
<br />
I could probably do the simple Matrix versions too (like add and subtract and other element-wise operations).
<br />
<br />
Would that be helpful? Is someone also working on that already?
<br />
<br />
<br />
I also have some spatial code that might be interesting to integrate into Math.Net - I have code for Euclidean and Projective Transforms (it uses System.Numerics). I also have an implementation of kd-tree k nearest neighbors translated from <a href="https://github.com/ethz-asl/libnabo/" rel="nofollow">https://github.com/ethz-asl/libnabo/</a> if there's interest in that (I used DenseColumnMajorMatrixStorage to represent the point clouds and query points).<br />
</div>bdodsonSun, 12 Apr 2015 02:14:25 GMTNew Post: Integrating SIMD support + Spatial code 20150412021425ANew Post: SubMatrix copyhttp://mathnetnumerics.codeplex.com/discussions/588460<div style="line-height: normal;">No concrete plans. But FFT is high on the list to work on, mainly to bring in native provider support.<br />
</div>cdrnetMon, 23 Mar 2015 19:54:24 GMTNew Post: SubMatrix copy 20150323075424PNew Post: SubMatrix copyhttp://mathnetnumerics.codeplex.com/discussions/588460<div style="line-height: normal;">I would prefer to keep it in a 2D array but maybe I should rethink this. I was not aware that DenseMatrix.OfArray(a) creates a new copy of the data and stores it in a different format.
<br />
<br />
BTW, are ther any plans to add 2D FFT support?
<br />
<br />
Thanks<br />
</div>jfraschillaMon, 23 Mar 2015 14:27:35 GMTNew Post: SubMatrix copy 20150323022735PNew Post: SubMatrix copyhttp://mathnetnumerics.codeplex.com/discussions/588460<div style="line-height: normal;">The matrix storage can also copy directly from one sub-matrix to another sub-matrix (<a href="http://numerics.mathdotnet.com/api/MathNet.Numerics.LinearAlgebra.Storage/MatrixStorage%601.htm#CopySubMatrixTo" rel="nofollow">Storage.CopySubMatrixTo</a>), so you could copy directly from A to B without extracting the 4 matrices.
<br />
<br />
It actually does use BlockCopy internally if applicable, although this does not help that much in case of sub-matrices. However, in this case you'll loose a lot already by the conversion from 2D arrays to matrices and back to 2D arrays, since dense matrices use a single (1D) column-major array internally. I assume the 2D arrays are a requirement in your scenario?<br />
</div>cdrnetSun, 22 Mar 2015 18:00:39 GMTNew Post: SubMatrix copy 20150322060039PNew Post: SubMatrix copyhttp://mathnetnumerics.codeplex.com/discussions/588460<div style="line-height: normal;">I have a matrix and I want to swap quandrant 1 with quandrant 3 and quandrant 2 with quadrant 4. For example
<br />
<br />
1 2 3
<br />
4 5 6
<br />
7 8 9
<br />
<br />
becomes
<br />
<br />
9 7 8
<br />
3 1 2
<br />
6 4 5
<br />
<br />
I can do this with the MathNet SubMatrix method as shown below. I will typically be doing this on matrices the size of 1000 x 1000. Is this the most efficient way? Is there a way to do this with BlockCopy?<br />
<pre><code>public static double[,] MatrixShift(double [,] a)
{
var matA = DenseMatrix.OfArray(a);
var N = a.GetLength(0);
var M = a.GetLength(1);
var n = (int)Math.Ceiling(N / 2.0);
var m = (int)Math.Ceiling(M / 2.0);
var A11 = matA.SubMatrix(0, n, 0, m);
var A12 = matA.SubMatrix(0, n, m, M - m);
var A21 = matA.SubMatrix(n, N - n, 0, m);
var A22 = matA.SubMatrix(n, N-n, m, M-m);
var B = new DenseMatrix(N,M);
B.SetSubMatrix(0, 0, A22);
B.SetSubMatrix(0, M - m, A21);
B.SetSubMatrix(N-n, 0, A12);
B.SetSubMatrix(N-n, M-m, A11);
return B.ToArray();
}</code></pre>
</div>jfraschillaFri, 20 Mar 2015 17:12:01 GMTNew Post: SubMatrix copy 20150320051201PNew Post: Problem in thin QR Solvehttp://mathnetnumerics.codeplex.com/discussions/432852<div style="line-height: normal;">Yes, this has been fixed roughly 2 years ago. Of course QR decompositions still require m >= n. Can you provide a repro?
<br />
<br />
Thanks,
<br />
Christoph<br />
</div>cdrnetSun, 15 Mar 2015 22:08:56 GMTNew Post: Problem in thin QR Solve 20150315100856PNew Post: Problem in thin QR Solvehttp://mathnetnumerics.codeplex.com/discussions/432852<div style="line-height: normal;">Hello there,
<br />
<br />
has this issue ever been solved? I am using the latest binaries but I get the same exception when trying to QR solve an MxN matrix (sparse or dense, full or thin method).
<br />
Thanks!<br />
</div>dgebreiterSat, 14 Mar 2015 21:16:10 GMTNew Post: Problem in thin QR Solve 20150314091610PNew Post: How to use vector with matrix to find best matchhttp://mathnetnumerics.codeplex.com/discussions/585118<div style="line-height: normal;">
<div dir="ltr">Hi,
<div><br>
</div>
<div>Thank you for your reply can you please describe me in details how I can implement my logic with this so I can get best result.</div>
<div><br>
</div>
<div><br clear="all">
<div><br>
</div>
-- <br>
<div>
<div dir="ltr"><br>
<b>Regards,<br>
Anuj Rohila<br>
ITMC SOFT (Software Engineer), <br>
</b><a href="http://www.linkedin.com/pub/anuj-rohila/35/629/376" target="_blank">Linkedin Profile</a>
<div><b>Mobile: +91-9510292597</b><br>
</div>
</div>
</div>
</div>
</div>
</div>anujrohilaTue, 10 Mar 2015 02:57:22 GMTNew Post: How to use vector with matrix to find best match 20150310025722ANew Post: How to use vector with matrix to find best matchhttp://mathnetnumerics.codeplex.com/discussions/585118<div style="line-height: normal;">This might help: <a href="http://numerics.mathdotnet.com/Matrix.html" rel="nofollow">Matrices and Vectors</a>
<br />
<br />
Thanks,
<br />
Christoph<br />
</div>cdrnetMon, 09 Mar 2015 20:28:55 GMTNew Post: How to use vector with matrix to find best match 20150309082855PNew Post: How to use vector with matrix to find best matchhttp://mathnetnumerics.codeplex.com/discussions/585118<div style="line-height: normal;">Hello,
<br />
<br />
I want to implement best match found using this Math Library to improve my search result.
<br />
<br />
I want to Implement two Matrix with m<em>n size.
<br />
<br />
First Matrix contain my Data in Integer format with m</em>n size.
<br />
Second matrix contain input values in m*1 matrix Integer values.
<br />
<br />
So I want to find best match result from First matrix based on Second matrix skip 0 values from second matrix.
<br />
<br />
So how can I Implement this I am enable to find Math.Net library document which having some example of matrix.
<br />
<br />
Please help me solve this.
<br />
<br />
I think this may be possible using Vector and SVD.
<br />
<br />
Thank you<br />
</div>anujrohilaMon, 09 Mar 2015 11:39:39 GMTNew Post: How to use vector with matrix to find best match 20150309113939ANew Post: Calculate eigenvector with relation to the smallest eigenvaluehttp://mathnetnumerics.codeplex.com/discussions/584594<div style="line-height: normal;">Hello,
<br />
<br />
I'm new to the Math.NET library, so please bear with me.
<br />
<br />
What I'm trying to do is calculate the eigenvector with relation to the smallest eigenvalue.
<br />
<br />
I have my dense 3x3 matrix calculated and called covarianceMatrix from which I'm getting the Evd object like this:<br />
<pre><code>Evd<double> eigen = covarianceMatrix.Evd(Symmetricity.Symmetric);</code></pre>
In <a href="http://numerics.mathdotnet.com/api/MathNet.Numerics.LinearAlgebra.Factorization/Evd%601.htm#EigenValues" rel="nofollow">documentation of the Evd class</a> there are two properties which should be helpful to me. According to the documentation the EigenValues property should be sorted in ascending order, so the smallest eigenvalue should be the first one.
<br />
The problem is that there is no mention of how the EigenVectors property is organized and I can't figure out how to get the correct one.
<br />
<br />
Can anybody help me with this? Or is there some other way to get the eigenvector w.r.t. smallest eigenvalue using Math.NET?
<br />
<br />
Thank you very much for any help!<br />
</div>GunlokWed, 04 Mar 2015 13:30:37 GMTNew Post: Calculate eigenvector with relation to the smallest eigenvalue 20150304013037PNew Post: Average absolute deviation?http://mathnetnumerics.codeplex.com/discussions/581581<div style="line-height: normal;">Hello,
<br />
<br />
I'm trying to compute the average absolute deviation but don't see it. I see Mean-Absolute Error in Distance but this takes two different vectors. Are there other options besides this one?
<br />
<br />
Thanks<br />
</div>hui11Mon, 23 Feb 2015 03:55:07 GMTNew Post: Average absolute deviation? 20150223035507ANew Post: syntax for armadillo into Math.nethttp://mathnetnumerics.codeplex.com/discussions/581227<div style="line-height: normal;">I don't know Armadillo well, but it sounds more like:<br />
<pre><code>Vector<double> td;
Vector<double> dda = ((td - td[0]) * 5);
dda = dda.SubVector(1,3);</code></pre>
Thanks,
<br />
Christoph<br />
</div>cdrnetTue, 17 Feb 2015 22:07:25 GMTNew Post: syntax for armadillo into Math.net 20150217100725PNew Post: syntax for armadillo into Math.nethttp://mathnetnumerics.codeplex.com/discussions/581227<div style="line-height: normal;">Hi,
<br />
I am a new to Math.Net Numerics and am struck in using the following in Math.NEt
<br />
<br />
from armadillo c++ program
<br />
rowvec td;
<br />
colvec dda = (td.st() - td(0)) * 5;<br />
dda = dda .rows(1, 4- 1);
<br />
<br />
<br />
Using Math.Net in c#
<br />
Matrix<double> td;
<br />
Matrix<double> dda = (td.Transpose() - td[0,0] * 5);
<br />
dda = dda .rows(1, 4- 1); //this line I am not able to convert may be like dda = dda[1,3] doesn't work as it returns a double
<br />
<br />
What is the best way to convert ...
<br />
Thanks,
<br />
Codeplus_vl<br />
</div>codeplus_vlTue, 17 Feb 2015 21:19:16 GMTNew Post: syntax for armadillo into Math.net 20150217091916PNew Post: Linear Interpolationhttp://mathnetnumerics.codeplex.com/discussions/580708<div style="line-height: normal;">If the "list of x values" is a Vector<T> then why not use<br />
<pre><code>Vector<T>.Map(Func<T, TU> f, Zeros zeros)</code></pre>
which will return a new Vector<TU> of the "y values"
<br />
<br />
If x values is just a List<T> or an array then use Linq:<br />
<pre><code>var yValues = xValues.Select(method.Interpolate);</code></pre>
to get an IEnumberable<T>
<br />
and add .ToList() or .ToArray() to get other result stuctures.<br />
</div>MattHeffronFri, 13 Feb 2015 18:46:56 GMTNew Post: Linear Interpolation 20150213064656P