20 #include <boost/shared_ptr.hpp> 27 #include <Eigen/Cholesky> 31 using namespace Eigen;
60 this->covariance = covariance;
61 this->dimension = means.size();
66 LLT<MatrixXf> lltOfA(covariance);
67 this->L = lltOfA.matrixL();
85 normal_dist->sampleRandomValues(z, dimension);
87 VectorXf Z = initVectorXf(z);
88 VectorXf mu = initVectorXf(means);
89 VectorXf X = mu + L * Z;
93 for(
int i=0; i < dimension; i++)
95 x.push_back(*(t1 + i));
113 VectorXf
x(values.size());
114 for(
unsigned int i=0; i<values.size();i++)
127 MatrixXf
initMatrixXf(std::vector<float> values,
unsigned int rows,
unsigned int cols)
132 MatrixXf
x(rows, cols);
133 for(
unsigned int i=0; i < rows;i++)
135 for(
unsigned int j=0; j < cols; j++)
137 x(i,j) = values.at(i*cols + j);
151 std::stringstream ss(csv);
157 if (ss.peek() ==
',' || ss.peek() ==
' ')
168 cout <<
"The means are " << endl << initVectorXf(this->means) << endl;
169 cout <<
"The matrix A is" << endl << covariance << endl;
170 cout <<
"The Cholesky factor L is" << endl << L << endl;
171 cout <<
"To check this, let us compute L * L.transpose()" << endl;
172 cout << L * L.transpose() << endl;
173 cout <<
"This should equal the matrix A" << endl;
MultidimensionalGaussian(std::vector< float > means, MatrixXf covariance)
VectorXf initVectorXf(std::vector< float > values)
MatrixXf initMatrixXf(std::vector< float > values, unsigned int rows, unsigned int cols)
std::vector< float > getMean()
void sampleRandomValues(std::vector< float > &x)
boost::shared_ptr< Gaussian > GaussianPtr
void initVectorFromCSVString(std::vector< float > &x, std::string csv)
TFSIMD_FORCE_INLINE const tfScalar & x() const
TFSIMD_FORCE_INLINE const tfScalar & z() const
boost::shared_ptr< MultidimensionalGaussian > MultidimensionalGaussianPtr
std::vector< float > means