L1 Norm

The Vector L1 norm is the sum of absolute scalar values within an array. Mathematically, we represent it as:

$$ x = \begin{bmatrix} x_1 \\ ... \\ x_n \end{bmatrix} $$ Then l1 norm is: $$ L^1 ||x|| = |x_1| + | x_2 | + ... + | x_n |$$

If $x$ is a vector

$$ x = \begin{bmatrix} 2 \\ 3 \\ 4 \end{bmatrix} $$

then the L1 norm of $x$: $$ L^1 ||x|| = |2| + |3| + |4| = 9 $$

Implementation in numpy

import numpy as np

sample_vect = np.array([2, 3, 4])
np.linalg.norm(sample_vect, 1)
9.0