• R/O
  • SSH
  • HTTPS

particle-filter: 提交


Commit MetaInfo

修订版24 (tree)
时间2010-06-01 20:49:43
作者(del#42041)

Log Message

sample "step" in progress 70%

更改概述

差异

--- sample/step.cc (revision 23)
+++ sample/step.cc (revision 24)
@@ -9,7 +9,7 @@
99 p[i][j]= p[i][j]+v[i][j];
1010 }
1111 }
12- cout<<"state function"<<endl;
12+// cout<<"state function"<<endl;
1313 return(p);
1414 }
1515 double func2(Particles<double> &p, Particle<double> &q)
@@ -34,21 +34,31 @@
3434 Filter track;
3535 MTRand mtrand;
3636 mtrand.seed(time(NULL));
37- track.setNumber(5);
37+ track.setNumber(50);
3838 track.setDimension(1);
3939 track.set_state_func(&func1);
4040 track.set_robserve_func(&func2);
4141 track.set_robserve_jacobian_func(&func3);
42- track.set_robserve_density_func(func4);
42+ track.set_robserve_density_func(&func4);
4343 track.createInitialParticles();
44- double t,y;
45- Particles<double> y(5,1);
44+ double t;
45+ Particles<double> x(50,1), y(50,1);
4646 for(int i=0;i<100;++i)
4747 {
48- track.get_next_state() // predict
48+ track.create_system_noise();
49+ track.get_next_state(); // predict
4950 t = i<25?1:i<50?0:i<75?-1:1;
50- y[0] = t + mtrand.rand();
51-cout<<y[0]<<endl;
52-
51+ y[0][0] = t + mtrand.rand();
52+//cout<<y[0][0]<<endl;
53+ track.set_observed_data(y);
54+ track.compute_likelihood();
55+ track.resampling();
56+ x = track.get_particles();
57+ double x_=0.0;
58+ for(int j=0;j<x.size();++j)
59+ {
60+ x_ += x[j][0];
61+ }
62+cout<<x_/x.size()<<endl;
5363 }
5464 }
\ No newline at end of file
Show on old repository browser