如何使该区域在曲线下或R中不可或缺

发布于 2025-01-30 04:06:36 字数 514 浏览 3 评论 0原文

我有一个曲线作为下面的数据,我想计算x和y点所做的曲线曲线(积分)下的区域。以下方式做正确吗?我如何在特定间隔内计算曲线下的区域,而不知道曲线的功能? 我将使用重复测量的每个人使用其余数据重复此操作。另外,我需要计算曲线下的面积和第二个导数值。我应该这样做吗? 谢谢您的建议。

structure(list(x = c("76.37", "76.89", "77.36", "77.86", "78.86", 
                 "79.37", "79.87", "80.36", "80.5", "81.2"), 
           y = c("2.1", "2.29", "2.47", "2.65", "2.82", "2.99", "3.16", "3.31", "3.46", "3.5")), 
      class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,-10L))


library(pracma)
AUC = trapz(data$x,data$y)

I have a curve as the data below and I would like to calculate the area under the curve (integral) of this curve made by x and y points. Is it correct to do in the way below? and how can I calculate the area under the curve within a specific interval without knowing the function of curve?
I am going to repeat this with the rest of my data for each individual with repeated measurements. Also, I need to calculate the area under the curve for the first and second derivative values. should I do the same?
Thank you for your advice.

structure(list(x = c("76.37", "76.89", "77.36", "77.86", "78.86", 
                 "79.37", "79.87", "80.36", "80.5", "81.2"), 
           y = c("2.1", "2.29", "2.47", "2.65", "2.82", "2.99", "3.16", "3.31", "3.46", "3.5")), 
      class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,-10L))


library(pracma)
AUC = trapz(data$x,data$y)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

弃爱 2025-02-06 04:06:36

您可以使用线性插值来近似actoffun

integrate(approxfun(df$x, df$y), min(df$x), max(df$x))
13.78885 with absolute error < 0.00049

请注意,该区域的粗略近似可产生接近此数的数字。假设该区域是梯形。

prod(sapply(df, \(x)diff(range(x))))/2 + diff(range(df$x)) * min(df$y)
[1] 13.524

You could approximate the function thus use approxfun with a linear interpolation

integrate(approxfun(df$x, df$y), min(df$x), max(df$x))
13.78885 with absolute error < 0.00049

Note that a rough approximation of the area yields a number closer to this. This assumes the region is trapezoidal.

prod(sapply(df, \(x)diff(range(x))))/2 + diff(range(df$x)) * min(df$y)
[1] 13.524
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文