Search code examples
pythonnumpynormalize

how to de-normalize values normalized by linalg.norm method of numpy?


I have an array

a = array([[ 3.55679502,  3.46622505],
           [ 1.03670334,  2.43254031],
           [ 1.12185975,  3.25257322]])

Now I normalized it with numpys linalg.norm method

norm_a = a/np.linalg.norm(a)

It gives normalized values in the range of (0,1) as

norm_a = array([[ 0.53930891,  0.52557599],
                [ 0.15719302,  0.36884067],
                [ 0.1701051 ,  0.49318044]])

Now, using norm_a, how can I recover original de-normalized matrix a?


Solution

  • Do the opposite, simple maths really:

    In [310]:    
    norm_a * np.linalg.norm(a)
    
    Out[310]:
    array([[ 3.55679502,  3.46622505],
           [ 1.03670334,  2.43254031],
           [ 1.12185975,  3.25257322]])