This test creates a GaussianPdf with a random mean and covariance. It then generates uniform samples within 3 standard deviations of the mean and weights them according to the density function of this GaussianPdf, adding them to a DiracMixturePdf distribution. The mean and covariance of the DiracMixturePdf can then be compared with those of the original Gaussian. Furthermore, the DiracMixturePdf is resampled with indii::ml::filter::StratifiedParticleResampler and the new mean and covariance calculated, which should be the same as before the resampling, or very close to.
Results are as follows:
True mean [4](-4.5444,5.20865,4.0792,-4.82722) True covariance [4,4]((17.766,20.8542,4.83023,13.7405),(20.8542,38.9079,7.85229,22.763),(4.83023,7.85229,3.84153,10.1079),(13.7405,22.763,10.1079,32.2301)) Sampled mean [4](-4.82126,4.62878,3.76454,-5.57665) Sampled covariance [4,4]((14.3484,15.9283,3.02584,8.94303),(15.9283,31.4807,5.06911,15.3619),(3.02584,5.06911,2.56023,6.60124),(8.94303,15.3619,6.60124,22.4278)) Resampled mean [4](-4.82061,4.63081,3.76633,-5.56877) Resampled covariance [4,4]((14.3519,15.9375,3.02905,8.95475),(15.9375,31.4927,5.06273,15.3567),(3.02905,5.06273,2.55954,6.59333),(8.95475,15.3567,6.59333,22.4061))
Note that the covariances for the DiracMixturePdf are expected to be slightly lower than that for the GaussianPdf in general, due to the finite interval over which the samples are taken.
Definition in file test3.cpp.
Go to the source code of this file.
Functions | |
| int | main (int argc, char *argv[]) |
| Run tests. | |
Variables | |
| unsigned int | M = 4 |
| Dimensionality of the Gaussian. | |
| unsigned int | N = 10000 |
| Number of samples to take. | |
1.5.3