Vector norms are used in many machine learning and computer science problems. This article covers some common norms and related applications.
From a high school entrance exam…
Remember the day (?/?/1998) when I took an exam to a high school, there was a problem of finding the shortest path from A to B knowing that the person can only go left/right or up/down given the following grid of m x n
blocks.
👨 | ||||||||||||
B |
You may find the shortest path is m +n
, simply the person should go down and right only. Accordingly, they add up to the sum of the length and the width of the grid. Also, the shortest path is not unique.
This is a practical problem in our real world to find the shortest routes since in many cases, we just can not follow a straight line connecting A and B. For example, finding the way to your nearest train station by foot/car, not the aeroplane.
So, we can see that there is more than one way to measure the distance from A to B depending on the (movement/constraint) condition between 2 points. The solution of the example is known as manhattan distance and it is closely related to the concept of vector norms which we introduce below.
Vector norms
Definition: A norm on a vector space V is a function:
which asigns each vector its length
, such that for all
and
the following hold:
- Absolutely homogeneous:
- Triangle inequality:
- Positive definite:
Manhattan norm – l1
The manhattan norm on is defined for
as
where is the absolute value. The left panel of the equation shows all vectors
with
. The Manhattan norm is also called
.
EUCLIDEAN NORM – L2
The Euclidean norm of is defined as
and computes the Euclidean distance of x from the origin. The right panel of the equation shows all vectors with
.
The Euclidean norm is also called l2 norm.
p-norm (
spaces)
Many may wonder where the letter l
come from. It is after the name of mathematician Henri Lebesgue. For higher-order norm, we call them norm (Lebesgue spaces).
Let e a real number. The p-norm (also called
of vector
is
Frobenius norm
It is a common norm for matrix.
where are the singular values of matrix A.
Quick note
: zero norm is not a norm in the usual sense as it lacks the homogeneity property. It is the number of non-zero elements of x.
and
(or Frobenius norm in case of matrices) are commonly used as l1 and l2 regularization in machine learning to reduce the overfitting problem (see this article).
: the max element in x.
REFERENCE:
Math for machine learning, https://mml-book.github.io/book/mml-book.pdf