title: How to filter based on the previous value and a cutoff value
body: <p><a href="https://i.stack.imgur.com/sCKET.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sCKET.png" alt="enter image description here" /></a>I am using Jupiter notebook and I want to create a filter.
  I have an array which contains sensor reedings. The sensor dat are available every seconds. I want to implement a filter such as:</p>
  <blockquote>
  <p>store the last two readings of the SenorData in an empty array
  (FilterData[]),  if the last value (FilterData[-1] ) is bigger than a
  cutoff (500), then use the previous value (FilterData[-2]) and update
  this filtered value to the SenorData  and repeat this loop again with
  the new sensor reading.</p>
  </blockquote>
  <p>Here is an example how my sensor data looks like:</p>
  <pre><code>SenorData= [110.3244118,
   110.3244118,
   110.3244118,
   110.3244118,
   110.3244118,
   110.3244118,
   110.3244118,
   170.7510605,
   170.7510605,
   2180.280465,
   2417.867061,
   2793.702506,
   2883.198035,
   2822.542497,
   2822.542497,
   2862.483596,
   2862.483596,
   2723.776971,
   2694.70809,
   2812.700278,
   2812.700278,
   2812.700278,
   2596.400342,
   2269.66155,
   1902.867214,
   833.9564196,
   457.4343089,
   160.3366192,
   131.0388501,
   131.0388501,
   91.09775079,
   91.09775079,
   91.09775079,
   91.09775079,
   91.09775079,
   91.09775079,
   91.09775079,
   91.09775079,
   91.09775079,
   91.09775079]
  </code></pre>