title: Normalize positive and negative values separately
body: <p>I have a matrix where I want the positive values to be normalized by dividing by the max positive value such that the maximum value is 1, and the negative values to be normalized by the min negative value such that the most negative value is -1. For example,</p>
  <pre><code>[[   1.    4. -100.]
   [   3.   10.   -8.]]
  </code></pre>
  <p>becomes</p>
  <p>[[ 0.1   0.4  -1.  ]
  [ 0.3   1.   -0.08]].</p>
  <p>I tried</p>
  <pre><code>def sym_min_max_norm(mat):
      res = np.divide(mat, np.max(mat), where = mat &gt; 0)
      res = np.divide(res, -np.min(res), where = res &lt; 0)
      return res
  </code></pre>
  <p>but this doesn't seem to work. Maybe I'm using the where condition wrong in np.divide?</p>