本文介绍了C# - 通过二次拟合找到一个给定的宽度内的峰的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个算法来找到一个List对象峰。我已经想出了我认为是通过看一个点,它的邻国做一个很好的(或不够好)的算法,如果它是一个高峰,将它添加到结果列表中。然而,鉴于最近的一些成果,我不认为这种方法可行,以及我最初希望。 (我已经包括了代码我目前使用,并希望更换,下同)。我已经做了之前的LabView一点的工作,我知道他们的模块发现波峰/波谷的方式适用于什么,我需要做的。我做了一些研究,LabVIEW如何做到这一点,发现这样的:



Okay, so now I've been trying to do something similar in C#, however, in all my searching it seems that fitting a quadratic polynomial to data is certainly not trivial. I'd think that this problem would be one explored many, many times, but I've been unsuccessful getting a algorithm that does this well or finding a library to do it with.

Any help with this problem is greatly appreciated. Thanks.

Original/Current Code:

public static List<double> FindPeaks(List<double> values, double rangeOfPeaks)
{
    List<double> peaks = new List<double>();

    int checksOnEachSide = (int)Math.Floor(rangeOfPeaks / 2);
    for (int i = checksOnEachSide; i < values.Count - checksOnEachSide; i++)
    {
        double current = values[i];
        IEnumerable<double> window = values;
        if (i > checksOnEachSide)
            window = window.Skip(i - checksOnEachSide);
        window = window.Take((int)rangeOfPeaks);
        if (current == window.Max())
            peaks.Add(current);
    }
    return peaks;
}
解决方案

I have used Math.NET for matrix operations like this in c#. It has all the tools you might need for least squares problems such as QR decomposition or SVD. For a general overview of how to apply them I think wikipedia does quite a good job.

这篇关于C# - 通过二次拟合找到一个给定的宽度内的峰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 22:08