32 #include <bias_config.h>
34 #include <MathAlgo/LDA.hh>
35 #include <Base/Math/Random.hh>
40 int main(
int args,
char **arg)
43 myLDA.SetDebugLevel(1+2);
45 std::vector<std::vector<BIAS::Vector<LDAType> > > vec;
48 int reductionSize = 2;
49 std::vector<BIAS::Matrix<LDAType> > *covs = NULL;
50 unsigned int classes = 3;
51 unsigned int numsamples = 1000;
57 for (
unsigned int i=2; i<dim; i++) sigma[i] = 0.1;
62 vector<Vector<LDAType> > means;
63 for (
unsigned int c=0; c<classes; c++){
65 means.push_back(curMean);
67 case 0: curMean[0] = -1;curMean[1] = 0;
break;
68 case 1: curMean[0] = 1;curMean[1] = 0;
break;
69 case 2: curMean[0] = 0.1f;curMean[1] = -0.1f;
break;
71 for (
unsigned int d=0; d<dim; d++) {
78 cout<<
"mean "<<c<<
" is "<<curMean<<endl;
79 std::vector<BIAS::Vector<LDAType> > curvec;
80 for (
unsigned int i=0; i<numsamples; i++) {
82 for (
unsigned int d=0; d<dim; d++) {
84 estMean[d] += sample[d];
86 curvec.push_back(sample);
88 for (
unsigned int d=0; d<dim; d++) {
89 estMean[d] /= float(numsamples);
91 cout<<
"estimated mean is "<<estMean<<endl;
92 vec.push_back(curvec);
104 myLDA.ComputeReductionMatrix(vec, matrix, reductionSize, covs);
105 cout<<
"Reduction matrix is "<<matrix<<endl;
linear discriminant analysis on a set of classes of vectors LDA is a approach for dimension-reduction...
double GetUniformDistributed(const double min, const double max)
on succesive calls return uniform distributed random variable between min and max ...
matrix class with arbitrary size, indexing is row major.
double GetNormalDistributed(const double mean, const double sigma)
on succesive calls return normal distributed random variable with mean and standard deviation sigma ...
class for producing random numbers from different distributions