I am working on the implementation of the probability density function of a multidimensional Gaussian language in C ++, and I am fixated on how best to handle cases where the dimension is> 2.
A Gaussian PDF file can be written as

where (A) 'or A' is the transposition of the "matrix" created by subtracting the average of all elements x. In this equation, k represents the number of sizes we have, and sigma is the covariance matrix, which is the matrix kx k. Finally, | X | means the determinant of the matrix X.
In the one-dimensional case, the PDF implementation is trivial. Even in the two-dimensional case (k = 2) this is trivial. However, when we go beyond two dimensions, the implementation is much more complicated.
In the two-dimensional case, we would have

where rho is the correlation between x and y, with a correlation equal to

In this case, I could use Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> to implement the first equation, or simply calculate everything myself using the second equation, without using the Eigen interface with simplified linear algebra.
My thoughts about trying a multivariate case are likely to begin with the continuation of the above equations into a multidimensional case

from

My questions:
- Would it be appropriate / recommended to use
boost::multi_array for an n-dimensional array, or should I try using Eigen instead? - Should I have separate functions for one-dimensional / two-dimensional cases, or should I just divert it all to the multidimensional case using boost :: multi_array (or a suitable alternative)?
c ++ boost statistics eigen
kmore
source share