用于从记录的噪声数据中检测峰值的算法。里面有图表
所以我记录了来自 Android GPS 的一些数据,并且我试图找到这些图表的峰值,但我无法找到任何具体内容,也许是因为我不太确定我在看什么为了。我找到了一些 MatLab 函数,但找不到执行此操作的实际算法。我需要在 Java 中执行此操作,但我应该能够翻译其他语言的代码。
正如你所看到的,有很多“迷你峰”,但我只想要主要的。
So I've recorded some data from an Android GPS, and I'm trying to find the peaks of these graphs, but I haven't been able to find anything specific, perhaps because I'm not too sure what I'm looking for. I have found some MatLab functions, but I can't find the actual algorithms that do it. I need to do this in Java, but I should be able to translate code from other languages.
As you can see, there are lots of 'mini-peaks', but I just want the main ones.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您的解决方案取决于您想要对数据执行的操作。如果您想做非常严肃的事情,那么您很可能应该使用(快速)傅立叶变换,并从中提取相位和频率输出。但这需要大量的计算,并且需要很长时间来编程。 如果您只想做一些简单的事情,不需要大量的计算资源,那么这里有一个建议:
对于这个确切的问题我在几个小时前实现了以下算法。强> 我自己发明了这个算法,所以我不知道它是否已经有了名字,但它在非常嘈杂的数据上运行得很好。
您需要确定平均峰到峰距离并将其称为 PtP。随心所欲地进行测量。从你的案例中的图表来看,它似乎约为 35。在我的代码中,我发明了另一种算法来自动执行此操作。
然后在图表上选择一个随机起始索引。从那时起轮询每个新数据点,并等待图表从起始指数水平上升或下降约 70% 的 PtP。如果是跌倒的话那就是一个tock。如果是上涨,那就是一个勾号。将该水平存储为最后一个刻度或刻度高度。在此索引处生成“tick”或“tock”事件。
继续在数据中前进。在价格变动之后,如果数据在该点之后继续上升,则将该水平存储为新的“价格变动高度”,但不会产生新的价格变动事件。在 tocks 之后,如果数据在该点之后继续下降,则将该水平存储为新的“tock 深度”,但不会产生新的 tock 事件。
如果最后一个事件是时钟,则等待时钟,如果最后一个事件是时钟,则等待时钟。
每次您检测到蜱虫,那么这应该是一个峰值!祝你好运。
Your solution depends on what you want to do with the data. If you want to do very serious things then you should most likely use (Fast) Fourier Transforms, and extract both the phase and frequency output from it. But that's very computationally intensive and takes a long while to program. If you just want to do something simple that doesn't require a lot of computational resources, then here's a suggestion:
For that exact problem i implemented the below algorithm a few hours ago. I invented the algorithm myself so i do not know if it has a name already, but it is working great on very noisy data.
You need to determine the average peak-to-peak distance and call that PtP. Do that measurement any what you like. Judging from the graph in your case it appears to be about 35. In my code i have another algorithm i invented to do that automatically.
Then choose a random starting index on the graph. Poll every new datapoint from then on and wait until the graph has either risen or fallen from the starting index level by about 70% of PtP. If it was a fall then that's a tock. If it was a rise then that's a tick. Store that level as the last tick or tock height. Produce a 'tick' or 'tock' event at this index.
Continue forward in the data. After ticks, if the data continues to rise after that point then store that level as the new 'height-of-tick' but do not produce a new tick event. After tocks, if the data continues to fall after that point then store that level as the new 'depth-of-tock' but do not produce a new tock event.
If last event was a tock then wait for a tick, if last event was a tick then wait for a tock.
Each time you detect a tick, then that should be a peak! Good luck.
我认为你想要做的是通过某种低通滤波器运行它。根据您想要从该数据集中得到什么,一个简单的“棚车”过滤器可能是
充分:在每个点,取以该点为中心的 N 个样本的平均值,
并取平均值作为过滤后的值。 N 越大,过滤后的数据平滑得越积极。
I think what you want to do is run this through some sort of low-pass filter. Depending on exactly what you want to get out of this dataset, a simple "box car" filter might be
sufficient: at each point, take the average of the N samples centered on that point,
and take the average as the filtered value. The larger N is, the more aggressively smoothed the filtered data will be.
我猜你有很多点...计算它们的平均值,从所有点的值中减去它,并从每个点具有相同符号的范围中获得最高点值(负或正),直到它们改变为止。我希望我很清楚...
I guess you have lots of points... Calculate mean value of them, subtract it from all point's values and get highest point value (negative or positive) from each range where points have same sign till they change it. I hope I am clear...
对于特别讨厌和嘈杂的数据,我通常使用平滑。平滑最简单的例子是移动平均线。然后您可以在该移动平均线上找到峰值。然后,您只需返回原始数据并获取与您在移动平均值上找到的最接近的峰值即可。
With particulary nasty and noisy data I usually use smoothing. Easiest example of smoothing is moving average. Then you can find peacks on that moving average. And then you simply go back to your original data and take the closest peak to one you found on moving average.
我对峰值检测做了一些研究,我可以告诉你,如果你的数据表现不佳,它可能会扰乱你的算法。在我的脑海中,您可以尝试:选择一个阈值,即阈值= 250。如果数据高于阈值,则找到该时期的最大值。这是假设您拥有的数据的平均值约为 230。不确定您想要获得多奇特的结果。希望有帮助。
I've done some looking into peak detection and I can tell you that if your data doesn't behave, it could mess up your algorithm. Off the top of my head, you could try: Pick a threshold, i.e threshold = 250. If data is above threshold, find the max at that period. This is assuming that the data you have has a mean about 230. Not sure how fancy you want to get. Hope that helps.