In the context of comparing elements in a vector space, there is a huge variety of distance measures or metric at our disposal. Let us focus on a particular metric induced by the -norm. For two vectors , we define the -distance as:

which is the -norm of the vector .

For , we have the Euclidean distance, a very common metric that is related to the inner product of a vector with itself:

where .

Fill in the code to calculate the Euclidean distance between two vectors .

Hint

You can use numpy functions, such as -norm np.linalg.norm or the inner product np.inner.

or to submit your code

To interact with codercises, please switch to a larger screen size.

Learning Objectives:

  • Define and give examples of metrics.
  • Define and calculate the trace distance between two probability distributions.