如何比较两条曲线(点阵列) [英] how to compare two curves (arrays of points)

查看:130
本文介绍了如何比较两条曲线(点阵列)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个点(x,y)的数组,用这些点我可以画2条曲线.

i have 2 arrays of points (x,y), with those points I can draw 2 curves.

有人知道如何计算这些曲线的相似度吗?

Anyone have ideas how to calculate how those curves are similar?

推荐答案

您始终可以计算两条曲线之间的面积. (如果端点匹配,这会容易一些.)如果面积较小,则曲线相似,如果面积较小,则曲线不太相似.

You can always calculate the area between those two curves. (This is a bit easier if the endpoints match.) The curves are similar if the area is small, not so similar if the area is not small.

请注意,我没有定义小".那是故意的.再说一次,您没有定义相似".

Note that I did not define 'small'. That was intentional. Then again, you didn't define 'similar'.

修改
有时面积不是最佳指标.例如,考虑函数f(x)= 0和f(x)= 1e6 * sin(x).如果x的范围是2 * pi的某个整数倍,则这些曲线之间的面积为零.在正负一百万之间波动的函数并不是f(x)= 0的良好近似.

Edit
Sometimes area isn't the best metric. For example consider the function f(x)=0 and f(x)=1e6*sin(x). If the range of x is some integral multiple of 2*pi, the area between these curves is zero. A function that oscillates between plus and minus one million is not a good approximation of f(x)=0.

需要更好的指标.这是一对.注意:我在这里假设两个集合中的x值是相同的.唯一不同的是y值.

A better metric is needed. Here are a couple. Note: I am assuming here that the x values are identical in the two sets; the only things that differ are the y values.

  1. 平方和.对于每个x值,计算delta_y i = y 1,i -y 2,i 并累加delta_y i 2 .该度量是最小二乘优化的基础,最小二乘优化的目标是最小化误差平方和.这是一种广泛使用的方法,因为通常它很容易实现.

  1. Sum of squares. For each x value, compute delta_yi = y1,i - y2,i and accumulate delta_yi2. This metric is the basis for a least square optimization, where the goal is to minimize the sum of the squares of the errors. This is a widely used approach because oftentimes it is fairly easy to implement.

最大偏差.找到abs_delta_y i = | y 1,i -y 2,i | | y 1,i -y 2,i |最大化对于所有x值.此度量标准是数学库中许多功能实现的基础,其目的是最大程度地减少最大误差.这些数学库实现是true函数的近似值.作为这种近似值的使用者,我通常更关心近似值将对我的应用程序造成的最坏影响,而不是关心近似值的平均表现.

Maximum deviation. Find the abs_delta_yi = |y1,i - y2,i| that maximizes the |y1,i - y2,i| for all x values. This metric is the basis for a lot of the implementations of the functions in the math library, where the goal is to minimize the maximum error. These math library implementations are approximations of the true function. As a consumer of such an approximation, I typically care more about the worst thing that the approximation is going to do to my application than I care about how that approximation is going to behave on average.

这篇关于如何比较两条曲线(点阵列)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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