PointCloudLibrary / pcl

Point Cloud Library (PCL)
https://pointclouds.org/
Other
9.89k stars 4.61k forks source link

Sample Variance problem in Statistical Outlier Removal #5893

Closed NeilGatenby closed 10 months ago

NeilGatenby commented 10 months ago

https://github.com/PointCloudLibrary/pcl/blob/0e4683a4f602447b1b7278abe98d9696e8027ce1/filters/src/statistical_outlier_removal.cpp#L247

Maybe I'm not seeing this right, but surely this should be ... variance = (sq_sum - mean * mean) / (static_cast<double>(valid_distances) - 1);

(odd casts aside)

It's missing a 1 / valid_distances, isn't it?

Best wishes N

NeilGatenby commented 10 months ago

I take it back ; I'm an idiot

mvieth commented 10 months ago

No worries, happens to everyone :smile: I think this is taken from https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Na%C3%AFve_algorithm