title: NRZ-S with Python
body: <p>I have this array, which is a digital signal (in theory):</p>
  
  <pre><code>array_nrz = [1,0,1,1,0,0,0,1,1,0,1,0]
  </code></pre>
  
  <p>I want to plot both the NRZ and NRZ-S encodings. How can I transform this array into an NRZ-S signal?</p>
  
  <pre><code>array_transformed_nrz_s = [1,0,0,0,1,0,1,1,1,0,0,1]
  </code></pre>
  
  <p>Here are two illustrated examples. </p>
  
  <p><a href="http://www.tpub.com/neets/book23/0060.GIF" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3nI9u.gif" alt="http://www.tpub.com/neets/book23/0060.GIF"></a></p>
  
  <p><a href="http://www.itwissen.info/bilder/nrz-s-codierung.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5qtPP.png" alt="http://www.itwissen.info/bilder/nrz-s-codierung.png"></a></p>
  
  <p>Is there a package I could use?</p>
  
  <p>From what I understand the signal changes only when it encounter a 0.</p>