查找两条曲线之间的重叠区域 [英] Find area of overlap between two curves

查看:32
本文介绍了查找两条曲线之间的重叠区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力寻找解决方案来找到两条曲线之间的重叠区域.我不是在处理具有已知参数的概率密度函数,而是从经验数据点的平滑获得的曲线.

我发现的唯一提示是计算不重叠的区域(来自

这本质上是曲线之间的区域,但我需要的不是突出显示的蓝色区域,而是中间的白色区域.所以重叠区域.

我在一位数学家的博客上读到必须找到两条曲线的交点,但我在 R 中也找不到如何做到这一点.

希望有人能帮助我.

任何建议都是有帮助的.不过我提前道歉,我不是数学专家.

解决方案

这是最小值的积分:

x <- seq(-6,6,by = 0.01)y1 <- dnorm(x,0,1)y2 <- pnorm(x,1,1.1)f <- approxfun(x, pmin(y1,y2))积分(f,min(x),max(x))

I've been struggling to find a solution to find the area of overlap between two curves. I'm not dealing with probability density functions with known parameters but curves obtained from smoothing of empirical data points.

The only hint I found is to calculate the area that is not over-lapping as in this code (from here):

x <- seq(-6,6,by = 0.01)
y1 <- dnorm(x,0,1)
y2 <- pnorm(x,1,1.1)
f1 <- approxfun(x, y1-y2)
f2 <- function(z) abs(f1(z))
dif <- integrate(f2, min(x), max(x))

plot(x,y1,type="l",ylim=c(0,1))
lines(x,y2,type="l",col="red")
polygon(c(x,rev(x)),c(y1,rev(y2)), col="skyblue")

This is essentially the area between curves, but what I need is not the highlighted blue area but the white area in-between. So the area of overlap.

I was reading that one has to find the intersections of the two curves on a mathematician's blog but I cannot find how to do this in R either.

Hopefully, someone can help me out.

Any suggestions are helpful. I apologise in advance though, I'm not an expert in maths.

解决方案

This is the integral of the minimum:

x <- seq(-6,6,by = 0.01)
y1 <- dnorm(x,0,1)
y2 <- pnorm(x,1,1.1)
f <- approxfun(x, pmin(y1,y2))
integrate(f, min(x), max(x))

这篇关于查找两条曲线之间的重叠区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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