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
Matthias Mayr
limbo
Commits
69069654
Unverified
Commit
69069654
authored
Jun 21, 2018
by
Konstantinos Chatzilygeroudis
Committed by
GitHub
Jun 21, 2018
Browse files
Merge pull request #273 from resibots/fix_gp
Fix GP sigma prediction
parents
2bb26473
5c768708
Changes
2
Show whitespace changes
Inline
Side-by-side
src/limbo/model/gp.hpp
View file @
69069654
...
...
@@ -160,15 +160,15 @@ namespace limbo {
{
if
(
_samples
.
size
()
==
0
)
return
std
::
make_tuple
(
_mean_function
(
v
,
*
this
),
_kernel_function
(
v
,
v
));
_kernel_function
(
v
,
v
)
+
_kernel_function
.
noise
()
);
Eigen
::
VectorXd
k
=
_compute_k
(
v
);
return
std
::
make_tuple
(
_mu
(
v
,
k
),
_sigma
(
v
,
k
));
return
std
::
make_tuple
(
_mu
(
v
,
k
),
_sigma
(
v
,
k
)
+
_kernel_function
.
noise
()
);
}
/**
\\rst
return :math:`\mu` (unormalized). If there is no sample, return the value according to the mean function.
return :math:`\mu` (un
-n
ormalized). If there is no sample, return the value according to the mean function.
\\endrst
*/
Eigen
::
VectorXd
mu
(
const
Eigen
::
VectorXd
&
v
)
const
...
...
@@ -180,14 +180,14 @@ namespace limbo {
/**
\\rst
return :math:`\sigma^2` (unormalized). If there is no sample, return the max :math:`\sigma^2`.
return :math:`\sigma^2` (un
-n
ormalized). If there is no sample, return the max :math:`\sigma^2`.
\\endrst
*/
double
sigma
(
const
Eigen
::
VectorXd
&
v
)
const
{
if
(
_samples
.
size
()
==
0
)
return
_kernel_function
(
v
,
v
);
return
_sigma
(
v
,
_compute_k
(
v
));
return
_kernel_function
(
v
,
v
)
+
_kernel_function
.
noise
()
;
return
_sigma
(
v
,
_compute_k
(
v
))
+
_kernel_function
.
noise
()
;
}
/// return the number of dimensions of the input
...
...
src/tests/test_gp.cpp
View file @
69069654
...
...
@@ -474,7 +474,7 @@ BOOST_AUTO_TEST_CASE(test_gp_dim)
BOOST_CHECK
(
std
::
abs
((
mu
(
0
)
-
5
))
<
1
);
BOOST_CHECK
(
std
::
abs
((
mu
(
1
)
-
5
))
<
1
);
BOOST_CHECK
(
sigma
<=
Params
::
kernel
::
noise
()
+
1e-8
);
BOOST_CHECK
(
sigma
<=
2.
*
(
Params
::
kernel
::
noise
()
+
1e-8
)
)
;
}
BOOST_AUTO_TEST_CASE
(
test_gp
)
...
...
@@ -496,15 +496,15 @@ BOOST_AUTO_TEST_CASE(test_gp)
double
sigma
;
std
::
tie
(
mu
,
sigma
)
=
gp
.
query
(
make_v1
(
1
));
BOOST_CHECK
(
std
::
abs
((
mu
(
0
)
-
5
))
<
1
);
BOOST_CHECK
(
sigma
<=
Params
::
kernel
::
noise
()
+
1e-8
);
BOOST_CHECK
(
sigma
<=
2.
*
(
Params
::
kernel
::
noise
()
+
1e-8
)
)
;
std
::
tie
(
mu
,
sigma
)
=
gp
.
query
(
make_v1
(
2
));
BOOST_CHECK
(
std
::
abs
((
mu
(
0
)
-
10
))
<
1
);
BOOST_CHECK
(
sigma
<=
Params
::
kernel
::
noise
()
+
1e-8
);
BOOST_CHECK
(
sigma
<=
2.
*
(
Params
::
kernel
::
noise
()
+
1e-8
)
)
;
std
::
tie
(
mu
,
sigma
)
=
gp
.
query
(
make_v1
(
3
));
BOOST_CHECK
(
std
::
abs
((
mu
(
0
)
-
5
))
<
1
);
BOOST_CHECK
(
sigma
<=
Params
::
kernel
::
noise
()
+
1e-8
);
BOOST_CHECK
(
sigma
<=
2.
*
(
Params
::
kernel
::
noise
()
+
1e-8
)
)
;
for
(
double
x
=
0
;
x
<
4
;
x
+=
0.05
)
{
Eigen
::
VectorXd
mu
;
...
...
@@ -690,15 +690,15 @@ BOOST_AUTO_TEST_CASE(test_gp_auto)
double
sigma
;
std
::
tie
(
mu
,
sigma
)
=
gp
.
query
(
make_v1
(
1
));
BOOST_CHECK
(
std
::
abs
((
mu
(
0
)
-
5
))
<
1
);
BOOST_CHECK
(
sigma
<=
gp
.
kernel_function
().
noise
()
+
1e-8
);
BOOST_CHECK
(
sigma
<=
2.
*
(
gp
.
kernel_function
().
noise
()
+
1e-8
)
)
;
std
::
tie
(
mu
,
sigma
)
=
gp
.
query
(
make_v1
(
2
));
BOOST_CHECK
(
std
::
abs
((
mu
(
0
)
-
10
))
<
1
);
BOOST_CHECK
(
sigma
<=
gp
.
kernel_function
().
noise
()
+
1e-8
);
BOOST_CHECK
(
sigma
<=
2.
*
(
gp
.
kernel_function
().
noise
()
+
1e-8
)
)
;
std
::
tie
(
mu
,
sigma
)
=
gp
.
query
(
make_v1
(
3
));
BOOST_CHECK
(
std
::
abs
((
mu
(
0
)
-
5
))
<
1
);
BOOST_CHECK
(
sigma
<=
gp
.
kernel_function
().
noise
()
+
1e-8
);
BOOST_CHECK
(
sigma
<=
2.
*
(
gp
.
kernel_function
().
noise
()
+
1e-8
)
)
;
}
BOOST_AUTO_TEST_CASE
(
test_gp_init_variance
)
...
...
Write
Preview
Supports
Markdown
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