ProbabilityMeasures.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package WorkingMemory
17 * @author Alexey Kozlov ( kozlov at kit dot edu)
18 * @date 2012
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #include "ProbabilityMeasures.h"
24 
26 #include <Eigen/LU>
27 
28 namespace memoryx
29 {
30  /*
31  * DiscreteProbability class
32  *
33  */
34  DiscreteProbability::DiscreteProbability(): DiscreteProbabilityBase::DiscreteProbabilityBase(0.) {}
35 
36  DiscreteProbability::DiscreteProbability(::Ice::Float prob): DiscreteProbabilityBase::DiscreteProbabilityBase(prob) {}
37 
39 
41  {
42  return prob;
43  }
44 
45  void DiscreteProbability::setProbability(Ice::Float prob, const Ice::Current&)
46  {
47  this->prob = prob;
48  }
49 
50  void DiscreteProbability::serialize(const armarx::ObjectSerializerBasePtr& serializer, const Ice::Current&) const
51  {
52  armarx::AbstractObjectSerializerPtr obj = armarx::AbstractObjectSerializerPtr::dynamicCast(serializer);
53 
54  obj->setFloat("prob", prob);
55  }
56 
57  void DiscreteProbability::deserialize(const armarx::ObjectSerializerBasePtr& serializer, const Ice::Current&)
58  {
59  armarx::AbstractObjectSerializerPtr obj = armarx::AbstractObjectSerializerPtr::dynamicCast(serializer);
60 
61  prob = obj->getFloat("prob");
62  }
63 
64 
65  /*
66  * NormalDistribution class
67  *
68  */
70  {
71  this->dimensions = dimensions;
72  this->mean.resize(dimensions);
73  }
74 
76  NormalDistributionBase(mean.size(), mean)
77  {
78  }
79 
81  {
82  this->dimensions = mean.rows();
83  this->mean.resize(dimensions);
85  }
86 
88  IceUtil::Shared(other),
89  NormalDistributionBase()
90  // NormalDistributionBase(other)
91  {
92  this->dimensions = other.dimensions;
93  this->mean = other.mean;
94  }
95 
96  Eigen::VectorXf NormalDistribution::toEigenMean() const
97  {
98  Eigen::VectorXf result = Eigen::Map<const Eigen::VectorXf>(this->mean.data(), this->dimensions);
99  return result;
100  }
101 
102  void NormalDistribution::fromEigenMean(const Eigen::VectorXf& mean)
103  {
104  if (this->dimensions == mean.rows())
105  {
106  Eigen::Map<Eigen::VectorXf>(this->mean.data(), this->dimensions) = mean;
107  }
108  else
109  {
111  }
112  }
113 
114  std::string NormalDistribution::output(const Ice::Current& c) const
115  {
116  std::stringstream s;
117  Eigen::MatrixXf cov = this->toEigenCovariance();
118  if (dimensions > 0)
119  {
120  s << "Standard deviation(mm): " << pow(cov.determinant(), 0.5 / dimensions);
121  }
122 
123  s << " mean: (";
124 
125  for (size_t i = 0; i < mean.size(); ++i)
126  {
127  s << mean[i] << ((i != mean.size() - 1) ? ", " : ") ");
128  }
129 
130  s << "cov: (";
131 
132  for (int i = 0; i < dimensions; ++i)
133  for (int j = 0; j < dimensions; ++j)
134  {
135  s << getCovariance(i, j) << ((i != dimensions - 1 || j != dimensions - 1) ? ", " : ")");
136  }
137 
138  return s.str();
139  }
140 
141  void NormalDistribution::serialize(const armarx::ObjectSerializerBasePtr& serializer, const Ice::Current&) const
142  {
143  armarx::AbstractObjectSerializerPtr obj = armarx::AbstractObjectSerializerPtr::dynamicCast(serializer);
144 
145  obj->setFloatArray("mean", mean);
146  }
147 
148  void NormalDistribution::deserialize(const armarx::ObjectSerializerBasePtr& serializer, const Ice::Current&)
149  {
150  armarx::AbstractObjectSerializerPtr obj = armarx::AbstractObjectSerializerPtr::dynamicCast(serializer);
151 
152  obj->getFloatArray("mean", mean);
153  dimensions = mean.size();
154  }
155 
156 
157  /*
158  * UnivariateNormalDistribution class
159  *
160  */
162  UnivariateNormalDistributionBase::UnivariateNormalDistributionBase(),
164  {
165  variance = 0.0f;
166  }
167 
169  UnivariateNormalDistributionBase::UnivariateNormalDistributionBase(),
171  {
172  variance = var;
173  this->mean.push_back(mean);
174  }
175 
177  IceUtil::Shared(other),
178  NormalDistributionBase(/*other*/),
179  UnivariateNormalDistributionBase(/*other*/),
180  NormalDistribution(other)
181  {
182  variance = other.variance;
183  }
184 
186  {
187  return variance;
188  }
189 
191  {
192  variance = var;
193  }
194 
195  float UnivariateNormalDistribution::getCovariance(int row, int col, const ::Ice::Current&) const
196  {
197  if ((row == 0) && (col == 0))
198  {
199  return variance;
200  }
201 
202  return 0;
203  }
204 
206  {
207  Eigen::MatrixXf result(1, 1);
208  result << this->variance;
209  return result;
210  }
211 
212  void UnivariateNormalDistribution::fromEigenCovariance(const Eigen::MatrixXf& cov)
213  {
214  if (cov.rows() == 1 && cov.cols() == 1)
215  {
216  this->variance = cov(1, 1);
217  }
218  else
219  {
221  }
222  }
223 
224  void UnivariateNormalDistribution::serialize(const armarx::ObjectSerializerBasePtr& serializer, const Ice::Current& c) const
225  {
226  armarx::AbstractObjectSerializerPtr obj = armarx::AbstractObjectSerializerPtr::dynamicCast(serializer);
227 
229  obj->setFloat("var", variance);
230  }
231 
232  void UnivariateNormalDistribution::deserialize(const armarx::ObjectSerializerBasePtr& serializer, const Ice::Current& c)
233  {
234  armarx::AbstractObjectSerializerPtr obj = armarx::AbstractObjectSerializerPtr::dynamicCast(serializer);
235 
237  variance = obj->getFloat("var");
238  }
239 
240  /*
241  * IsotropicNormalDistribution class
242  *
243  */
246  {
247  this->varVector.resize(dimensions);
248  }
249 
252  {
253  this->varVector = vars;
254  }
255 
256  IsotropicNormalDistribution::IsotropicNormalDistribution(const Eigen::VectorXf& mean, const Eigen::VectorXf& vars):
258  {
259  this->varVector.resize(dimensions);
260  fromEigenCovariance(vars);
261  }
262 
264  IceUtil::Shared(other),
265  NormalDistributionBase(other),
266  IsotropicNormalDistributionBase(other),
267  NormalDistribution(other)
268  {
269  this->varVector.assign(other.varVector.begin(), other.varVector.end());
270  }
271 
272 
274  {
275  return (size_t) dim < varVector.size() ? varVector[dim] : -1.;
276  }
277 
279  {
280  if ((size_t) dim < varVector.size())
281  {
282  varVector[dim] = var;
283  }
284  }
285 
286  float IsotropicNormalDistribution::getCovariance(int row, int col, const ::Ice::Current&) const
287  {
288  if (row != col)
289  {
290  return 0.;
291  }
292 
293  return varVector[row];
294  }
295 
297  {
298  Eigen::MatrixXf result(dimensions, dimensions);
299 
300  for (int i = 0; i < dimensions; ++i)
301  {
302  result(i, i) = varVector[i];
303  }
304 
305  return result;
306  }
307 
308  void IsotropicNormalDistribution::fromEigenCovariance(const Eigen::MatrixXf& cov)
309  {
310  if (cov.rows() == 1 && cov.cols() == dimensions)
311  {
312  for (int i = 0; i < dimensions; ++i)
313  {
314  varVector[i] = cov(0, i);
315  }
316  }
317  else if (cov.rows() == dimensions && cov.cols() == dimensions)
318  {
319  for (int i = 0; i < dimensions; ++i)
320  {
321  varVector[i] = cov(i, i);
322  }
323  }
324  else
325  {
327  }
328  }
329 
330 
331  void IsotropicNormalDistribution::serialize(const armarx::ObjectSerializerBasePtr& serializer, const Ice::Current& c) const
332  {
333  armarx::AbstractObjectSerializerPtr obj = armarx::AbstractObjectSerializerPtr::dynamicCast(serializer);
334 
336  obj->setFloatArray("var", varVector);
337  }
338 
339  void IsotropicNormalDistribution::deserialize(const armarx::ObjectSerializerBasePtr& serializer, const Ice::Current& c)
340  {
341  armarx::AbstractObjectSerializerPtr obj = armarx::AbstractObjectSerializerPtr::dynamicCast(serializer);
342 
344  obj->getFloatArray("var", varVector);
345  }
346 
347 
348  /*
349  * MultivariateNormalDistribution class
350  *
351  */
354  {
355  this->covMatrix.resize(dimensions * dimensions);
356  }
357 
360  {
361  this->covMatrix = vars;
362  }
363 
364  MultivariateNormalDistribution::MultivariateNormalDistribution(const Eigen::VectorXf& mean, const Eigen::MatrixXf& vars):
366  {
367  this->covMatrix.resize(dimensions * dimensions);
368  fromEigenCovariance(vars);
369  }
370 
372  IceUtil::Shared(other),
373  NormalDistributionBase(/*other*/),
374  MultivariateNormalDistributionBase(/*other*/),
375  NormalDistribution(other)
376  {
377  this->covMatrix = other.covMatrix;
378  }
379 
380 
381  Ice::Float MultivariateNormalDistribution::getCovariance(int row, int col, const Ice::Current&) const
382  {
383  const int index = row * dimensions + col;
384 
385  if (index >= 0 && (size_t) index < covMatrix.size())
386  {
387  return covMatrix[index];
388  }
389  throw armarx::IndexOutOfBoundsException();
390  }
391 
393  {
394  const int index = row * dimensions + col;
395 
396  if (index >= 0 && (size_t) index < covMatrix.size())
397  {
398  covMatrix[index] = cov;
399  }
400  else
401  {
402  throw armarx::IndexOutOfBoundsException();
403  }
404  }
405 
407  {
408  if (dimensions > 0)
409  {
410  Eigen::MatrixXf cov = toEigenCovariance();
411  return pow(cov.determinant(), 0.5 / dimensions);
412  }
413  else
414  {
415  return 0;
416  }
417  }
418 
420  {
421  Eigen::MatrixXf result = Eigen::Map<const Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> >(this->covMatrix.data(), this->dimensions, this->dimensions);
422  return result;
423  }
424 
426  {
427  if (cov.rows() == this->dimensions && cov.cols() == this->dimensions)
428  {
429  Eigen::Map<Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> >(this->covMatrix.data(), this->dimensions, this->dimensions) = cov;
430  }
431  else
432  {
434  }
435  }
436 
437  float MultivariateNormalDistribution::getDensity(const Eigen::VectorXf& point)
438  {
439  if (point.rows() != dimensions)
440  {
442  }
443 
444  Eigen::MatrixXf cov = toEigenCovariance();
445  Eigen::VectorXf m = toEigenMean();
446  Eigen::Matrix<float, 1, 1> inner = -0.5 * (point - m).transpose() * cov.inverse() * (point - m);
447  float e = expf(inner(0, 0));
448 
449  return pow(2 * M_PI, -dimensions / 2.0f) * pow(cov.determinant(), -0.5) * e;
450  }
451 
452  void MultivariateNormalDistribution::serialize(const armarx::ObjectSerializerBasePtr& serializer, const Ice::Current& c) const
453  {
454  armarx::AbstractObjectSerializerPtr obj = armarx::AbstractObjectSerializerPtr::dynamicCast(serializer);
455 
457  obj->setFloatArray("cov", covMatrix);
458  }
459 
460  void MultivariateNormalDistribution::deserialize(const armarx::ObjectSerializerBasePtr& serializer, const Ice::Current& c)
461  {
462  armarx::AbstractObjectSerializerPtr obj = armarx::AbstractObjectSerializerPtr::dynamicCast(serializer);
463 
465  obj->getFloatArray("cov", covMatrix);
466  }
467 
468  /**
469  * GaussianMixtureDistribution implementation
470  */
472  {
473  this->dimensions = 0;
474  }
475 
477  IceUtil::Shared(other),
478  GaussianMixtureDistributionBase(other)
479  {
480  clear();
481 
482  for (GaussianMixtureComponentList::const_iterator it = other.components.begin(); it != other.components.end(); ++it)
483  {
484  GaussianMixtureComponent comp;
485  comp.gaussian = NormalDistributionBasePtr::dynamicCast(it->gaussian->clone());
486  comp.weight = it->weight;
487  addComponent(comp);
488  }
489  }
490 
492  {
493  return dimensions;
494  }
495 
496  GaussianMixtureComponent GaussianMixtureDistribution::getComponent(::Ice::Int index, const ::Ice::Current&) const
497  {
498  if (index >= 0 && (size_t) index < components.size())
499  {
500  return components[index];
501  }
502  throw armarx::IndexOutOfBoundsException();
503  }
504 
505  GaussianMixtureComponent GaussianMixtureDistribution::getModalComponent(const ::Ice::Current&) const
506  {
507  if (components.empty())
508  {
509  return GaussianMixtureComponent();
510  }
511 
512  GaussianMixtureComponentList::const_iterator res = components.end();
513 
514  for (GaussianMixtureComponentList::const_iterator it = components.begin(); it != components.end(); ++it)
515  if (res == components.end() || it->weight > res->weight)
516  {
517  res = it;
518  }
519 
520  return *res;
521  }
522 
523  void GaussianMixtureDistribution::addComponent(const GaussianMixtureComponent& component, const ::Ice::Current&)
524  {
525  if (components.empty())
526  {
527  dimensions = component.gaussian->getDimensions();
528  }
529  else if (component.gaussian->getDimensions() != dimensions)
530  {
532  }
533 
534  components.push_back(component);
535  }
536 
537  void GaussianMixtureDistribution::addComponent(const NormalDistributionBasePtr& gaussian, float weight)
538  {
539  GaussianMixtureComponent comp;
540  comp.gaussian = gaussian;
541  comp.weight = weight;
542  addComponent(comp);
543  }
544 
545  void GaussianMixtureDistribution::addGaussian(const NormalDistributionBasePtr& gaussian, float weight, const ::Ice::Current& c)
546  {
547  addComponent(gaussian, weight);
548  }
549 
550  void GaussianMixtureDistribution::setComponent(::Ice::Int index, const GaussianMixtureComponent& component, const ::Ice::Current&)
551  {
552  if (index < 0 && (size_t) index >= components.size())
553  {
554  throw armarx::IndexOutOfBoundsException();
555  }
556  else if (component.gaussian->getDimensions() != dimensions)
557  {
559  }
560  else
561  {
562  components[index] = component;
563  }
564  }
565 
567  {
568  if (index >= 0 && (size_t) index < components.size())
569  {
570  components.erase(components.begin() + index);
571  }
572  else
573  {
574  throw armarx::IndexOutOfBoundsException();
575  }
576  }
577 
578  void GaussianMixtureDistribution::clear(const ::Ice::Current&)
579  {
580  components.clear();
581  }
582 
583  ::Ice::Int GaussianMixtureDistribution::size(const ::Ice::Current&) const
584  {
585  return (::Ice::Int) components.size();
586  }
587 
588  float GaussianMixtureDistribution::getTotalWeight() const
589  {
590  float result = 0.;
591 
592  for (GaussianMixtureComponentList::const_iterator it = components.begin(); it != components.end(); ++it)
593  {
594  result += it->weight;
595  }
596 
597  return result;
598  }
599 
600  void GaussianMixtureDistribution::addComponents(const GaussianMixtureDistributionBasePtr& other, const ::Ice::Current& c)
601  {
602  for (int i = 0; i < other->size(); ++i)
603  {
604  addComponent(other->getComponent(i));
605  }
606  }
607 
608  void GaussianMixtureDistribution::scaleComponents(::Ice::Float factor, const ::Ice::Current&)
609  {
610  for (GaussianMixtureComponentList::iterator it = components.begin(); it != components.end(); ++it)
611  {
612  it->weight *= factor;
613  }
614  }
615 
616  void GaussianMixtureDistribution::pruneComponents(::Ice::Float threshold, const ::Ice::Current&)
617  {
618  const float totalWeight = getTotalWeight();
619  GaussianMixtureComponentList::iterator it = components.begin();
620 
621  while (it != components.end())
622  {
623  if (it->weight / totalWeight < threshold)
624  {
625  it = components.erase(it);
626  }
627  else
628  {
629  ++it;
630  }
631  }
632  }
633 
634  void GaussianMixtureDistribution::normalize(const ::Ice::Current&)
635  {
636  const float totalWeight = getTotalWeight();
637 
638  for (GaussianMixtureComponentList::iterator it = components.begin(); it != components.end(); ++it)
639  {
640  it->weight /= totalWeight;
641  }
642  }
643 
644  float GaussianMixtureDistribution::getDensity(const Eigen::VectorXf& point)
645  {
646  const float totalWeight = getTotalWeight();
647  float result = 0.f;
648 
649  for (GaussianMixtureComponentList::iterator it = components.begin(); it != components.end(); ++it)
650  {
651  const NormalDistributionPtr gaussian = NormalDistributionPtr::dynamicCast(it->gaussian);
652  result += gaussian->getDensity(point) * it->weight / totalWeight;
653  }
654 
655  return result;
656  }
657 
659  {
660  // check if argument is already GM - in that case, we just need to cast
661  GaussianMixtureDistributionPtr gm = GaussianMixtureDistributionPtr::dynamicCast(probMeasure);
662 
663  if (gm)
664  {
665  return gm;
666  }
667 
668  // check if argument is a guassian
669  NormalDistributionBasePtr gaussian = NormalDistributionBasePtr::dynamicCast(probMeasure);
670 
671  if (gaussian)
672  {
673  // if so, create GM with a single component
675  result->addComponent(gaussian, 1.);
676  return result;
677  }
678 
679  // unable to convert -> return empty pointer
681  }
682 
683  std::string GaussianMixtureDistribution::output(const Ice::Current& c) const
684  {
685  std::stringstream s;
686 
687  for (GaussianMixtureComponentList::const_iterator it = components.begin(); it != components.end(); ++it)
688  {
689  s << "{ gaussian: " << it->gaussian->output() << "weight: " << it->weight << "} \n";
690  }
691 
692  return s.str();
693  }
694 
695 
696  void GaussianMixtureDistribution::serialize(const armarx::ObjectSerializerBasePtr& serializer, const Ice::Current& c) const
697  {
698  armarx::AbstractObjectSerializerPtr obj = armarx::AbstractObjectSerializerPtr::dynamicCast(serializer);
699 
700  obj->setElementType(armarx::ElementTypes::eArray);
701 
702  for (GaussianMixtureComponentList::const_iterator it = components.begin(); it != components.end(); ++it)
703  {
704  armarx::AbstractObjectSerializerPtr compValue = armarx::AbstractObjectSerializerPtr::dynamicCast(serializer)->createElement();
705  armarx::VariantPtr gaussianVar = new armarx::Variant(armarx::VariantDataClassPtr::dynamicCast(it->gaussian));
706  compValue->setVariant("gaussian", gaussianVar);
707  compValue->setFloat("weight", it->weight);
708  obj->append(compValue);
709  }
710  }
711 
712  void GaussianMixtureDistribution::deserialize(const armarx::ObjectSerializerBasePtr& serializer, const Ice::Current& c)
713  {
714  armarx::AbstractObjectSerializerPtr obj = armarx::AbstractObjectSerializerPtr::dynamicCast(serializer);
715 
716  clear();
717 
718  for (unsigned int i = 0; i < obj->size(); ++i)
719  {
720  const armarx::AbstractObjectSerializerPtr compValue = obj->getElement(i);
721 
722  GaussianMixtureComponent comp;
723  armarx::VariantPtr gaussianVar = compValue->getVariant("gaussian");
724  comp.gaussian = gaussianVar->getClass<NormalDistributionBase>();
725  comp.weight = compValue->getFloat("weight");
726  addComponent(comp);
727  }
728  }
729 }
730 
memoryx::IsotropicNormalDistribution::getVariance
::Ice::Float getVariance(::Ice::Int dim, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:273
memoryx::DiscreteProbability::setProbability
void setProbability(::Ice::Float, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ProbabilityMeasures.cpp:45
memoryx::UnivariateNormalDistribution::getCovariance
float getCovariance(int row, int col, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:195
armarx::Variant
The Variant class is described here: Variants.
Definition: Variant.h:224
memoryx::IsotropicNormalDistribution
The IsotropicNormalDistribution class.
Definition: ProbabilityMeasures.h:183
memoryx::NormalDistribution::fromEigenMean
void fromEigenMean(const Eigen::VectorXf &mean)
Definition: ProbabilityMeasures.cpp:102
memoryx::GaussianMixtureDistribution::removeComponent
void removeComponent(::Ice::Int index, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ProbabilityMeasures.cpp:566
memoryx::GaussianMixtureDistribution::getModalComponent
GaussianMixtureComponent getModalComponent(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:505
memoryx::GaussianMixtureDistribution::output
std::string output(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:683
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
memoryx::GaussianMixtureDistribution::addGaussian
void addGaussian(const NormalDistributionBasePtr &gaussian, float weight, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ProbabilityMeasures.cpp:545
memoryx::GaussianMixtureDistribution::size
::Ice::Int size(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:583
memoryx::IsotropicNormalDistribution::fromEigenCovariance
void fromEigenCovariance(const Eigen::MatrixXf &cov) override
Definition: ProbabilityMeasures.cpp:308
index
uint8_t index
Definition: EtherCATFrame.h:59
memoryx::DiscreteProbability::~DiscreteProbability
~DiscreteProbability() override
Definition: ProbabilityMeasures.cpp:38
memoryx::NormalDistribution::getCovariance
float getCovariance(int row, int col, const ::Ice::Current &=Ice::emptyCurrent) const override=0
memoryx::MultivariateNormalDistribution::getCovariance
float getCovariance(int row, int col, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:381
memoryx::UnivariateNormalDistribution::getVariance
::Ice::Float getVariance(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:185
memoryx::IsotropicNormalDistribution::setVariance
void setVariance(::Ice::Int dim, ::Ice::Float, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ProbabilityMeasures.cpp:278
armarx::ElementTypes::eArray
@ eArray
Definition: AbstractObjectSerializer.h:36
memoryx::IsotropicNormalDistribution::getCovariance
float getCovariance(int row, int col, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:286
memoryx::GaussianMixtureDistribution::deserialize
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ProbabilityMeasures.cpp:712
AbstractObjectSerializer.h
memoryx::DiscreteProbability::getProbability
::Ice::Float getProbability(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:40
memoryx::IsotropicNormalDistribution::IsotropicNormalDistribution
IsotropicNormalDistribution(int dimensions=0)
Definition: ProbabilityMeasures.cpp:244
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
memoryx::GaussianMixtureDistribution::getDimensions
::Ice::Int getDimensions(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:491
memoryx::GaussianMixtureDistribution::normalize
void normalize(const ::Ice::Current &=Ice::emptyCurrent) override
Normalize components weights (i.e.
Definition: ProbabilityMeasures.cpp:634
memoryx::GaussianMixtureDistribution::serialize
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:696
IceUtil
Definition: Instance.h:21
memoryx::UnivariateNormalDistribution::serialize
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:224
memoryx::MultivariateNormalDistribution::serialize
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:452
IceInternal::Handle
Definition: forward_declarations.h:8
memoryx::MultivariateNormalDistribution::getVarianceScalar
float getVarianceScalar(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:406
InvalidDimensionException
Definition: Gaussian.h:19
memoryx::GaussianMixtureDistribution::pruneComponents
void pruneComponents(::Ice::Float threshold, const ::Ice::Current &=Ice::emptyCurrent) override
Remove all components with weights lower than threshold value.
Definition: ProbabilityMeasures.cpp:616
memoryx::GaussianMixtureDistribution::addComponent
void addComponent(const GaussianMixtureComponent &component, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ProbabilityMeasures.cpp:523
memoryx::NormalDistribution::toEigenCovariance
virtual Eigen::MatrixXf toEigenCovariance() const =0
armarx::mean
std::optional< float > mean(const boost::circular_buffer< NameValueMap > &buffer, const std::string &key)
Definition: KinematicUnitGuiPlugin.cpp:1615
M_PI
#define M_PI
Definition: MathTools.h:17
memoryx::MultivariateNormalDistribution::setCovariance
void setCovariance(::Ice::Int row, ::Ice::Int col, ::Ice::Float cov, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ProbabilityMeasures.cpp:392
memoryx::UnivariateNormalDistribution::toEigenCovariance
Eigen::MatrixXf toEigenCovariance() const override
Definition: ProbabilityMeasures.cpp:205
armarx::FloatVector
::std::vector< ::Ice::Float > FloatVector
Definition: KinematicUnitGuiPlugin.h:327
memoryx::MultivariateNormalDistribution
The MultivariateNormalDistribution class.
Definition: ProbabilityMeasures.h:236
memoryx::GaussianMixtureDistribution
The GaussianMixtureDistribution class.
Definition: ProbabilityMeasures.h:298
memoryx::NormalDistribution::toEigenMean
Eigen::VectorXf toEigenMean() const
Definition: ProbabilityMeasures.cpp:96
memoryx::IsotropicNormalDistribution::deserialize
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ProbabilityMeasures.cpp:339
memoryx::UnivariateNormalDistribution::setVariance
void setVariance(::Ice::Float, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ProbabilityMeasures.cpp:190
memoryx::GaussianMixtureDistribution::getDensity
virtual float getDensity(const Eigen::VectorXf &point)
Definition: ProbabilityMeasures.cpp:644
memoryx::GaussianMixtureDistribution::setComponent
void setComponent(::Ice::Int index, const GaussianMixtureComponent &component, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ProbabilityMeasures.cpp:550
memoryx::DiscreteProbability::DiscreteProbability
DiscreteProbability()
Definition: ProbabilityMeasures.cpp:34
memoryx::NormalDistribution::NormalDistribution
NormalDistribution(int dimensions)
Definition: ProbabilityMeasures.cpp:69
memoryx::UnivariateNormalDistribution::UnivariateNormalDistribution
UnivariateNormalDistribution()
Definition: ProbabilityMeasures.cpp:161
memoryx::GaussianMixtureDistributionPtr
IceInternal::Handle< GaussianMixtureDistribution > GaussianMixtureDistributionPtr
Definition: ProbabilityMeasures.h:293
memoryx::UnivariateNormalDistribution
The UnivariateNormalDistribution class.
Definition: ProbabilityMeasures.h:131
memoryx::MultivariateNormalDistribution::MultivariateNormalDistribution
MultivariateNormalDistribution(int dimensions=0)
Definition: ProbabilityMeasures.cpp:352
memoryx::GaussianMixtureDistribution::addComponents
void addComponents(const GaussianMixtureDistributionBasePtr &other, const ::Ice::Current &=Ice::emptyCurrent) override
Multiply weight of each GM component with a given constant.
Definition: ProbabilityMeasures.cpp:600
memoryx::GaussianMixtureDistribution::FromProbabilityMeasure
static GaussianMixtureDistributionPtr FromProbabilityMeasure(const ProbabilityMeasureBasePtr &probMeasure)
Convert or approximate given ProbabilityMeasure to a gaussian mixture.
Definition: ProbabilityMeasures.cpp:658
memoryx::NormalDistribution::output
std::string output(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:114
ProbabilityMeasures.h
memoryx::GaussianMixtureDistribution::GaussianMixtureDistribution
GaussianMixtureDistribution()
GaussianMixtureDistribution implementation.
Definition: ProbabilityMeasures.cpp:471
memoryx::IsotropicNormalDistribution::toEigenCovariance
Eigen::MatrixXf toEigenCovariance() const override
Definition: ProbabilityMeasures.cpp:296
memoryx::UnivariateNormalDistribution::fromEigenCovariance
void fromEigenCovariance(const Eigen::MatrixXf &cov) override
Definition: ProbabilityMeasures.cpp:212
memoryx::MultivariateNormalDistribution::toEigenCovariance
Eigen::MatrixXf toEigenCovariance() const override
Definition: ProbabilityMeasures.cpp:419
memoryx::GaussianMixtureDistribution::clear
void clear(const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ProbabilityMeasures.cpp:578
memoryx::UnivariateNormalDistribution::deserialize
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ProbabilityMeasures.cpp:232
memoryx::MultivariateNormalDistribution::deserialize
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ProbabilityMeasures.cpp:460
memoryx::NormalDistribution::serialize
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:141
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:916
memoryx::NormalDistribution::deserialize
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ProbabilityMeasures.cpp:148
Eigen::Matrix
Definition: EigenForwardDeclarations.h:27
memoryx::NormalDistribution
Definition: ProbabilityMeasures.h:87
memoryx::GaussianMixtureDistribution::scaleComponents
void scaleComponents(::Ice::Float factor, const ::Ice::Current &=Ice::emptyCurrent) override
Multiply weight of each GM component with a given constant.
Definition: ProbabilityMeasures.cpp:608
memoryx::DiscreteProbability::deserialize
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ProbabilityMeasures.cpp:57
armarx::transpose
std::vector< std::vector< T > > transpose(const std::vector< std::vector< T >> &src, Thrower thrower)
Definition: SimoxCSpace.cpp:706
memoryx::DiscreteProbability::serialize
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:50
memoryx::MultivariateNormalDistribution::fromEigenCovariance
void fromEigenCovariance(const Eigen::MatrixXf &cov) override
Definition: ProbabilityMeasures.cpp:425
memoryx::IsotropicNormalDistribution::serialize
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:331
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
memoryx::GaussianMixtureDistribution::getComponent
GaussianMixtureComponent getComponent(::Ice::Int index, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ProbabilityMeasures.cpp:496
memoryx::MultivariateNormalDistribution::getDensity
float getDensity(const Eigen::VectorXf &point) override
Definition: ProbabilityMeasures.cpp:437