ot.gmm

Optimal transport for Gaussian Mixtures

Functions

ot.gmm.dist_bures_squared(m_s, m_t, C_s, C_t)[source]

Compute the matrix of the squared Bures distances between the components of two Gaussian Mixture Models (GMMs). Used to compute the GMM Optimal Transport distance [69].

Parameters:
  • m_s (array-like, shape (k_s, d)) – Mean vectors of the source GMM.

  • m_t (array-like, shape (k_t, d)) – Mean vectors of the target GMM.

  • C_s (array-like, shape (k_s, d, d)) – Covariance matrices of the source GMM.

  • C_t (array-like, shape (k_t, d, d)) – Covariance matrices of the target GMM.

Returns:

dist – Matrix of squared Bures distances between the components of the source and target GMMs.

Return type:

array-like, shape (k_s, k_t)

References

ot.gmm.gaussian_pdf(x, m, C)[source]

Compute the probability density function of a multivariate Gaussian distribution.

Parameters:
  • x (array-like, shape (..., d)) – The input samples.

  • m (array-like, shape (d,)) – The mean vector of the Gaussian distribution.

  • C (array-like, shape (d, d)) – The covariance matrix of the Gaussian distribution.

Returns:

pdf – The probability density function evaluated at each sample.

Return type:

array-like, shape (…,)

ot.gmm.gmm_ot_apply_map(x, m_s, m_t, C_s, C_t, w_s, w_t, plan=None, method='bary', seed=None)[source]

Apply Gaussian Mixture Model (GMM) optimal transport (OT) mapping to input data. The ‘barycentric’ mapping corresponds to the barycentric projection of the GMM-OT plan, and is called T_bary in [69]. The ‘random’ mapping takes for each input point a random pair (i,j) of components of the GMMs and applied the Gaussian map, it is called T_rand in [69].

Parameters:
  • x (array-like, shape (n_samples, d)) – Input data points.

  • m_s (array-like, shape (k_s, d)) – Mean vectors of the source GMM components.

  • m_t (array-like, shape (k_t, d)) – Mean vectors of the target GMM components.

  • C_s (array-like, shape (k_s, d, d)) – Covariance matrices of the source GMM components.

  • C_t (array-like, shape (k_t, d, d)) – Covariance matrices of the target GMM components.

  • w_s (array-like, shape (k_s,)) – Weights of the source GMM components.

  • w_t (array-like, shape (k_t,)) – Weights of the target GMM components.

  • plan (array-like, shape (k_s, k_t), optional) – Optimal transport plan between the source and target GMM components. If not provided, it will be computed internally.

  • method ({'bary', 'rand'}, optional) – Method for applying the GMM OT mapping. ‘bary’ uses barycentric mapping, while ‘rand’ uses random sampling. Default is ‘bary’.

  • seed (int, optional) – Seed for the random number generator. Only used when method=’rand’.

Returns:

out – Output data points after applying the GMM OT mapping.

Return type:

array-like, shape (n_samples, d)

References

Examples using ot.gmm.gmm_ot_apply_map

GMM Plan 1D

GMM Plan 1D
ot.gmm.gmm_ot_loss(m_s, m_t, C_s, C_t, w_s, w_t, log=False)[source]

Compute the Gaussian Mixture Model (GMM) Optimal Transport distance between two GMMs introduced in [69].

Parameters:
  • m_s (array-like, shape (k_s, d)) – Mean vectors of the source GMM.

  • m_t (array-like, shape (k_t, d)) – Mean vectors of the target GMM.

  • C_s (array-like, shape (k_s, d, d)) – Covariance matrices of the source GMM.

  • C_t (array-like, shape (k_t, d, d)) – Covariance matrices of the target GMM.

  • w_s (array-like, shape (k_s,)) – Weights of the source GMM components.

  • w_t (array-like, shape (k_t,)) – Weights of the target GMM components.

  • log (bool, optional (default=False)) – If True, returns a dictionary containing the cost and dual variables. Otherwise returns only the GMM optimal transportation cost.

Returns:

  • loss (float or array-like) – The GMM-OT loss.

  • log (dict, optional) – If input log is true, a dictionary containing the cost and dual variables and exit status

References

Examples using ot.gmm.gmm_ot_loss

GMM Flow

GMM Flow
ot.gmm.gmm_ot_plan(m_s, m_t, C_s, C_t, w_s, w_t, log=False)[source]

Compute the Gaussian Mixture Model (GMM) Optimal Transport plan between two GMMs introduced in [69].

Parameters:
  • m_s (array-like, shape (k_s, d)) – Mean vectors of the source GMM.

  • m_t (array-like, shape (k_t, d)) – Mean vectors of the target GMM.

  • C_s (array-like, shape (k_s, d, d)) – Covariance matrices of the source GMM.

  • C_t (array-like, shape (k_t, d, d)) – Covariance matrices of the target GMM.

  • w_s (array-like, shape (k_s,)) – Weights of the source GMM components.

  • w_t (array-like, shape (k_t,)) – Weights of the target GMM components.

  • log (bool, optional (default=False)) – If True, returns a dictionary containing the cost and dual variables. Otherwise returns only the GMM optimal transportation matrix.

Returns:

  • plan (array-like, shape (k_s, k_t)) – The GMM-OT plan.

  • log (dict, optional) – If input log is true, a dictionary containing the cost and dual variables and exit status

References

ot.gmm.gmm_ot_plan_density(x, y, m_s, m_t, C_s, C_t, w_s, w_t, plan=None, atol=0.01)[source]

Compute the density of the Gaussian Mixture Model - Optimal Transport coupling between GMMS at given points, as introduced in [69]. Given two arrays of points x and y, the function computes the density at each point (x[i], y[i]) of the product space.

Parameters:
  • x (array-like, shape (n, d)) – Entry points in source space for density computation.

  • y (array-like, shape (m, d)) – Entry points in target space for density computation.

  • m_s (array-like, shape (k_s, d)) – The means of the source GMM components.

  • m_t (array-like, shape (k_t, d)) – The means of the target GMM components.

  • C_s (array-like, shape (k_s, d, d)) – The covariance matrices of the source GMM components.

  • C_t (array-like, shape (k_t, d, d)) – The covariance matrices of the target GMM components.

  • w_s (array-like, shape (k_s,)) – The weights of the source GMM components.

  • w_t (array-like, shape (k_t,)) – The weights of the target GMM components.

  • plan (array-like, shape (k_s, k_t), optional) – The optimal transport plan between the source and target GMMs. If not provided, it will be computed using gmm_ot_plan.

  • atol (float, optional) – The absolute tolerance used to determine the support of the GMM-OT coupling.

Returns:

density – The density of the GMM-OT coupling between the two GMMs.

Return type:

array-like, shape (n, m)

References

Examples using ot.gmm.gmm_ot_plan_density

GMM Plan 1D

GMM Plan 1D
ot.gmm.gmm_pdf(x, m, C, w)[source]

Compute the probability density function (PDF) of a Gaussian Mixture Model (GMM) at given points.

Parameters:
  • x (array-like, shape (..., d)) – The input samples.

  • m (array-like, shape (n_components, d)) – The means of the Gaussian components.

  • C (array-like, shape (n_components, d, d)) – The covariance matrices of the Gaussian components.

  • w (array-like, shape (n_components,)) – The weights of the Gaussian components.

Returns:

out – The PDF values at the given points.

Return type:

array-like, shape (…,)

Examples using ot.gmm.gmm_pdf

GMM Plan 1D

GMM Plan 1D
ot.gmm.dist_bures_squared(m_s, m_t, C_s, C_t)[source]

Compute the matrix of the squared Bures distances between the components of two Gaussian Mixture Models (GMMs). Used to compute the GMM Optimal Transport distance [69].

Parameters:
  • m_s (array-like, shape (k_s, d)) – Mean vectors of the source GMM.

  • m_t (array-like, shape (k_t, d)) – Mean vectors of the target GMM.

  • C_s (array-like, shape (k_s, d, d)) – Covariance matrices of the source GMM.

  • C_t (array-like, shape (k_t, d, d)) – Covariance matrices of the target GMM.

Returns:

dist – Matrix of squared Bures distances between the components of the source and target GMMs.

Return type:

array-like, shape (k_s, k_t)

References

ot.gmm.gaussian_pdf(x, m, C)[source]

Compute the probability density function of a multivariate Gaussian distribution.

Parameters:
  • x (array-like, shape (..., d)) – The input samples.

  • m (array-like, shape (d,)) – The mean vector of the Gaussian distribution.

  • C (array-like, shape (d, d)) – The covariance matrix of the Gaussian distribution.

Returns:

pdf – The probability density function evaluated at each sample.

Return type:

array-like, shape (…,)

ot.gmm.gmm_ot_apply_map(x, m_s, m_t, C_s, C_t, w_s, w_t, plan=None, method='bary', seed=None)[source]

Apply Gaussian Mixture Model (GMM) optimal transport (OT) mapping to input data. The ‘barycentric’ mapping corresponds to the barycentric projection of the GMM-OT plan, and is called T_bary in [69]. The ‘random’ mapping takes for each input point a random pair (i,j) of components of the GMMs and applied the Gaussian map, it is called T_rand in [69].

Parameters:
  • x (array-like, shape (n_samples, d)) – Input data points.

  • m_s (array-like, shape (k_s, d)) – Mean vectors of the source GMM components.

  • m_t (array-like, shape (k_t, d)) – Mean vectors of the target GMM components.

  • C_s (array-like, shape (k_s, d, d)) – Covariance matrices of the source GMM components.

  • C_t (array-like, shape (k_t, d, d)) – Covariance matrices of the target GMM components.

  • w_s (array-like, shape (k_s,)) – Weights of the source GMM components.

  • w_t (array-like, shape (k_t,)) – Weights of the target GMM components.

  • plan (array-like, shape (k_s, k_t), optional) – Optimal transport plan between the source and target GMM components. If not provided, it will be computed internally.

  • method ({'bary', 'rand'}, optional) – Method for applying the GMM OT mapping. ‘bary’ uses barycentric mapping, while ‘rand’ uses random sampling. Default is ‘bary’.

  • seed (int, optional) – Seed for the random number generator. Only used when method=’rand’.

Returns:

out – Output data points after applying the GMM OT mapping.

Return type:

array-like, shape (n_samples, d)

References

ot.gmm.gmm_ot_loss(m_s, m_t, C_s, C_t, w_s, w_t, log=False)[source]

Compute the Gaussian Mixture Model (GMM) Optimal Transport distance between two GMMs introduced in [69].

Parameters:
  • m_s (array-like, shape (k_s, d)) – Mean vectors of the source GMM.

  • m_t (array-like, shape (k_t, d)) – Mean vectors of the target GMM.

  • C_s (array-like, shape (k_s, d, d)) – Covariance matrices of the source GMM.

  • C_t (array-like, shape (k_t, d, d)) – Covariance matrices of the target GMM.

  • w_s (array-like, shape (k_s,)) – Weights of the source GMM components.

  • w_t (array-like, shape (k_t,)) – Weights of the target GMM components.

  • log (bool, optional (default=False)) – If True, returns a dictionary containing the cost and dual variables. Otherwise returns only the GMM optimal transportation cost.

Returns:

  • loss (float or array-like) – The GMM-OT loss.

  • log (dict, optional) – If input log is true, a dictionary containing the cost and dual variables and exit status

References

ot.gmm.gmm_ot_plan(m_s, m_t, C_s, C_t, w_s, w_t, log=False)[source]

Compute the Gaussian Mixture Model (GMM) Optimal Transport plan between two GMMs introduced in [69].

Parameters:
  • m_s (array-like, shape (k_s, d)) – Mean vectors of the source GMM.

  • m_t (array-like, shape (k_t, d)) – Mean vectors of the target GMM.

  • C_s (array-like, shape (k_s, d, d)) – Covariance matrices of the source GMM.

  • C_t (array-like, shape (k_t, d, d)) – Covariance matrices of the target GMM.

  • w_s (array-like, shape (k_s,)) – Weights of the source GMM components.

  • w_t (array-like, shape (k_t,)) – Weights of the target GMM components.

  • log (bool, optional (default=False)) – If True, returns a dictionary containing the cost and dual variables. Otherwise returns only the GMM optimal transportation matrix.

Returns:

  • plan (array-like, shape (k_s, k_t)) – The GMM-OT plan.

  • log (dict, optional) – If input log is true, a dictionary containing the cost and dual variables and exit status

References

ot.gmm.gmm_ot_plan_density(x, y, m_s, m_t, C_s, C_t, w_s, w_t, plan=None, atol=0.01)[source]

Compute the density of the Gaussian Mixture Model - Optimal Transport coupling between GMMS at given points, as introduced in [69]. Given two arrays of points x and y, the function computes the density at each point (x[i], y[i]) of the product space.

Parameters:
  • x (array-like, shape (n, d)) – Entry points in source space for density computation.

  • y (array-like, shape (m, d)) – Entry points in target space for density computation.

  • m_s (array-like, shape (k_s, d)) – The means of the source GMM components.

  • m_t (array-like, shape (k_t, d)) – The means of the target GMM components.

  • C_s (array-like, shape (k_s, d, d)) – The covariance matrices of the source GMM components.

  • C_t (array-like, shape (k_t, d, d)) – The covariance matrices of the target GMM components.

  • w_s (array-like, shape (k_s,)) – The weights of the source GMM components.

  • w_t (array-like, shape (k_t,)) – The weights of the target GMM components.

  • plan (array-like, shape (k_s, k_t), optional) – The optimal transport plan between the source and target GMMs. If not provided, it will be computed using gmm_ot_plan.

  • atol (float, optional) – The absolute tolerance used to determine the support of the GMM-OT coupling.

Returns:

density – The density of the GMM-OT coupling between the two GMMs.

Return type:

array-like, shape (n, m)

References

ot.gmm.gmm_pdf(x, m, C, w)[source]

Compute the probability density function (PDF) of a Gaussian Mixture Model (GMM) at given points.

Parameters:
  • x (array-like, shape (..., d)) – The input samples.

  • m (array-like, shape (n_components, d)) – The means of the Gaussian components.

  • C (array-like, shape (n_components, d, d)) – The covariance matrices of the Gaussian components.

  • w (array-like, shape (n_components,)) – The weights of the Gaussian components.

Returns:

out – The PDF values at the given points.

Return type:

array-like, shape (…,)