Home | Develop | Download | Contact
example_probability_gaussian3.cpp
1 
32 #include <iostream>
33 #include <Pds/Ra>
34 #include <Pds/Ml>
35 
36 int main(void)
37 {
38  Pds::Octave::XLabel="x1";
39  Pds::Octave::YLabel="x2";
40  Pds::Octave::DAspect=true;
41 
42  unsigned int L=2000;
43  Pds::Matrix X;
44  Pds::Matrix Mu;
45  Pds::Matrix Sigma;
46  Pds::Vector P;
47  Pds::Matrix R("2 -0.2\n-0.2 1");
48 
49  // Generating data X=[x1 x2]
50  X=Pds::MergeHor({ Pds::RandN(L,1) , Pds::RandN(L,1) });
51  X=X*R;
52 
53  Pds::Octave::Plot::PointsX2D(X,"testando.m","example_probability_gaussian3_data.png");
54 
55  // Mu, Sigma estimation
56  Sigma=X.CovMatrix(Mu);
57 
58  std::cout<<"X.Size():\n"<<X.Size()<<"\n";
59  std::cout<<"Mu:\n"<<Mu;
60  std::cout<<"Sigma:\n"<<Sigma;
61  std::cout<<"R.MtM():\n"<<R.MtM();
62 
63  // Anomaly detection
64  P=Pds::Probability::MGaussian(X,Mu,Sigma.Inv());
65 
66  Pds::Octave::Plot::ScatterX2DY(X,P,"testando.m","example_probability_gaussian3_prob.png");
67 
68  return 0;
69 }
Pds::Vector MGaussian(const Pds::Matrix &X, const Pds::Vector &Mu, const double &Sigma)
Evalua la "probability density function" de la funcion gaussiana multivariada, usando ,...

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed