Norm of a Vector in Python | L2 norm python
Thenormofavectorreferstothelengthorthemagnitudeofavector.Therearedifferentwaystocalculatethelength.Thenormofavectorisanon-negativevalue.Inthistutorial,wewilllearnhowtocalculatethedifferenttypesofnormsofavector.Normofavectorxisdenotedas:‖x‖Thenormofavectorisameasureofitsdistancefromtheorigininthevectorspace.Tocalculatethenorm,youcaneitheruseNumpy[1]orScipy.[2]Bothofferasimilarfunctiontocalculatethenorm.Inthistutorialwewilllookattwotypesofnormsthataremostcommoninthefieldofmachinelearning.These...
The norm of a vector refers to the length or the magnitude of a vector. There are different ways to calculate the length. The norm of a vector is a non-negative value. In this tutorial, we will learn how to calculate the different types of norms of a vector.
Norm of a vector x is denoted as: ‖x‖
The norm of a vector is a measure of its distance from the origin in the vector space.
To calculate the norm, you can either use Numpy[1] or Scipy.[2] Both offer a similar function to calculate the norm.
In this tutorial we will look at two types of norms that are most common in the field of machine learning.
These are :
L1 Norm of a vector is also known as the Manhattan distance or Taxicab norm. The notation for L1 norm of a vector x is ‖x‖1.
To calculate the norm, you need to take the sum of the absolute vector values.
Let’s take an example to understand this:
a = [1,2,3,4,5]For the array above, the L1 norm is going to be: