title: How to use numpy to calculate mean and standard deviation of an irregular shaped array
body: <p>I have a numpy array that has many samples in it of varying length</p>
  
  <pre><code>Samples = np.array([[1001, 1002, 1003],
                      ... ,
                      [1001, 1002]])
  </code></pre>
  
  <p>I want to (elementwise) subtract the mean of the array then divide by the standard deviation of the array. Something like:</p>
  
  <pre><code>newSamples = (Samples-np.mean(Samples))/np.std(Samples)
  </code></pre>
  
  <p>Except that doesn't work for irregular shaped arrays,</p>
  
  <p>np.mean(Samples) causes</p>
  
  <pre><code>unsupported operand type(s) for /: 'list' and 'int'
  </code></pre>
  
  <p>due to what I assume to be it having set a static size for each axis and then when it encounters a different sized sample it can't handle it. What is an approach to solve this using numpy?</p>
  
  <p>example input:</p>
  
  <pre><code>Sample = np.array([[1, 2, 3],
                     [1, 2]])
  </code></pre>
  
  <p>After subtracting by the mean and then dividing by standard deviation:</p>
  
  <pre><code>Sample = array([[-1.06904497,  0.26726124,  1.60356745], 
                  [-1.06904497,  0.26726124]])
  </code></pre>