Home | Develop | Download | Contact
example_probability_gaussian.cpp

Programa para el testeo de las funciones.Para compilar o código example_probability_gaussian.cpp:

g++ -static -o example_probability_gaussian example_probability_gaussian.cpp -lpdsmlmm -lpdsramm -lpdsspmm

Para executar o programa:

./example_probability_gaussian

Retornando por consola:

X.Size():
2000    2
Mu:
-0.023392411833952      0.019244496951369
Sigma:
4.0276987303483 -0.50653582614593
-0.50653582614593       0.98095013247813
R.MtM():
4.04    -0.6
-0.6    1.04
Anomaly detection - data
Anomaly detection - probability

Código example_probability_gaussian.cpp:

#include <iostream>
#include <Pds/Ra>
#include <Pds/Ml>
int main(void)
{
Pds::Octave::XLabel="x1";
Pds::Octave::YLabel="x2";
Pds::Octave::DAspect=true;
unsigned int L=2000;
Pds::Matrix X;
Pds::Matrix Mu;
Pds::Matrix Sigma;
Pds::Vector P;
Pds::Matrix R("2 -0.2\n-0.2 1");
// Generating data X=[x1 x2]
X=Pds::MergeHor({ Pds::RandN(L,1) , Pds::RandN(L,1) });
X=X*R;
Pds::Octave::Plot::PointsX2D(X,"testando.m","example_probability_gaussian_data.png");
// Mu, Sigma estimation
Sigma=X.CovMatrix(Mu);
std::cout<<"X.Size():\n"<<X.Size()<<"\n";
std::cout<<"Mu:\n"<<Mu;
std::cout<<"Sigma:\n"<<Sigma;
std::cout<<"R.MtM():\n"<<R.MtM();
// Anomaly detection
P=Pds::Probability::MGaussian(X,Mu,Sigma.Inv());
Pds::Octave::Plot::ScatterX2DY(X,P,"testando.m","example_probability_gaussian_prob.png");
return 0;
}
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