32 #ifndef SHARK_STATISTICS_MULTIVARIATENORMALDISTRIBUTION_H 33 #define SHARK_STATISTICS_MULTIVARIATENORMALDISTRIBUTION_H 47 typedef std::pair<RealVector,RealVector> result_type;
52 m_covarianceMatrix = Sigma;
62 template<
typename Archive>
63 void serialize( Archive & ar,
const std::size_t version ) {
64 ar & BOOST_SERIALIZATION_NVP( m_covarianceMatrix );
65 ar & BOOST_SERIALIZATION_NVP( m_decomposition );
71 m_covarianceMatrix = blas::identity_matrix<double>( size );
77 return m_covarianceMatrix;
85 return m_covarianceMatrix;
96 return m_decomposition.Q();
101 return m_decomposition.D();
105 template<
class randomType>
107 RealVector z( m_covarianceMatrix.size1() );
109 for( std::size_t i = 0; i < z.size(); i++ ) {
113 RealVector result = m_decomposition.Q() % to_diagonal(sqrt(max(
eigenValues(),0))) % z;
114 return std::make_pair( result, z );
119 m_decomposition.decompose(m_covarianceMatrix);
123 RealMatrix m_covarianceMatrix;
124 blas::symm_eigenvalue_decomposition<RealMatrix> m_decomposition;
135 typedef std::pair<RealVector,RealVector> result_type;
149 template<
typename Archive>
150 void serialize( Archive & ar,
const std::size_t version ) {
151 ar & BOOST_SERIALIZATION_NVP( m_cholesky);
157 m_cholesky = blas::identity_matrix<double>( size );
162 return m_cholesky.lower_factor().size1();
167 return m_cholesky.lower_factor();
173 m_cholesky.decompose(matrix);
178 m_cholesky.update(alpha,beta,v);
181 template<
class randomType,
class Vector1,
class Vector2>
182 void generate(randomType& rng, Vector1& y, Vector2& z)
const{
185 for( std::size_t i = 0; i != size(); i++ ) {
188 noalias(y) = blas::triangular_prod<blas::lower>(m_cholesky.lower_factor(),z);
195 template<
class randomType>
198 RealVector& z = result.second;
199 RealVector& y = result.first;
205 blas::cholesky_decomposition<blas::matrix<double,blas::column_major> > m_cholesky;