FanucWeb/ActiveBOWeb/src/js_funs/online_rbf_policy.js
Niko 1db897b9d5 active bo implemented
not working due to watch in RosBar.vue line 150
2023-03-20 17:46:59 +01:00

20 lines
558 B
JavaScript

function rbf(x, centre, sigma) {
return Math.exp(-Math.pow(x - centre, 2) / (2 * Math.pow(sigma, 2)));
}
export function computeRbfCurve(nrPoints, weights) {
const centers = Array.from(
{ length: weights.length },
(_, i) => (i * nrPoints) / (weights.length - 1)
);
const sigma = centers[1] / (2 * Math.sqrt(2 * Math.log(2)));
let policy = Array(nrPoints).fill(0);
for (let x = 0; x < nrPoints; x++) {
for (let i = 0; i < centers.length; i++) {
policy[x] += weights[i] * rbf(x, centers[i], sigma);
}
}
return policy;
}