title: Using exponential smoothing with NaN values
body: <p>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&deg; to +45&deg;, <em>or</em> a <code>NaN</code>, which means that the blob is not actually in view.</p>
  
  <p>In order to combat the noisy data, I felt that <a href="http://en.wikipedia.org/wiki/Exponential_smoothing" rel="nofollow noreferrer">exponential smoothing</a> would do the trick. However, I'm not sure how to handle the <code>NaN</code> values.</p>
  
  <p>On the one hand, involving them in the math would result in a <code>NaN</code> average, which would then prevent any meaningful results. On the other hand, ignoring <code>NaN</code> 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 <code>NaN</code> value, which ideally would be smoothed somehow to prevent random noise.</p>
  
  <p>Any ideas about how I could implement such an exponential smoother?</p>