Euclidean Distances

Euclidean distances are measures of proximity between points in standard Euclidean spaces.

EuclideanDistance Class

The abstract UQpy.utilities.distances.baseclass.EuclideanDistance class is the base class for all Euclidean distances in UQpy. It provides a blueprint for classes in the euclidean_distances module and allows the user to define a set of methods that must be created within any child classes built from this abstract class.

class EuclideanDistance[source]
calculate_distance_matrix(points)[source]

Given a list of cartesian points, calculates a matrix that contains the distances between them.

Parameters:

points (list[ndarray]) – A list of cartesian points.

Returns:

ndarray

The EuclideanDistance class is imported using the following command:

>>> from UQpy.utilities.distances.baseclass.EuclideanDistance import EuclideanDistance

List of Available Distances

All the distances classes below are subclasses of the EuclideanDistance class.

Bray-Curtis Distance

The Bray-Curtis distance between two 1D arrays, x and y, is given by:

\[d(x,y) = \dfrac{\sum_i |x_i - y_i|}{\sum_i |x_i + y_i|}\]

The BrayCurtisDistance class is imported using the following command:

>>> from UQpy.utilities.distances.euclidean_distances.BrayCurtisDistance import BrayCurtisDistance

Methods

One can use the following command to instantiate the BrayCurtisDistance class.

class BrayCurtisDistance[source]
compute_distance(xi, xj)[source]

Given two points, this method calculates the Bray-Curtis distance.

Parameters:
Return type:

float

Returns:

A float representing the distance between the points.

Attributes

BrayCurtisDistance.distance_matrix: np.ndarray

Distance matrix defining the pairwise distances between the points

Canberra Distance

The Canberra distance between two 1D arrays, x and y, is given by:

\[d(x,y) = \sum_i \dfrac{|x_i - y_i|}{|x_i| + |y_i|}\]

The CanberraDistance class is imported using the following command:

>>> from UQpy.utilities.distances.euclidean_distances.CanberraDistance import CanberraDistance

Methods

One can use the following command to instantiate the CanberraDistance class.

class CanberraDistance[source]
compute_distance(xi, xj)[source]

Given two points, this method calculates the Canberra distance.

Parameters:
Return type:

float

Returns:

A float representing the distance between the points.

Attributes

CanberraDistance.distance_matrix: np.ndarray

Distance matrix defining the pairwise distances between the points

Chebyshev Distance

The Chebyshev distance between two 1D arrays, x and y, is given by:

\[d(x,y) = \max_i |x_i-y_i|\]

The ChebyshevDistance class is imported using the following command:

>>> from UQpy.utilities.distances.euclidean_distances.ChebyshevDistance import ChebyshevDistance

Methods

One can use the following command to instantiate the ChebyshevDistance class:

class ChebyshevDistance[source]
compute_distance(xi, xj)[source]

Given two points, this method calculates the Chebyshev distance.

Parameters:
Return type:

float

Returns:

A float representing the distance between the points.

Attributes

ChebyshevDistance.distance_matrix: np.ndarray

Distance matrix defining the pairwise distances between the points

CityBlock Distance

The City Block (Manhattan) distance between two 1D arrays, x and y, is given by:

\[d(x,y) = \sum_i |x_i - y_i|\]

The CityBlockDistance class is imported using the following command:

>>> from UQpy.utilities.distances.euclidean_distances.CityBlockDistance import CityBlockDistance

Methods

One can use the following command to instantiate the CityBlockDistance class

class CityBlockDistance[source]
compute_distance(xi, xj)[source]

Given two points, this method calculates the City Block (Manhattan) distance.

Parameters:
Return type:

float

Returns:

A float representing the distance between the points.

Attributes

CityBlockDistance.distance_matrix: np.ndarray

Distance matrix defining the pairwise distances between the points

Correlation Distance

The Correlation distance between two 1D arrays, x and y, is given by:

\[d(x,y) = 1 - \dfrac{(x-\bar{x})\cdot(y-\bar{y})}{||x-\bar{x}||_2||y-\bar{y}||_2}\]

where \(\bar{x}\) denotes the mean of the elements of \(x\) and \(x\cdot y\) denotes the dot product.

The CorrelationDistance class is imported using the following command:

>>> from UQpy.utilities.distances.euclidean_distances.CorrelationDistance import CorrelationDistance

Methods

One can use the following command to instantiate the class CorrelationDistance

class CorrelationDistance[source]
compute_distance(xi, xj)[source]

Given two points, this method calculates the Correlation distance.

Parameters:
Return type:

float

Returns:

A float representing the distance between the points.

Attributes

CorrelationDistance.distance_matrix: np.ndarray

Distance matrix defining the pairwise distances between the points

Cosine Distance

The Cosine distance between two 1D arrays, x and y, is given by:

\[d(x,y) = 1 - \dfrac{x\cdot y}{||x||_2||y||_2}\]

where \(x\cdot y\) denotes the dot product.

The CosineDistance class is imported using the following command:

>>> from UQpy.utilities.distances.euclidean_distances.CosineDistance import CosineDistance

Methods

One can use the following command to instantiate the class CosineDistance

class CosineDistance[source]
compute_distance(xi, xj)[source]

Given two points, this method calculates the Cosine distance.

Parameters:
Return type:

float

Returns:

A float representing the distance between the points.

Attributes

CosineDistance.distance_matrix: np.ndarray

Distance matrix defining the pairwise distances between the points

L2 Distance

The UQpy.utilities.distances.euclidean_distances.L2Distance class is imported using the following command: The L2 distance between two 1D arrays, x and y, is given by:

\[d(x,y) = ||x - y||_2\]

The UQpy.utilities.distances.euclidean_distances.L2Distance class is imported using the following command:

>>> from UQpy.utilities.distances.euclidean_distances.L2Distance import L2Distance

Methods

One can use the following command to instantiate the class UQpy.utilities.distances.euclidean_distances.L2Distance

class L2Distance[source]
compute_distance(xi, xj)[source]

Given two points, this method calculates the L2 distance.

Parameters:
Return type:

float

Returns:

A float representing the distance between the points.

Attributes

L2Distance.distance_matrix: np.ndarray

Distance matrix defining the pairwise distances between the points

Minkowski Distance

The Minkowski distance between two 1D arrays, x and y, is given by:

\[d(x,y) = ||x - y||_p = \left(\sum_i |x_i-y_i|^p \right)^{1/p}.\]

The MinkowskiDistance class is imported using the following command:

>>> from UQpy.utilities.distances.euclidean_distances.MinkowskiDistance import MinkowskiDistance

Methods

One can use the following command to instantiate the class MinkowskiDistance

class MinkowskiDistance(p=2)[source]
Parameters:

p (float) – Order of the norm.

compute_distance(xi, xj)[source]

Given two points, this method calculates the Minkowski distance.

Parameters:
Return type:

float

Returns:

A float representing the distance between the points.

Attributes

MinkowskiDistance.distance_matrix: np.ndarray

Distance matrix defining the pairwise distances between the points