Matlab,如何计算AUC(曲线下面积)? [英] Matlab, how to calculate AUC (Area Under Curve)?
问题描述
我有一个包含两列 N 行的文件 data.txt
,如下所示:
I have the file data.txt
with two columns and N rows, something like this:
0.009943796 0.4667975
0.009795735 0.46777886
0.009623984 0.46897832
0.009564759 0.46941447
0.009546991 0.4703958
0.009428543 0.47224948
0.009375241 0.47475737
0.009298249 0.4767201
[...]
文件中的每一对值对应一个点坐标 (x,y).如果绘制,这些点会生成一条曲线.我想计算这条曲线的曲线下面积 (AUC).
Every couple of values in the file correspond to one point coordinates (x,y). If plotted, this points generate a curve. I would like to calculate the area under curve (AUC) of this curve.
所以我加载数据:
data = load("data.txt");
X = data(:,1);
Y = data(:,2);
所以,X
包含点的所有 x 坐标,Y
包含所有点的 y 坐标.
So, X
contains all the x coordinates of the points, and Y
all the y coordinates.
如何计算曲线下面积 (AUC)?
How could I calculate the area under curve (AUC) ?
推荐答案
最简单的方法是梯形规则函数 trapz
.
Easiest way is the trapezoidal rule function trapz
.
如果已知您的数据是平滑的,您可以尝试使用辛普森规则,但 MATLAB 没有内置任何内容可以通过辛普森规则集成数值数据.(& 我不确定如何将它用于 x/y 数据,其中 x 不会稳定增加)
If your data is known to be smooth, you could try using Simpson's rule, but there's nothing built-in to MATLAB for integrating numerical data via Simpson's rule. (& I'm not sure how to use it for x/y data where x doesn't increase steadily)
这篇关于Matlab,如何计算AUC(曲线下面积)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!