title: Peak signal detection in realtime timeseries data
body: <hr />
  <p><strong>Update:</strong> The best performing algorithm <em>so far</em> <a href="https://stackoverflow.com/questions/22583391/peak-recognition-in-realtime-timeseries-data/22640362#22640362"><strong>is this one</strong></a>.</p>
  <hr />
  <p><em>This question explores robust algorithms for detecting sudden peaks in real-time timeseries data.</em></p>
  <p>Consider the following example data:</p>
  <p><a href="https://i.stack.imgur.com/yUeKr.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/yUeKr.jpg" alt="Plot of data" /></a></p>
  <p><sub>Example of this data is in Matlab format (but this question is not about the language but about the algorithm):</sub></p>
  <pre><code>p = [1 1 1.1 1 0.9 1 1 1.1 1 0.9 1 1.1 1 1 0.9 1 1 1.1 1 1 1 1 1.1 0.9 1 1.1 1 1 0.9, ...
       1 1.1 1 1 1.1 1 0.8 0.9 1 1.2 0.9 1 1 1.1 1.2 1 1.5 1 3 2 5 3 2 1 1 1 0.9 1 1, ... 
       3 2.6 4 3 3.2 2 1 1 0.8 4 4 2 2.5 1 1 1];
  </code></pre>
  <p>You can clearly see that there are three large peaks and some small peaks. This dataset is a specific example of the class of timeseries datasets that the question is about. This class of datasets has two general features:</p>
  <ol>
  <li>There is basic noise with a general mean</li>
  <li>There are large '<em>peaks</em>' or '<em>higher data points</em>' that significantly deviate from the noise.</li>
  </ol>
  <p>Let's also assume the following:</p>
  <ul>
  <li>The width of the peaks cannot be determined beforehand</li>
  <li>The height of the peaks significantly deviates from the other values</li>
  <li>The algorithm updates in realtime (so updates with each new datapoint)</li>
  </ul>
  <p>For such a situation, a boundary value needs to be constructed which triggers signals. However, the boundary value cannot be static and must be determined realtime based on an algorithm.</p>
  <hr />
  <p><strong>My Question: what is a good algorithm to calculate such thresholds in realtime?</strong> Are there specific algorithms for such situations? What are the most well-known algorithms?</p>
  <hr />
  <p><sub>Robust algorithms or useful insights are all highly appreciated. (can answer in any language: it's about the algorithm)</sub></p>