对NaN值使用指数平滑 [英] Using exponential smoothing with NaN values
问题描述
我有一个样本,可以产生一些嘈杂的输出.该样本是来自相机的某些图像处理的结果,该图像指示某种颜色的斑点的航向.它是从-45°左右的角度到+ 45°,或 a NaN
,这意味着该斑点实际上不在视野中.
I have a sample of some kind that can create somewhat noisy output. The sample is the result of some image processing from a camera, which indicates the heading of a blob of a certain color. It is an angle from around -45° to +45°, or a NaN
, which means that the blob is not actually in view.
为了处理嘈杂的数据,我认为指数平滑可以解决问题.但是,我不确定如何处理NaN
值.
In order to combat the noisy data, I felt that exponential smoothing would do the trick. However, I'm not sure how to handle the NaN
values.
一方面,让他们参与数学运算将得出NaN
平均值,这将防止任何有意义的结果.另一方面,完全忽略NaN
值将意味着永远不会报告未检测到"情况.只是使事情复杂化,数据也很嘈杂,因为它可能会得到错误的NaN
值,理想情况下会以某种方式对其进行平滑处理以防止出现随机噪声.
On the one hand, involving them in the math would result in a NaN
average, which would then prevent any meaningful results. On the other hand, ignoring NaN
values completely would mean that a "no-detection" scenario would never be reported. And just to complicate things, the data is also noisy in that it can get false NaN
value, which ideally would be smoothed somehow to prevent random noise.
关于如何实现这样的指数平滑器的任何想法吗?
Any ideas about how I could implement such an exponential smoother?
推荐答案
如何保留两个分布?第一个可以像平常一样是您平滑的Blob标题,除非您获得NaN,而是输入最后看到的非NaN值(或其他一些默认值);另一个是"NaN分布",它仅对每个非NaN值获取0,对每个NaN(或类似值)获取1.
How about keeping two distributions? The first one can be your smoothed blob heading as usual, except if you get a NaN you instead just enter whatever the last seen non-NaN value was (or some other default); the other is a "NaN-distribution", which simply gets a 0 for every non-NaN value and 1 for every NaN (or something like that).
这样,即使它被遮盖了,您的主分布仍将基于最近的标题"继续进行预测,而不会得到垃圾数据或弄乱平滑,但同时也会使NaN分布同时增加让您知道发生了什么事.
This way, even if it gets obscured, your primary distribution will keep predicting based on "last known heading", without getting garbage data or messing up the smoothing, but you'll also get a simultaneous spike on the NaN-distribution letting you know that something's up.
这篇关于对NaN值使用指数平滑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!