2

I have a set of (Xi,Yi) point that should be fitted by 3rd degree polynomial function that pass through zero.

I consider to use MathNet.Numerics for this task, but I don't see in the documentation an option to force the fitted function to pass through origin. If this option is not supported, please suggest a solution that uses functions included in latest release of MathNet.Numerics.

atrash
  • 865
  • 1
  • 8
  • 11

1 Answers1

1

I would assume you know that this is how you would fit some data in Math.Net

Func<Double, Double> MyFunc = Fit.PolynomialFunc(xDataArr, yDataArr, 3);

As for forcing it through the origin I have never seen an option for that. I think the only real solution is to put the point (0, 0) into your data set and hope for the best?.

Something you can try that doesn't really make mathematical sense at all is to put the point (0, 0) in your data set multiple times.

KDecker
  • 6,928
  • 8
  • 40
  • 81
  • Thanks for the fast reply. Fit data with Math.Net is straightforward. Adding (0,0) to the data is not equivalent to constrain the plot to pass through (0,0). I just wonder if I can workaround this limitation within the current version. – atrash Apr 27 '16 at 12:39
  • I have been through `Fit` a few times I have never seen something to allow such a constraint. And yes I understand that adding `(0, 0)` to the data does not strictly constrain it. // Another option you might have is to get the function coefficients instead of the `Func` and then modify the coefficients to your needs? – KDecker Apr 27 '16 at 12:42
  • Pass through origin is equivalent to "Set Intercept=0" in Excel. Here are two ways to solve this problem with Matlab: http://www.mathworks.com/matlabcentral/answers/94272-how-do-i-constrain-a-fitted-curve-through-specific-points-like-the-origin-in-matlab http://www.mathworks.com/matlabcentral/fileexchange/35401-polyfitzero – atrash Apr 27 '16 at 13:11