28 this->dimension = dimension;
32 this->mean = value_type::Zero(dimension, 1);
42 this->cov = covariance;
45 dimension = cov.rows();
47 if (mean.rows() != dimension)
64 if (point.rows() != dimension)
70 -0.5 * (point - mean).
transpose() * cov.inverse() * (point - mean);
71 double e = exp(inner(0, 0));
85 if (point.rows() != dimension)
91 dist = (point - mean).
transpose() * cov.inverse() * (point - mean);
108 float fRand1, fRand2;
114 fRand1 =
float(rand()) / RAND_MAX;
115 fRand2 =
float(rand()) / RAND_MAX;
118 gaussianSample(d) =
sqrt(-2 * log(fRand1)) * cos(2 *
M_PI * fRand2);
146 float fRand1, fRand2;
152 fRand1 =
float(rand()) / RAND_MAX;
153 fRand2 =
float(rand()) / RAND_MAX;
156 gaussianSample(d) =
sqrt(-2 * log(fRand1)) * cos(2 *
M_PI * fRand2);
166 A(i, u) =
sqrt(cov(i, u));
189 if (samples.rows() != dimension)
194 int numberSamples = samples.cols();
197 mean = value_type::Zero(dimension, 1);
199 for (
int i = 0; i < numberSamples; i++)
201 mean += samples.block(0, i, mean.rows(), 1);
204 mean = mean / numberSamples;
209 for (
int s = 0;
s < numberSamples;
s++)
211 meanadj.block(0,
s, meanadj.rows(), 1) -= mean;
215 cov = meanadj * meanadj.transpose() / numberSamples;
226 this->mean = prototype.
getMean();
235 if ((dimension != -1) && (mean.rows() != dimension))
240 if ((dimension != -1) && (cov.rows() != dimension))
247 dimension = cov.rows();
257 if ((dimension != -1) && (mean.rows() != dimension))
264 dimension = mean.rows();
274 if ((dimension != -1) && (cov.rows() != dimension))
279 if ((dimension != -1) && (cov.cols() != dimension))
284 if ((dimension == -1) && (cov.rows() != cov.cols()))
291 dimension = cov.rows();
292 this->mean = Eigen::VectorXd::Zero(dimension);
302 Gaussian::isSymmetric(
const covariance_type& matrix)
304 if (matrix.rows() != matrix.cols())
309 for (
int r = 0; r < matrix.rows(); r++)
311 for (
int c = 0;
c < matrix.cols();
c++)
313 if (matrix(r,
c) != matrix(
c, r))