MCPcopy Create free account
hub / github.com/PythonOT/POT / gmm_pdf

Function gmm_pdf

ot/gmm.py:74–103  ·  view source on GitHub ↗

r""" 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

(x, m, C, w)

Source from the content-addressed store, hash-verified

72
73
74def gmm_pdf(x, m, C, w):
75 r"""
76 Compute the probability density function (PDF) of a
77 Gaussian Mixture Model (GMM) at given points.
78
79 Parameters
80 ----------
81 x : array-like, shape (..., d)
82 The input samples.
83 m : array-like, shape (n_components, d)
84 The means of the Gaussian components.
85 C : array-like, shape (n_components, d, d)
86 The covariance matrices of the Gaussian components.
87 w : array-like, shape (n_components,)
88 The weights of the Gaussian components.
89
90 Returns
91 -------
92 out : array-like, shape (...,)
93 The PDF values at the given points.
94
95 """
96 assert (
97 m.shape[0] == C.shape[0] == w.shape[0]
98 ), "All GMM parameters must have the same amount of components"
99 nx = get_backend(x, m, C, w)
100 out = nx.zeros((x.shape[:-1]))
101 for k in range(m.shape[0]):
102 out = out + w[k] * gaussian_pdf(x, m[k], C[k])
103 return out
104
105
106def dist_bures_squared(m_s, m_t, C_s, C_t):

Callers 2

test_gmm_pdfFunction · 0.90
plot_GMMOT_plan.pyFile · 0.90

Calls 3

get_backendFunction · 0.85
gaussian_pdfFunction · 0.85
zerosMethod · 0.45

Tested by 1

test_gmm_pdfFunction · 0.72