00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2009 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 #ifndef mrpt_math_distributions_H 00029 #define mrpt_math_distributions_H 00030 00031 #include <mrpt/utils/utils_defs.h> 00032 #include <mrpt/math/CMatrixTemplateNumeric.h> 00033 #include <mrpt/math/CVectorTemplate.h> 00034 00035 /*--------------------------------------------------------------- 00036 Namespace 00037 ---------------------------------------------------------------*/ 00038 namespace mrpt 00039 { 00040 namespace math 00041 { 00044 double MRPTDLLIMPEXP normalPDF(double x, double mu, double std); 00045 00048 template <class T> 00049 T normalPDF( 00050 const CMatrixTemplateNumeric<T> &x, 00051 const CMatrixTemplateNumeric<T> &mu, 00052 const CMatrixTemplateNumeric<T> &cov) 00053 { 00054 MRPT_TRY_START; 00055 00056 CMatrixTemplateNumeric<T> S = cov.inv(); 00057 size_t d = cov.getRowCount(); // Dimension: 00058 CMatrixTemplateNumeric<T> X, MU, X_MU; 00059 00060 if (x.getRowCount()==1) 00061 X = ~x; 00062 else X = x; 00063 00064 if (mu.getRowCount()==1) 00065 MU = ~mu; 00066 else MU = mu; 00067 00068 X_MU = X - MU; 00069 00070 return ::exp( static_cast<T>(-0.5) * ( (~X_MU)*S*X_MU )(0,0) ) / (::pow(static_cast<T>(M_2PI),static_cast<T>(d)) * ::sqrt(cov.det())); 00071 00072 MRPT_TRY_END; 00073 } 00074 00077 double MRPTDLLIMPEXP erfc(double x); 00078 00081 double MRPTDLLIMPEXP erf(double x); 00082 00087 double MRPTDLLIMPEXP normalQuantile(double p); 00088 00093 double MRPTDLLIMPEXP normalCDF(double p); 00094 00098 double MRPTDLLIMPEXP chiSquareQuantile(double P, unsigned int dim=1); 00099 00100 00101 } // End of MATH namespace 00102 00103 } // End of namespace 00104 00105 00106 #endif
Page generated by Doxygen 1.5.7.1 for MRPT 0.6.5 SVN: at Mon Feb 23 13:25:04 EST 2009 |