title: Revert MinMax scaling with 2 overlapping lists
body: <p>Following my question here: <a href="https://stackoverflow.com/questions/56000914/revert-minmax-scaling/56001205#56001205">Revert MinMax scaling</a>, I'm trying another approach.</p>
  
  <p>This time, I have 2 big lists:</p>
  
  <pre><code>[ ...many values, 0, 20, 22, 32, 11, 24,  0, 12, 11, 33]
                  [26, 25, 34, 45, 45, 35, 71, 27, 27, 34, many values...]
  </code></pre>
  
  <p>The values in the 2 big lists have been scaled with a MinMax scaler:</p>
  
  <pre><code>V = (actual - min) / (max - min)
  </code></pre>
  
  <p>min and max are constant within a list. min and max are different for the 2 big lists.</p>
  
  <p>The two big lists "overlap" in two smaller lists:</p>
  
  <pre><code>[ 0, 20, 22, 32, 11, 24,  0, 12, 11, 33]
  [26, 25, 34, 45, 45, 35, 71, 27, 27, 34]
  </code></pre>
  
  <p>For the first list, I know that:</p>
  
  <pre><code>V = (actual - min1) / (max1 - min1)
  </code></pre>
  
  <p>And for the second list, I know that:</p>
  
  <pre><code> V = (actual - min2) / (max2 - min2)
  </code></pre>
  
  <p>So technically, I can express <code>actual</code> as a function of <code>min1, min2, max1, max2</code>, </p>
  
  <pre><code>V1.max1 - V1.min1 + min1 - V2.max2 +V2.min2 - min2 = 0
  &lt;=&gt; V1.x0 - (V1+1).x1 - V2.x2 + (V2-1).x3 = 0
  </code></pre>
  
  <p>get a set of 4 equations, and solve with <code>numpy.linalg.solve</code>:</p>
  
  <pre><code>data = [(V1, V1+1, V2, V2-1) for V1, V2 in zip(vals1, vals2) if V1 !=0 and V2 != 0]
  res = [0 for v in data]
  
  x = np.linalg.solve(data, res)
  </code></pre>
  
  <p>But I get a <code>LinAlgError: Singular matrix</code> exception each time I try to do that:</p>
  
  <pre><code>lib/python3.7/site-packages/numpy/linalg/linalg.py in solve(a, b)
      401     signature = 'DD-&gt;D' if isComplexType(t) else 'dd-&gt;d'
      402     extobj = get_linalg_error_extobj(_raise_linalgerror_singular)
  --&gt; 403     r = gufunc(a, b, signature=signature, extobj=extobj)
      404
      405     return wrap(r.astype(result_t, copy=False))
  
  lib/python3.7/site-packages/numpy/linalg/linalg.py in _raise_linalgerror_singular(err, flag)
       95
       96 def _raise_linalgerror_singular(err, flag):
  ---&gt; 97     raise LinAlgError("Singular matrix")
       98
       99 def _raise_linalgerror_nonposdef(err, flag):
  
  LinAlgError: Singular matrix
  </code></pre>
  
  <p>Am I missing independent equations again?</p>