2

I'm using Math.net and C# for simple linear regression of two double arrays (XValues, YValues) which contain physiological data. There are good grounds for constraining the intercept to the origin. At the moment I'm using:

Tuple<double, double> r = Fit.Line(XValues, YValues);
double YIntercept = r.Item1;
double Slope = r.Item2; ...etc.

Can anyone provide the code snippet to force the regression line to pass through zero. - I am not able to understand the answer provided in the only relevant question on StackOverflow

duplode
  • 33,731
  • 7
  • 79
  • 150
Andy Pybus
  • 21
  • 2

1 Answers1

2

You might want to use Fit.LineThroughOrigin, which forces the intercept to be 0

Tuple<double, double> r = Fit.LineThroughOrigin(XValues, YValues);

If what you want is the function itself, use LineThroughOriginFunc.

duplode
  • 33,731
  • 7
  • 79
  • 150