1.3K views

Uploaded by pi194043

Implementation for computing the probaility density of multivariate gaussian random variable using Eigen Linear Algebra library

save

You are on page 1of 4

Pi19404

February 21, 2014

0.1 Introduction

In this article we will look at the multivariate gaussian distribution.

The mutivariate gaussian distribution is parameterized by mean vector and covariance matrix .

fx (x1 ; : : : ; xk ) = p

(2 )k

jj

exp

2 (x )

1

1(x ) ;

where is a Nx1 mean vector is NxN matrix covariance matrix j j is the determinant of

The mutivariate gaussian is also used as probability density function of the vector X A naive way of implementation is to directly perform the computation as in the equation to get the result. A Gaussian is defined Since ill be using a lot of opencv conversion routines are defined for Opencv cv::Mat data structure to Eigen::MatrixXf data structure. when loading the covarince matrix ,the determinant,inverse etc are also computed which would be later required for probability calculation

2|4

} void setSigma(cv::Mat &v) { Map<Eigen::Matrix<float,Dynamic,Dynamic,Eigen::RowMajor> > mappedMat((float *)v.data,v.rows,v.cols) ; _Sigma=mappedMat; _dim=v.rows; _det=_Sigma.determinant(); _scale=1.f/(pow(2*PI*_dim*_det,0.5)); _invsigma=_Sigma.inverse(); } MatrixXf setData(cv::Mat &v) { Map<Eigen::Matrix<float,Dynamic,Dynamic,Eigen::RowMajor> > mappedMat((float *)v.data,1,v.cols) ; MatrixXf ref=mappedMat; return ref; }

void validate(float &res) { if(res<0) res=0; if(res>1) res=1; if(isnan(res)) res=0; } float Prob(Mat &x) { MatrixXf tmp=setData(x); float res=0; MatrixXf tmp1=(tmp-_mu); MatrixXf tmp2=tmp1*_invsigma*tmp1.transpose(); res=scale*tmp2(0,0); validate(res); return res; }

3|4

The covariance matrix is postive semidefinate and symmteric The Cholesky decomposition of a symmetric, positive definite matrix decom- poses A into a product of a lower triangular matrix L and its transpose.

thus we can only compute (L1

Thus we can perform the Cholskey factorization of the covariance matrix to find

float Prob(Mat &x) { MatrixXf tmp=setData(x); float res=0; MatrixXf tmp1=(tmp-_mu).transpose(); tmp1=_LI*tmp1; MatrixXf tmp2=tmp1.transpose()*tmp1; res=tmp2(0,0); validate(res); return res;

0.1.1 Code

The code can be found at git repository https://github.com/ pi19404/OpenVision in files ImgML/gaussian.hpp and ImgML.gaussian.cpp files.

4|4

- temporal filtersUploaded bypi194043
- Gesture Recognition using Hidden Markov ModeUploaded bypi194043
- polynomial approximation of a 2D signalUploaded bypi194043
- Modified Canny Edge DetectionUploaded bypi194043
- Polynomial Approximation of 1D signalUploaded bypi194043
- Multi Class Logistic Regression Training and TestingUploaded bypi194043
- OpenCL Image Convolution Filter - Box FilterUploaded bypi194043
- ARM Neon Optimization for image interleaving and deinterleavingUploaded bypi194043
- A linear channel filterUploaded bypi194043
- Adaptive Skin Color DetectorUploaded bypi194043
- OpenVision Library Gaussian Mixture Model ImplementationUploaded bypi194043
- Fast 2D Separable Symmetric/Anti-Symmmetric ConvolutionUploaded bypi194043
- Dense optical flow expansion based on polynomial basis approximationUploaded bypi194043
- Seeded Region Growing using Line Scan algorithm - Stack base ImplementationUploaded bypi194043
- Normalized convolution for image interpolationUploaded bypi194043
- Android OpenCV Face detectionUploaded bypi194043
- shape classification using Histogram of oriented gradientsUploaded bypi194043
- Noise Models in Image processingUploaded bypi194043
- hess-13-2299-2009Uploaded bymm507
- Ten Deadly Statistical Traps in Pharmaceutical Quality ControlUploaded byvkumar6883
- Image enhancement using FusionUploaded bypi194043
- Region Growing Algorithm For UnderWater Image SegmentationUploaded bypi194043
- Anderson & Gerbing SEM 2steps PB1988 HARDUploaded byAlexThucHien
- Spatio Temporal Feature extraction using harris 3d corner detectorUploaded bypi194043
- Continuous Emission Hidden Markov Model for sequence classificationUploaded bypi194043
- Control Limited Adaptive Histogram Equalization for Image EnhancementUploaded bypi194043
- POM Lecture (27)Uploaded bymuneerpp
- Murphy GaussiansUploaded byp
- Markov chain implementation in C++ using EigenUploaded bypi194043
- Trial Lecture Hobaek HaffUploaded byWaode Rachmaniyah

- Polynomial Approximation of 2D image patch -Part 2Uploaded bypi194043
- Compiling Native C/C++ library for AndroidUploaded bypi194043
- Multi Class Logistic Regression Training and TestingUploaded bypi194043
- ARM Neon Optimization for image interleaving and deinterleavingUploaded bypi194043
- A linear channel filterUploaded bypi194043
- Adaptive Skin Color DetectorUploaded bypi194043
- OpenVision Library Gaussian Mixture Model ImplementationUploaded bypi194043
- Continuous Emission Hidden Markov Model for sequence classificationUploaded bypi194043
- Fast 2D Separable Symmetric/Anti-Symmmetric ConvolutionUploaded bypi194043
- Dense optical flow expansion based on polynomial basis approximationUploaded bypi194043
- Implementation of discrete hidden markov model for sequence classification in C++ using EigenUploaded bypi194043
- Markov chain implementation in C++ using EigenUploaded bypi194043
- C++ InheritanceUploaded bypi194043
- Local Binary PatternUploaded bypi194043
- Mean Shift AlgorithmUploaded bypi194043
- C++ Const,Volatile Type QualifiersUploaded bypi194043
- Random Ferns for Patch DescriptionUploaded bypi194043
- Integral Image for Computation of Mean And VarianceUploaded bypi194043
- C++ Class Members and friendsUploaded bypi194043
- Embedded Systems Programming with ARM on Linux - Blinking LEDUploaded bypi194043
- C++ virtual functions and abstract classUploaded bypi194043
- C++ static members and functionUploaded bypi194043
- Mean Shift TrackingUploaded bypi194043
- Uniform Local Binary Pattern and Spatial Histogram ComputationUploaded bypi194043
- Tan and Triggs Illumination normalizationUploaded bypi194043
- Normalized convolution for image interpolationUploaded bypi194043

- Control Por Discretizacion de StcUploaded byEdilberto Montero
- LAB3.1-3.3Uploaded byFederico Lozano Santamaria
- Simplex Method - 4th Semester - Numerical ProgrammingUploaded byMyWBUT - Home for Engineers
- 4ALesercitazione3_logaritmi_1617Uploaded bymaurizio_pischi5880
- Apostila VetoresUploaded byAriomar Cordeiro
- Ecuaciones e InecuacionesUploaded bydianny
- Bioestadistica Tema 02Uploaded byJuno Baez Ingeniero
- ComputationalFluidDynamics_20140910.pdfUploaded byAdebanjo Tomisin
- Libro Calve cUploaded byAndrew Jones
- Matematicas 4Uploaded byalan696
- Koch I. Analysis of Multivariate and High-Dimensional Data 2013Uploaded byrciani
- Valores y Vectores PropiosUploaded byPaul Albaracin
- cap2_3Uploaded byDavid Alejandro Diaz Muñoz
- hw4-sol - CopyUploaded byrupadn
- lab1Uploaded byMichel Voyer
- ANALISIS CANÓNICO DE POBLACIONES Y MÉTODOS RELACIONADOS.Uploaded bygabigaralb
- CuaternionesUploaded byMAYREADA
- labantenas.pdfUploaded byPaulo Sergio Dalvi
- Georgi Lecture Notes on Weak Interactions Physics Harvard Web Draft 1998Uploaded bymanosmagicas7340
- ManualUploaded byHandiSetiadi
- Calculo1_aula05 Limitess Laterais[1]Uploaded byIara Mesquita
- medicion promedioUploaded byNick Bendezú Sánchez
- Mat021 Guia Funciones Continuas StgoUploaded byCeeiqa Usm
- Estimation 2Uploaded byjlosam
- Fisica LSUploaded byIngegnere Pazzo
- Mecanica Celeste Una Introduccion.Uploaded byCarlos Vázquez Monzón
- Abarbanel .-. the Analysis of Observed Chaotic Data in Physical SystemsUploaded byluizomar
- Ejercicios Sobre Calculo Integral (1)Uploaded byJesus David Avellaneda Martinez
- Ecuaciones de orden superior especialesUploaded byJhon Uquillas
- Basics on Hermitian Symmetric SpacesUploaded byAdriano João da Silva