Distances¶
Functions:
|
Calculate distance metrics between two samples over multiple dimensions using ecdf_distance and convert to a numpy array. |
|
Calculate distance metrics between two samples over multiple dimensions using hist_distance and convert to a numpy array. |
|
Calculate scaled Wasserstein-1 distance metrics between two samples over multiple dimensions. |
|
Calculate an approximation to the cumulative distribution function (CDF) using empirical distribution. |
|
Calculate a distance metric between two 1D samples using the ecdf function. |
|
Calculate the Energy Distance between two 1D samples. |
|
Calculate a distance metric between two 1D samples using the histcdf function. |
|
Calculate an approximation to the cumulative distribution function (CDF) using histograms. |
|
Calculate the scaled Wasserstein-1 Distance between two 1D samples. |
|
Calculate the Wasserstein Distance (Earth Mover's Distance) between two 1D samples. |
- caloutils.distances.calc_ecdf_dist(r: <Mock name='mock.Tensor' id='140552768372112'>, f: <Mock name='mock.Tensor' id='140552768372112'>, rw: <Mock name='mock.Tensor' id='140552768372112'> | None = None, fw: <Mock name='mock.Tensor' id='140552768372112'> | None = None) <Mock name='mock.ndarray' id='140552768342912'>[source]¶
Calculate distance metrics between two samples over multiple dimensions using ecdf_distance and convert to a numpy array.
- Args:
r (torch.Tensor): Reference sample. f (torch.Tensor): Comparison sample. rw (Optional[torch.Tensor]): Weights for the reference sample (optional). fw (Optional[torch.Tensor]): Weights for the comparison sample (optional).
- Returns:
np.ndarray: Array of distance metrics calculated for each dimension.
- caloutils.distances.calc_hist_dist(r: <Mock name='mock.Tensor' id='140552768372112'>, f: <Mock name='mock.Tensor' id='140552768372112'>, bins: <Mock name='mock.Tensor' id='140552768372112'>, rw: <Mock name='mock.Tensor' id='140552768372112'> | None = None, fw: <Mock name='mock.Tensor' id='140552768372112'> | None = None) <Mock name='mock.ndarray' id='140552768342912'>[source]¶
Calculate distance metrics between two samples over multiple dimensions using hist_distance and convert to a numpy array.
- Args:
r (torch.Tensor): Reference sample. f (torch.Tensor): Comparison sample. bins (torch.Tensor): Bins for histogram calculation. rw (Optional[torch.Tensor]): Weights for the reference sample (optional). fw (Optional[torch.Tensor]): Weights for the comparison sample (optional).
- Returns:
np.ndarray: Array of distance metrics calculated for each dimension.
- caloutils.distances.calc_sw1_dist(r: <Mock name='mock.Tensor' id='140552768372112'>, f: <Mock name='mock.Tensor' id='140552768372112'>, rw: <Mock name='mock.Tensor' id='140552768372112'> | None = None, fw: <Mock name='mock.Tensor' id='140552768372112'> | None = None) <Mock name='mock.ndarray' id='140552768342912'>[source]¶
Calculate scaled Wasserstein-1 distance metrics between two samples over multiple dimensions.
- Args:
r (torch.Tensor): Reference sample. f (torch.Tensor): Comparison sample. rw (Optional[torch.Tensor]): Weights for the reference sample (optional). fw (Optional[torch.Tensor]): Weights for the comparison sample (optional).
- Returns:
np.ndarray: Array of scaled Wasserstein-1 distance metrics calculated for each dimension.
- caloutils.distances.ecdf(arr: <Mock name='mock.Tensor' id='140552768372112'>, weights: <Mock name='mock.Tensor' id='140552768372112'> | None = None) tuple[<Mock name='mock.Tensor' id='140552768372112'>, typing.Optional[<Mock name='mock.Tensor' id='140552768372112'>]][source]¶
Calculate an approximation to the cumulative distribution function (CDF) using empirical distribution.
- Args:
arr (torch.Tensor): Input tensor containing data points. weights (Optional[torch.Tensor]): Weights for each data point (optional).
- Returns:
tuple[torch.Tensor, Optional[torch.Tensor]]: Tuple containing the calculated CDF values and weights (if provided).
- caloutils.distances.ecdf_distance(r: <Mock name='mock.Tensor' id='140552768372112'>, f: <Mock name='mock.Tensor' id='140552768372112'>, rw: <Mock name='mock.Tensor' id='140552768372112'> | None = None, fw: <Mock name='mock.Tensor' id='140552768372112'> | None = None) <Mock name='mock.Tensor' id='140552768372112'>[source]¶
Calculate a distance metric between two 1D samples using the ecdf function.
- Args:
r (torch.Tensor): Reference sample. f (torch.Tensor): Comparison sample. rw (Optional[torch.Tensor]): Weights for the reference sample (optional). fw (Optional[torch.Tensor]): Weights for the comparison sample (optional).
- Returns:
torch.Tensor: Calculated distance metric between the two samples.
- caloutils.distances.energy_distance(r: <Mock name='mock.Tensor' id='140552768372112'>, f: <Mock name='mock.Tensor' id='140552768372112'>, rw: <Mock name='mock.Tensor' id='140552768372112'> | None = None, fw: <Mock name='mock.Tensor' id='140552768372112'> | None = None) <Mock name='mock.Tensor' id='140552768372112'>[source]¶
Calculate the Energy Distance between two 1D samples.
The Energy Distance is a statistical measure that quantifies the difference between the empirical distributions of two sets of data points.
- Args:
r (torch.Tensor): Reference sample. f (torch.Tensor): Comparison sample. rw (Optional[torch.Tensor]): Weights for the reference sample (optional). fw (Optional[torch.Tensor]): Weights for the comparison sample (optional).
- Returns:
torch.Tensor: Calculated Energy Distance between the two samples.
- caloutils.distances.hist_distance(r: <Mock name='mock.Tensor' id='140552768372112'>, f: <Mock name='mock.Tensor' id='140552768372112'>, bins: <Mock name='mock.Tensor' id='140552768372112'>, rw: <Mock name='mock.Tensor' id='140552768372112'> | None = None, fw: <Mock name='mock.Tensor' id='140552768372112'> | None = None) <Mock name='mock.Tensor' id='140552768372112'>[source]¶
Calculate a distance metric between two 1D samples using the histcdf function.
- Args:
r (torch.Tensor): Reference sample. f (torch.Tensor): Comparison sample. bins (torch.Tensor): Bins for histogram calculation. rw (Optional[torch.Tensor]): Weights for the reference sample (optional). fw (Optional[torch.Tensor]): Weights for the comparison sample (optional).
- Returns:
torch.Tensor: Calculated distance metric between the two samples.
- caloutils.distances.histcdf(arr: <Mock name='mock.Tensor' id='140552768372112'>, bins: <Mock name='mock.Tensor' id='140552768372112'>, weight: <Mock name='mock.Tensor' id='140552768372112'> | None = None) <Mock name='mock.Tensor' id='140552768372112'>[source]¶
Calculate an approximation to the cumulative distribution function (CDF) using histograms.
- Args:
arr (torch.Tensor): Input tensor containing data points. bins (torch.Tensor): Bins for histogram calculation. weight (Optional[torch.Tensor]): Weights for each data point (optional).
- Returns:
torch.Tensor: Approximated cumulative distribution function values.
- caloutils.distances.scaled_w1_distance(r: <Mock name='mock.Tensor' id='140552768372112'>, f: <Mock name='mock.Tensor' id='140552768372112'>, rw: <Mock name='mock.Tensor' id='140552768372112'> | None = None, fw: <Mock name='mock.Tensor' id='140552768372112'> | None = None) <Mock name='mock.Tensor' id='140552768372112'>[source]¶
Calculate the scaled Wasserstein-1 Distance between two 1D samples.
The scaled Wasserstein-1 Distance measures the difference between the distributions of two samples while accounting for differences in scale and location.
- Args:
r (torch.Tensor): Reference sample. f (torch.Tensor): Comparison sample. rw (Optional[torch.Tensor]): Weights for the reference sample (optional). fw (Optional[torch.Tensor]): Weights for the comparison sample (optional).
- Returns:
torch.Tensor: Calculated scaled Wasserstein-1 Distance between the two samples.
- caloutils.distances.wasserstein_distance(r: <Mock name='mock.Tensor' id='140552768372112'>, f: <Mock name='mock.Tensor' id='140552768372112'>, rw: <Mock name='mock.Tensor' id='140552768372112'> | None = None, fw: <Mock name='mock.Tensor' id='140552768372112'> | None = None) <Mock name='mock.Tensor' id='140552768372112'>[source]¶
Calculate the Wasserstein Distance (Earth Mover’s Distance) between two 1D samples.
The Wasserstein Distance measures the minimum “cost” of transforming one distribution into another.
- Args:
r (torch.Tensor): Reference sample. f (torch.Tensor): Comparison sample. rw (Optional[torch.Tensor]): Weights for the reference sample (optional). fw (Optional[torch.Tensor]): Weights for the comparison sample (optional).
- Returns:
torch.Tensor: Calculated Wasserstein Distance between the two samples.