使用Math.NET进行线性拟合:数据错误和拟合参数错误? [英] Linear fit with Math.NET: error in data and error in fit parameters?

查看:175
本文介绍了使用Math.NET进行线性拟合:数据错误和拟合参数错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Math.NET通过少量数据点执行简单的线性拟合.使用Fit.Line,我可以很容易地执行线性拟合并获得斜率和截距:

I am trying to use Math.NET to perform a simple linear fit through a small set of datapoints. Using Fit.Line I am very easily able to perform the linear fit and obtain the slope and intercept:

Tuple<double, double> result = Fit.Line(xdata, ydata);
var intercept = result.Item1;
var slope = result.Item2;

这很简单,但是错误呢?

This is very simple, but what about errors?

y数据中的错误

我的y数据可能包含错误栏,Math.NET可以考虑这些错误吗?在x数据中没有错误,在y数据中没有错误.

My y-data might contain error bars, can Math.NET take these errors into account? There are no errors in x-data, just in y-data.

拟合参数错误

结果拟合参数中的错误怎么办?斜率和截距应该有一个错误或至少某种方式让我知道这些参数的拟合程度.通常,我认为您会使用协方差矩阵,并且其对角线元素会给参数带来误差.我看不到有任何选择可以使用它. Math.NET能够给我合适的参数错误吗?

What about the error in the resulting fit parameters? The slope and intercept should have an error or at least some way for me to tell how good these parameters fit. Typically I think you'd use the covariance matrix and its diagonal elements would give the error in the parameters. I don't see any option to use that. Is Math.NET able to give me the fit parameter errors?

推荐答案

我想您可以使用此行来测量拟合误差:

I supouse you can use this line to measure the fit error:

GoodnessOfFit.RSquared(xdata.Select(x => a+b*x), ydata); // == 1.0

其中1表示完全"(完全在线),0表示差".

where 1 means PERFECT (exactly on the line) and 0 means POOR.

该页面上的Math.NET文档中对此进行了描述:

it is described in Math.NET documentation on that page:

Math.net-曲线拟合:线性回归

这篇关于使用Math.NET进行线性拟合:数据错误和拟合参数错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆