Commit f414e85e authored by mzed's avatar mzed
Browse files

bayes working in js, changing default jump_rate

parent 29ff726e
......@@ -12,15 +12,15 @@ int main(int argc, const char * argv[]) {
rapidStream<double> rapidProcess;
rapidProcess.bayesSetDiffusion(-2.0);
rapidProcess.bayesSetJumpRate(-5.0);
rapidProcess.bayesSetJumpRate(-10.0);
rapidProcess.bayesSetMVC(1.);
double bayes = 0.;
for (int i = 0; i < 100; ++i) {
bayes = rapidProcess.bayesFilter(i/100.);
std::cout << "bayes: " << bayes <<std::endl;
//std::cout << "bayes: " << bayes <<std::endl;
}
// bayes > 0.99);
assert( bayes > 0.68 );
//vanAllenTesting
seriesClassification testDTW;
......
......@@ -629,6 +629,15 @@ Module.StreamBuffer.prototype = {
bayesFilter: function (input) {
return this.rapidStream.bayesFilter(parseFloat(input));
},
bayesSetDiffusion: function (input) {
this.rapidStream.bayesSetDiffusion(parseFloat(input));
},
bayesSetJumpRate: function (input) {
this.rapidStream.bayesSetJumpRate(parseFloat(input));
},
bayesSetMVC: function (input) {
this.rapidStream.bayesSetMVC(parseFloat(input));
},
/**
* Calculate the minimum first-order difference over consecutive inputs in the buffer.
* @return {number} minimum velocity.
......
......@@ -25,7 +25,7 @@ rapidStream<T>::rapidStream(int window_size) {
//Baysian Filter setup
bayesFilt.diffusion = powf(10., -2);
bayesFilt.jump_rate = powf(10., -5);
bayesFilt.jump_rate = powf(10., -10);
bayesFilt.mvc[0] = 1.;
bayesFilt.init();
......@@ -143,8 +143,6 @@ T rapidStream<T>::bayesFilter(T input) {
template<typename T>
void rapidStream<T>::bayesSetDiffusion(float diffusion) {
bayesFilt.diffusion = powf(10., diffusion);
//bayesFilt.jump_rate = powf(10., -5);
//bayesFilt.mvc[0] = 1.;
bayesFilt.init();
}
......
......@@ -449,6 +449,9 @@ describe('RapidLib Signal Processing', function () {
});
describe('when streaming to bayesFilter', function() {
let bf = new rapidMix.StreamBuffer();
bf.bayesSetDiffusion(-2.0);
bf.bayesSetJumpRate(-5.0);
bf.bayesSetMVC(1.0);
console.log("ok " + bf.bayesFilter(0.2));
});
});
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment