Home | Develop | Download | Contact
example_probability_gaussian2.cpp
1 
28 #include <iostream>
29 #include <Pds/Ra>
30 #include <Pds/Ml>
31 
32 int main(void)
33 {
34  Pds::Octave::XLabel="x1";
35  Pds::Octave::YLabel="x2";
36  Pds::Octave::DAspect=true;
37 
38  unsigned int L=2000;
39  Pds::Matrix X;
40  Pds::Matrix Mu;
41  double Sigma;
42  Pds::Vector P;
43 
44  // Generating data X=[x1 x2]
45  X=Pds::MergeHor({ Pds::RandN(L,1) , Pds::RandN(L,1) });
46 
47  Pds::Octave::Plot::PointsX2D(X,"testando.m","example_probability_gaussian2_data.png");
48 
49  // Mu, Sigma estimation
50  Sigma=sqrt(X.CovMatrix(Mu).Det());
51 
52  std::cout<<"X.Size():\n"<<X.Size()<<"\n";
53  std::cout<<"Mu:\n"<<Mu;
54  std::cout<<"Sigma:\n"<<Sigma<<"\n";
55 
56  // Anomaly detection
57  P=Pds::Probability::MGaussian(X,Mu,Sigma);
58 
59  Pds::Octave::Plot::ScatterX2DY(X,P,"testando.m","example_probability_gaussian2_prob.png");
60 
61  return 0;
62 }
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