Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
rli
pbdlib-python
Commits
92294c29
Commit
92294c29
authored
Jan 18, 2019
by
Emmanuel PIGNAT
Browse files
getting logdet instead of det in uncertainty
parent
7473686e
Changes
2
Hide whitespace changes
Inline
Side-by-side
pbdlib/mtmm.py
View file @
92294c29
...
...
@@ -163,7 +163,7 @@ class MTMM(GMM):
# apply moment matching to get a single MVN for each datapoint
return
gaussian_moment_matching
(
mu_est
,
sigma_est
*
(
nu
/
(
nu
-
2.
))[:,
None
,
None
,
None
],
h
.
T
)
def
get_pred_post_uncertainty
(
self
,
data_in
,
dim_in
,
dim_out
):
def
get_pred_post_uncertainty
(
self
,
data_in
,
dim_in
,
dim_out
,
log
=
False
):
"""
[1] M. Hofert, 'On the Multivariate t Distribution,' R J., vol. 5, pp. 129-136, 2013.
...
...
@@ -230,8 +230,10 @@ class MTMM(GMM):
_
,
_covs
=
gaussian_moment_matching
(
mu_est
,
sigma_est
,
h
.
T
)
# return a
return
np
.
linalg
.
det
(
_covs
)
if
log
:
return
np
.
linalg
.
slogdet
(
_covs
)[
1
]
else
:
return
np
.
linalg
.
det
(
_covs
)
# the conditional distribution is now a still a mixture
...
...
@@ -278,7 +280,7 @@ class VBayesianGMM(MTMM):
_gmm
=
GMM
()
_gmm
.
lmbda
=
np
.
array
(
[
wishart
.
rvs
(
m
.
degrees_of_freedom_
[
i
],
[
wishart
.
rvs
(
m
.
degrees_of_freedom_
[
i
]
+
1.
,
np
.
linalg
.
inv
(
m
.
covariances_
[
i
]
*
m
.
degrees_of_freedom_
[
i
]))
for
i
in
range
(
nb_states
)])
...
...
pbdlib/plot.py
View file @
92294c29
...
...
@@ -520,6 +520,10 @@ def plot_gmm(Mu, Sigma, dim=None, color=[1, 0, 0], alpha=0.5, linewidth=1, marke
l
,
=
plt
.
plot
(
Mu
[
0
,
i
],
Mu
[
1
,
i
],
'.'
,
color
=
c
,
alpha
=
a
)
# Mean
else
:
l
,
=
plt
.
plot
(
Mu
[
i
,
0
],
Mu
[
i
,
1
],
'.'
,
color
=
c
,
alpha
=
a
)
# Mean
if
border
:
plt
.
plot
(
points
[
0
,
:],
points
[
1
,
:],
color
=
c
,
linewidth
=
linewidth
,
markersize
=
markersize
)
# Contour
# plt.plot(points[0,:], points[1,:], color=c, linewidth=linewidth , markersize=markersize) # Contour
return
l
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment