metanumerics Discussions Rss Feedhttp://metanumerics.codeplex.com/Thread/List.aspxmetanumerics Discussions Rss DescriptionNew Post: .NET Standard versionhttp://metanumerics.codeplex.com/discussions/660878<div style="line-height: normal;">BTW, I have an example project.json file here, allowing for simultaneous builds of .NET Standard 1.0, .NET Framework 2.0 and PCL profile 328 instances of the csmpfit library. <a href="https://github.com/cureos/csmpfit/blob/master/src/csmpfit/project.json" rel="nofollow">https://github.com/cureos/csmpfit/blob/master/src/csmpfit/project.json</a>
<br />
<br />
The project.json format is on its way out again though, and I don't know right now how the similar arrangement can be obtain with the new .csproj file format.<br />
</div>cureosThu, 26 Jan 2017 11:25:09 GMTNew Post: .NET Standard version 20170126112509ANew Post: .NET Standard versionhttp://metanumerics.codeplex.com/discussions/660878<div style="line-height: normal;">Thanks for the response, David!<br />
<br />
Targeting 1.1 rather than 1.0 might not be a big win more than from a principal point-of-view, the only additional supported platform on 1.0 is Windows Phone Silverlight 8. As far as I understand, Silverlight 5 is not supported by any .NET Standard profile, probably because its close links to .NET 4.0.<br />
<br />
BTW, moving to .NET Standard will invalidate the support for .NET Framework 4.0 as well. Do you plan to provide an additional build for .NET 4.0, or will you discard 4.0 from now on?<br />
<br />
If you want to maintain .NET 4.0 support alongside .NET Standard support, you might want to consider providing an additional PCL profile 328 build for that purpose. PCL profile 328 is the most compatible "old-school" cross platform profile, including support for .NET Framework 4.0 and Silverlight 5. The only code changes you need to make right now to build a PCL profile 328 library is to comment out (e.g. using compiler directives) the [assembly:ComVisible(false)] and [assembly:Guid(...)] attributes in AssemblyInfo.cs, and comment out the two [MethodImpl(MethodImplOptions.AggressiveInlining)] lines in RectangularMatrixAlgorithms.cs.<br />
<br />
(Of course, with a pure .NET Framework 4.0 build you don't need to make any of these changes :-) )<br />
<br />
Best regards,<br />
Anders<br />
</div>cureosThu, 26 Jan 2017 11:20:16 GMTNew Post: .NET Standard version 20170126112016ANew Post: .NET Standard versionhttp://metanumerics.codeplex.com/discussions/660878<div style="line-height: normal;">Hi Anders,
<br />
<br />
Thanks for pointing this out. I had actually picked 1.1 not because of the Guid attribute, but because the table at <a href="https://blogs.msdn.microsoft.com/dotnet/2016/09/26/introducing-net-standard/" rel="nofollow">https://blogs.msdn.microsoft.com/dotnet/2016/09/26/introducing-net-standard/</a> doesn't make clear which desktop framework would run with a 1.0 library. When release time gets closer, I will be careful to use the lowest standard version consistent with requirements. The Guid attribute is probably not a requirement, but there are a lot of hosting scenarios (SQL CLR, Windows App Store, etc.) that impose their own special requirements on assemblies, so I would need to do little more work to say that more confidently.
<br />
<br />
Do you have a particular scenario, such as a Silverlight app, that would work with a 1.0 library but not a 1.1 library?
<br />
<br />
Regards,
<br />
David
<br />
<br />
By the way: I have not forgotten your desire for local optimization to support boundary constraints!<br />
</div>ichbinWed, 25 Jan 2017 20:52:59 GMTNew Post: .NET Standard version 20170125085259PNew Post: .NET Standard versionhttp://metanumerics.codeplex.com/discussions/660878<div style="line-height: normal;">Hi ichbin,
<br />
<br />
It's really great to see that you are moving over to a more portable solution, by adopting .NET Standard.
<br />
<br />
I had a look in the latest source code commit, and I notice that you are currently targeting .NET Standard 1.1.
<br />
<br />
Are you aware that you can target .NET Standard 1.0 with one simple change in the AssemblyInfo.cs file?
<br />
<br />
If you just exclude the [assembly:Guid(...)] line, the Numerics library can be successfully built for .NET Standard 1.0.
<br />
<br />
As far as I understand this would be an acceptable change; after all, ComVisible is anyhow set to false. Or do you have other reasons for maintaining the Guid?
<br />
<br />
Thanks in advance for considering this!
<br />
<br />
Best regards,
<br />
Anders @ Cureos<br />
</div>cureosMon, 23 Jan 2017 12:39:28 GMTNew Post: .NET Standard version 20170123123928PNew Post: linear regression with 3 pointshttp://metanumerics.codeplex.com/discussions/660779<div style="line-height: normal;">Hi sdecorme,
<br />
<br />
It's quite easy to do a three-point linear regression. Here is some code:<br />
<pre><code> BivariateSample sample = new BivariateSample();
sample.Add(0, 0);
sample.Add(100, 100);
sample.Add(x, y);
LinearRegressionFitResult result = sample.LinearRegression();</code></pre>
When it returns, result will contain data about the best-fit line and goodness of fit.
<br />
<br />
If you are looking for analytic formulas for a and b as functions of x and y, you won't get that from a numerical library. But it's not hard to derive such a formula using the formulas for a and b as functions of input points that you can find in any textbook that covers linear regression.<br />
</div>ichbinThu, 19 Jan 2017 21:44:42 GMTNew Post: linear regression with 3 points 20170119094442PNew Post: linear regression with 3 pointshttp://metanumerics.codeplex.com/discussions/660779<div style="line-height: normal;">Hi,
<br />
I need to get the formula of a 3 points curves
<br />
The extrem points are fixed (0,0) and (100,100) and the middle points move from (0,0)to (100,100).
<br />
The middle point is not linear and can be anywhere between the 2 extrems points.
<br />
As input for my formula I have a value that move from 0 to 100.
<br />
On the image you can see the middle point is at X=23 and Y=5.
<br />
<img src="http://www.tiikoni.com/tis/view/?id=c834d60" alt="Image" /><br />
</div>sdecormeWed, 18 Jan 2017 14:13:26 GMTNew Post: linear regression with 3 points 20170118021326PNew Post: How to get R-square value in Polynomial Regression ?http://metanumerics.codeplex.com/discussions/642096<div style="line-height: normal;">You can get r for a BivariateSample using PearsonRTest().Statistic. Its square is the r^2 for a linear fit, which you can also get by summing the squares of the residuals dividing by n-2. The r^2 for other fits is defined by analogy and can be computed analogously: sum the squares of the residuals and divide by n minus the number of fit parameters.
<br />
<br />
In future releases, we will make it easier to get to this information.<br />
</div>ichbinSat, 24 Dec 2016 10:20:37 GMTNew Post: How to get R-square value in Polynomial Regression ? 20161224102037ANew Post: How to get R-square value in Polynomial Regression ?http://metanumerics.codeplex.com/discussions/642096<div style="line-height: normal;">First of all, Thanks for this good library.<br />
<br />
I'm using two Regressions of BivariateSample such as Linear and polynomial.<br />
I can't find where i find r-square value in FitResult class.<br />
<br />
In case of Linear, I use BivariateSample.CorrelationCoefficient * BivariateSample.CorrelationCoefficient.<br />
In case of Polynomial, Any other ways of get r-square value?<br />
</div>youngsooWed, 29 Jul 2015 06:17:18 GMTNew Post: How to get R-square value in Polynomial Regression ? 20150729061718ANew Post: Problem referencing V3.0http://metanumerics.codeplex.com/discussions/641350<div style="line-height: normal;">Hi,
<br />
<br />
I'm working with VS2008 with .NET 3.5 and I was using met.numerics 2.2 and decided to install the new metanumerics 3.0 but I have problem in referencing it, even if I browse and click to the Meta.Numerics.dll I got an error in the VS2008 reference menu :<br />
<pre><code>Meta.Numerics .NET 0.0.0.0 FALSE <impossible to find the specified reference>
</code></pre>
I had to reinstall the V2.2.0 and everything works fine again<br />
<pre><code>Meta.Numerics .NET 2.2.0.0 FALSE C:\Program Files (x86)\Meta.Numerics\Meta.Numerics.dll
</code></pre>
</div>ebortoluzziTue, 14 Jul 2015 14:07:49 GMTNew Post: Problem referencing V3.0 20150714020749PNew Post: Multiple Regressionhttp://metanumerics.codeplex.com/discussions/433264<div style="line-height: normal;">Hi,<br />
<br />
I also met a NullReference exception when calling MultivariateSample.LinearRegression, even though such exception should not be raised, according to the documentation.<br />
<br />
The cause was that one of my input variables was a constant, hence playing the same role as the intercept parameter (alpha).<br />
A consequence, in the internal implementation (LinearRegression_Internal function), is that the CholeskyDecomposition returns null, which raises the NullReference exception on the following line (which calls CholeskyDecomposition.Solve()).<br />
I guess that, more generally, having non-linearly independent input variables will lead to the same behavior.<br />
<br />
Once I found the cause, of course, it was easy to bypass the problem: just remove the constant variable from the MultivariateSample, and then retrieve its weight from the intercept.<br />
<br />
One suggestion to the team: throw a more explicit exception rather than the NullReference, and update the documentation accordingly, to quickly guide users towards a solution.<br />
<br />
Thanks,<br />
Ronan<br />
</div>RonanDannoWed, 22 Apr 2015 10:01:06 GMTNew Post: Multiple Regression 20150422100106ANew Post: SVD error NonconvergenceExceptionhttp://metanumerics.codeplex.com/discussions/468838<div style="line-height: normal;">
<div dir="ltr">Hi Merrick,
<div><br>
</div>
<div>That's a very big matrix! It takes about 117 MB of memory just to hold the contents of a 39169 X 392 matrix of doubles. The theoretical scaling of the SVD algorithm for an M X N matrix (with M >> N) is M^2 N, and scaling up from smaller test cases on my
own machine, I would expect your SVD to take about 6 hours. Perhaps less with a more performant machine, perhaps more if moving that much data in and out of active memory starts to take more time than actual computations, but that's at least the order-of-magnitude
time I would expect.<br>
<br>
It's hard for me to know whether the nonconvergence you observe is a general phenomenon that appears once input matrices get big enough, or is triggered by some very specific property of your matrix. Since getting your email, I have experimented with random
matrices up to about 4000 X 400 without seeing any nonconvergence exception. Is there any particular aspect of your problem I should try to replicate? (Very sparse matrix? Entries vary in magnitude by many orders? Entries all positive, all negative, or mixed?
Some notable pattern in the entries?) Would it be possible to actually get from you the matrix that triggers the exception? I will continue to experiment and analyze the algorithm, but your help would be appreciated.</div>
<div><br>
</div>
<div>If you are experienced with debugging, one helpful exercise would be to look at the values in the a and b arrays of the ExtractSingularValues method when the NonConvergenceException is triggered. The algorithm is trying to drive the values in the b array
to zero (at which point the values in the a array are the singular values). It would be helpful to know how close it is getting. Are the values in b all very small and getting smaller, meaning the algorithm is working but we are not giving it long enough?
Or have some NaN values appeared in either array, in which case they are likely to propagate in such a way that the algorithm will never converge?</div>
<div><br>
</div>
<div>Thanks again for the bug report!</div>
<div><br>
</div>
<div>Yours,</div>
<div>David</div>
<div></div>
<div>
<div>
<hr id="stopSpelling">
</div>
</div>
</div>
</div>ichbinFri, 03 Apr 2015 09:51:32 GMTNew Post: SVD error NonconvergenceException 20150403095132ANew Post: SVD error NonconvergenceExceptionhttp://metanumerics.codeplex.com/discussions/468838<div style="line-height: normal;">Hi,
<br />
<br />
I am using Meta.Numerics to perform matrix calculations for a NLP project that I am busy with. After running for several hours a NonconvergenceException was thrown in Meta.Numerics.Matrices.MatrixAlgorithms.ExtractSingularValues while calculating the SVD. The original matrix being used is a 39169 x 392 rectangular matrix holding doubles. Do you have any idea how I canfix/prevent this from happening?
<br />
<br />
Regards,
<br />
Merrick<br />
</div>merrickbengisWed, 01 Apr 2015 10:30:24 GMTNew Post: SVD error NonconvergenceException 20150401103024ANew Post: Distribution.FitToSamplehttp://metanumerics.codeplex.com/discussions/571508<div style="line-height: normal;">Hi
<br />
<br />
Thanks for your update!
<br />
<br />
I will download the patch for that.
<br />
<br />
Best regards<br />
</div>vafonsoWed, 11 Feb 2015 19:23:31 GMTNew Post: Distribution.FitToSample 20150211072331PNew Post: Distribution.FitToSamplehttp://metanumerics.codeplex.com/discussions/571508<div style="line-height: normal;">I have checked in a fix. The basic idea is to use the variables w = log(x) - <log(x)> instead of x, so we are no longer taking large numbers to large powers. We ended up being able to speed up the root-finding too. Thanks, this was a great bug.
<br />
<br />
Oh, and I was wrong about the fit being bad. The goodness-of-fit test indicates that the fit is fine.<br />
</div>ichbinWed, 11 Feb 2015 08:52:04 GMTNew Post: Distribution.FitToSample 20150211085204ANew Post: SVD problem with LeftTransformMatrixhttp://metanumerics.codeplex.com/discussions/572095<div style="line-height: normal;">I thank you for your replay, which of course it's correct, I was mislead by some doc in accord with "numerical recipes" 3rd edition which on par 2.6 pag 65 mention SVD as A(MxN)=U(MxN) W(NxN) V(NxN)^T without specifying any reduced format. So I learned something more thank you again<br />
</div>ebortoluzziMon, 09 Feb 2015 07:33:02 GMTNew Post: SVD problem with LeftTransformMatrix 20150209073302ANew Post: Eigenvectors - Eigenvalueshttp://metanumerics.codeplex.com/discussions/571079<div style="line-height: normal;">Suppose two eigenvectors u and v have the same eigenvalue e. Then Au = eu and Av = ev. And by linearity, A(u + v) = e(u + v), and A(u - 0.5v) = e(u - 0.5)v, and in fact A(au + bv) = e(au + bv), i.e. any linear combination of those two eigenvectors is also an eigenvector with eigenvalue e. So there is actually a two-dimensional eigen-subspace for that eigenvalue, and any two vectors that span than subspace are as good an answer as any two others for "the" eigenvectors.
<br />
<br />
I just checked by hand up to three decimal places and {v2.m, v3.m} span the same subspace as {v2.a, v3.a}.<br />
</div>ichbinMon, 09 Feb 2015 02:46:21 GMTNew Post: Eigenvectors - Eigenvalues 20150209024621ANew Post: SVD problem with LeftTransformMatrixhttp://metanumerics.codeplex.com/discussions/572095<div style="line-height: normal;">You are thinking U has the wrong dimensions because you are thinking of the reduced SVD, not the full SVD. Meta.Numerics produces the full SVD.<br />
<br />
Given an M x N matrix A, the full SVD produces A = U * S * V^T where U is M x M and orthogonal, V is N x N and orthogonal, and S is M x N and pseudo-diagonal (the upper N rows are diagonal, the remaining rows are 0). Notice that U and V are both square, S is not. This is the decomposition that we produce.<br />
<br />
The reduced SVD produces A = U' * S' * V^T where U' is M x N and S is N x N. Basically, this throws away a bunch of columns of U (so U' can no longer be said to be orthogonal) in order to make S square. It's easy to read off the reduced SVD from the full SVD: just ignore columns of U and rows of S beyond the Mth.<br />
<br />
Here is some code that fully reconstructs your matrix (as C) from its SVD:<br />
<pre><code>Dim A(,) As Double = {{-5.41, 1.0}, {-5.36, 1.0}, {-5.309, 1.0}, {-5.26, 1.0}, _
{-5.209, 1.0}, {-5.161, 1.0}, {-5.104, 1.0}, {-5.056, 1.0}, _
{-5.01, 1.0}, {-4.96, 1.0}, {-4.903, 1.0}, {-4.858, 1.0}}
Dim B As RectangularMatrix = New RectangularMatrix(A)
Dim SVD As SingularValueDecomposition = B.SingularValueDecomposition
Dim U As SquareMatrix = SVD.LeftTransformMatrix()
Dim V As SquareMatrix = SVD.RightTransformMatrix()
Dim S As RectangularMatrix = New RectangularMatrix(12, 2)
For i As Integer = 0 To SVD.Dimension - 1
S(i, i) = SVD.SingularValue(i)
Next
Dim C As RectangularMatrix = U * S * V.Transpose()</code></pre>
By the way, the Wikipedia article on the Singular Value Decomposition discusses the full vs. reduced SVD.<br />
</div>ichbinMon, 09 Feb 2015 02:19:19 GMTNew Post: SVD problem with LeftTransformMatrix 20150209021919ANew Post: Distribution.FitToSamplehttp://metanumerics.codeplex.com/discussions/571508<div style="line-height: normal;">You are right in your diagnosis. WeibullDistribution.FitToSample reduces the maximum likelihood problem to numerically finding the root of a 1D function. Part of computing this function is finding (<x^k>)^(1/k). This fails because intermediate values are (12.87)^1812 ~ 10^{2023}, which overflows a Double.
<br />
<br />
Fixing this issue would require us to work out a large-k approximation to our function and apply it in appropriate cases. I will add a bug to do this.
<br />
<br />
That said, it is very clear that a Weibull distribution is a very poor fit to this sample for any parameters. Weibull just doesn't produce values narrowly clustered around some non-zero value. <br />
</div>ichbinMon, 09 Feb 2015 01:32:07 GMTNew Post: Distribution.FitToSample 20150209013207ANew Post: FitToFunction which algorithm?http://metanumerics.codeplex.com/discussions/577393<div style="line-height: normal;">FitToFunction uses Powell's algorithm, a line search algorithm for optimizing arbitrary functions without derivatives. Levenberg-Marquardt is a great algorithm, but it requires derivatives, so to use it we would either have to ask uses to supply derivative functions or compute them numerically.<br />
</div>ichbinMon, 09 Feb 2015 00:33:21 GMTNew Post: FitToFunction which algorithm? 20150209123321ANew Post: FitToFunction which algorithm?http://metanumerics.codeplex.com/discussions/577393<div style="line-height: normal;">Hello,
<br />
<br />
have currently used your FitToFunction algorithm to fitting Fabry-Perot ringes from CCD-Chip. It works great!!! Thanks a lot for the library.
<br />
I have just one question: what for a algorithm behind it? (Levenberg-Marquardt)?
<br />
<br />
Thanks!<br />
</div>alex55Sun, 11 Jan 2015 10:30:13 GMTNew Post: FitToFunction which algorithm? 20150111103013A