Example2D for random number generator
- Author
- MIP
#ifdef WIN32
# include "Base/Common/W32Compat.hh"
# include <math.h>
#endif
#include <cmath>
#include <cstring>
#include <Base/Math/Random.hh>
using namespace BIAS;
using namespace std;
#define COUNT 9000
int main()
{
double cov_max=100.0;
double sigma1, sigma2;
cov[0][0] = cos(ang) * cos(ang) * sigma1 + sin(ang) * sin(ang) * sigma2;
cov[1][1] = cos(ang) * cos(ang) * sigma2 + sin(ang) * sin(ang) * sigma1;
cov[0][1] = (sigma1-sigma2)*cos(ang)*sin(ang);
cov[1][0] = (sigma1-sigma2)*cos(ang)*sin(ang);
cout << "input mean: "<<mean<<endl;
cout << "input covariance: "<<cov<<endl;
vector<Vector2<double> > points;
BIASERR("error");
return -1;
}
double dx, dy;
for (register unsigned int i=0; i<COUNT; i++){
omean[0]+=points[i][0];
omean[1]+=points[i][1];
}
omean[0]/=COUNT;
omean[1]/=COUNT;
cout << "output mean:" << omean << endl;
for (register unsigned int i=0; i<COUNT; i++){
dx = points[i][0]-omean[0];
dy = points[i][1]-omean[1];
ocov[0][0] += dx*dx;
ocov[1][1] += dy*dy;
ocov[0][1] += dx*dy;
}
ocov[1][0]=ocov[0][1];
ocov/=(double)(COUNT-1);
cout << "output covariance:" << ocov << endl;
return 0;
}