27 this->dimension = dimension;
31 this->mean = value_type::Zero(dimension, 1);
41 this->cov = covariance;
44 dimension = cov.rows();
46 if (mean.rows() != dimension)
62 if (point.rows() != dimension)
68 double e = exp(inner(0, 0));
81 if (point.rows() != dimension)
87 dist = (point - mean).
transpose() * cov.inverse() * (point - mean);
103 float fRand1, fRand2;
109 fRand1 =
float(rand()) / RAND_MAX;
110 fRand2 =
float(rand()) / RAND_MAX;
113 gaussianSample(d) =
sqrt(-2 * log(fRand1)) * cos(2 *
M_PI * fRand2);
140 float fRand1, fRand2;
146 fRand1 =
float(rand()) / RAND_MAX;
147 fRand2 =
float(rand()) / RAND_MAX;
150 gaussianSample(d) =
sqrt(-2 * log(fRand1)) * cos(2 *
M_PI * fRand2);
160 A(i, u) =
sqrt(cov(i, u));
182 if (samples.rows() != dimension)
187 int numberSamples = samples.cols();
190 mean = value_type::Zero(dimension, 1);
192 for (
int i = 0 ; i < numberSamples ; i++)
194 mean += samples.block(0, i, mean.rows(), 1);
197 mean = mean / numberSamples;
202 for (
int s = 0 ;
s < numberSamples ;
s++)
204 meanadj.block(0,
s, meanadj.rows(), 1) -= mean;
208 cov = meanadj * meanadj.transpose() / numberSamples;
218 this->mean = prototype.
getMean();
226 if ((dimension != -1) && (mean.rows() != dimension))
231 if ((dimension != -1) && (cov.rows() != dimension))
238 dimension = cov.rows();
247 if ((dimension != -1) && (mean.rows() != dimension))
254 dimension = mean.rows();
263 if ((dimension != -1) && (cov.rows() != dimension))
268 if ((dimension != -1) && (cov.cols() != dimension))
273 if ((dimension == -1) && (cov.rows() != cov.cols()))
280 dimension = cov.rows();
281 this->mean = Eigen::VectorXd::Zero(dimension);
290 void Gaussian::isSymmetric(
const covariance_type& matrix)
292 if (matrix.rows() != matrix.cols())
297 for (
int r = 0 ; r < matrix.rows() ; r++)
299 for (
int c = 0 ;
c < matrix.cols() ;
c++)
301 if (matrix(r,
c) != matrix(
c, r))