我有一个由Point2D
(它有两个成员,x
和y
)组成的数组,例如Point2D[] points
。你可以把这个数组看作X Y图上的一系列点。该阵列的排序方式是从较小的Point2D.X
到更大的Point2D.X
计算给定X Y系列的局部最大/最小值
我的问题很简单:您如何找到在这些点之前和之后的点(以及相应的项目索引)当地最大/最小?回想一下,本地最大/最小值在数学上被定义为dy/dx=0
。所以我的任务是我需要找到那些积分dy/dx=0
。
请注意,极端点可能或可能不在Point2D
阵列内,因为图形是平滑的曲线,而不是线性分段的折线。一个极端点可以是数组内两点的中点。例如。
是否有任何现有的库/组件已经在C#中做到这一点?
这是我的方法:
public class Point2D
{
public double X;
public double Y;
}
public class PointWithIndex
{
// the extreme point where dy/dx=0
public Point2D ExtremePoints;
// the index of the array for the point that locates right before this ExtremePoints
public int PrevItemIndex;
}
public static List<PointWithIndex> FindLocalExtrema(List<Point2D> xyPoints)
{
// the algorithm to find the max/min points of xyPoints
}
您正在寻找“峰值探测器”。 – 2012-04-12 03:10:12
这取决于您用来插入数据的平滑函数的形式......实际上,它是依赖于@DarrenEngwirda的。 – 2012-04-12 03:26:18
@DarrenEngwirda。但首先,我不知道如何以稳健的方式定义平滑函数。其次,我不知道如何从平滑函数转化为其衍生函数,而不是像C#那样真正实现的符号计算。 – Graviton 2012-04-12 03:35:20