this is an example transforming uncertainty with UnscentedTransform , MonteCarloTransform
#include <MathAlgo/UnscentedTransform.hh>
#include <MathAlgo/MonteCarloTransform.hh>
#include <Base/Math/Random.hh>
using namespace BIAS;
using namespace std;
{
const int dim = src.
Size();
dst = T * src;
}
{
const int dim = src.
Size();
const double c[] = { 1.0, 2.0, 0.0 };
const int numc = 3;
const int num = dim*dim;
for (int i=0; i<num; i++){
}
dst = T * src;
}
{
const double c[] = { 1.57, 3.14, 6.28 };
const int dim = src.
Size();
for (int i=0; i<dim; i++){
dst[i] = c[0] + c[1] * src[i] + c[2] * src[i] * src[i];
}
}
{
MyLinTransform(src, dst);
}
class MyUnscentedTransform
{
public:
};
virtual ~MyUnscentedTransform() {};
protected:
{
MyTransform(src, dst);
return 0;
}
};
class MyMonteCarloTransform
{
public:
};
virtual ~MyMonteCarloTransform() {};
protected:
{
MyTransform(src, dst);
return 0;
}
};
int main(int , char ** )
{
const int dim = 2;
for (int r=0; r<dim; r++){
for (int c=r; c<dim; c++){
src_cov[r][c] = src_cov[c][r] =
}
src_cov = src_cov * src_cov;
}
cout << "src: "<<src<<endl;
cout << "src_cov: "<<src_cov<<endl;
MyTransform(src, gt_dst);
cout << "T: "<<T<<endl;
cout << "gt: dst: "<<gt_dst<<endl;
cout << "gt: dst_cov: "<<gt_dst_cov<<endl;
MyUnscentedTransform mut;
mut.SetBeta(2.0);
mut.SetAlpha(0.001);
if (mut.Transform(src, src_cov, dst, dst_cov)!=0){
BIASERR("error transforming (unscented)");
return -1;
}
cout << "ut: dst: "<<dst<<endl;
cout << "ut: dst_cov: "<<dst_cov<<endl;
cout << "diff: "<<(dst - gt_dst)<<endl;
cout << "diff cov: "<<(dst_cov - gt_dst_cov)<<endl;
MyMonteCarloTransform mmct;
mmct.SetNumSamplesPerDimension((int)1e2);
mmct.SetUseQuasiRandomNumbers(true);
if (mmct.Transform(src, src_cov, dst, dst_cov)!=0){
BIASERR("error transforming (monte carlo)");
return -1;
}
cout << "mc: dst: "<<dst<<endl;
cout << "mc: dst_cov: "<<dst_cov<<endl;
cout << "diff: "<<(dst - gt_dst)<<endl;
cout << "diff cov: "<<(dst_cov - gt_dst_cov)<<endl;
return 0;
}