I have two double arrays (double[] XValues, YValues) which contain physiological data.
On these data I currently perform an 'unconstrained' linear regression using:
Tuple<double, double> r = Fit.Line(XValues, YValues);
double YIntercept = r.Item1;
double Slope = r.Item2;
There are sound (physiological) reasons for allowing the user to examine the line of best fit when regression through the origin is enforced.
How can this be done using MathNet?
答案 0 :(得分:1)
除了Fit.Line
之外,还有一个更通用的Fit.LinearCombination
函数。由于前者基本上试图在p0
中找到p1
和y : x -> p0 * 1.0 + p1 * x
,因此它也可以写为Fit.LinearCombination(XValues, YValues, x => 1.0, x => x)
。
您正在寻找原点的一条线,其中p0
被强制为零。因此,我们的等式简化为y : x -> p1 * x
,可以使用Fit.LinearCombination(XValues, YValues, x => x)
计算。