title: Histogram Smoothing
body: <p>I have a probably pretty simple question but I am still not sure!</p>
  
  <p>Actually I only want to smooth a histogram, and I am not sure which of the following to methods is correct. Would I do it like this:</p>
  
  <pre><code>vector&lt;double&gt; mask(3);
  mask[0] = 0.25; mask[1] = 0.5; mask[2] = 0.25;
  
  vector&lt;double&gt; tmpVect(histogram-&gt;size());
  for (unsigned int i = 0; i &lt; histogram-&gt;size(); i++)
    tmpVect[i] = (*histogram)[i];
  
  for (int bin = 1; bin &lt; histogram-&gt;size()-1; bin++) {
    double smoothedValue = 0;
    for (int i = 0; i &lt; mask.size(); i++) {
      smoothedValue += tmpVect[bin-1+i]*mask[i];
    }
    (*histogram)[bin] = smoothedValue;
  }
  </code></pre>
  
  <p>Or would you usually do it like this?:</p>
  
  <pre><code>vector&lt;double&gt; mask(3);
  mask[0] = 0.25; mask[1] = 0.5; mask[2] = 0.25;
  
  for (int bin = 1; bin &lt; histogram-&gt;size()-1; bin++) {
    double smoothedValue = 0;
    for (int i = 0; i &lt; mask.size(); i++) {
      smoothedValue += (*histogram)[bin-1+i]*mask[i];
    }
    (*histogram)[bin] = smoothedValue;
  }
  </code></pre>
  
  <p>My Questin is: Is it resonable to copy the histogram in a extra vector first so that when I smooth at bin <code>i</code> I can use the original <code>i-1</code> value or would I simply do <code>smoothedValue += (*histogram)[bin-1+i]*mask[i];</code>, so that I use the already smoothed <code>i-1</code> value instead the original one.</p>
  
  <p>Regards  &amp; Thanks for a reply. </p>