Hi Maximilian,
The problem with the median seems to be that you are not using Boost.Accumulator in the intended watt. What you do is that you create a histogram of the distribution, and then you want to use the library to calculate statistical properties from this histogram instead of the original sample values. This however introduces correlations into your samples: they are monotonically increasing.
For values like the mean, variance, skewness, ... this will still work. However, since there is no exact method of calculating the median without storing all values the median is approximated in Boost.Accumulator. That approximation will however be bad if you first sort the data as you essentially do.
The short answer is that Boost.Accumulator is not the right library for getting the median from a histogram, and it is also not the most efficient library for the other quantities in your case.
Matthias
Sent from my iPad
On Sep 1, 2010, at 17:19, Maximilian Matthe
Hi!
I want to calculate the median color (along some other data) of the pixels of an image from its histogram:
std::vector<int> m_Hist; // m_Hist[i] contains number of pixels with color i.
using namespace boost::accumulators; accumulator_set
, double> acc;
for(int i = 0; i < 256; i++) acc(i, weight = m_Hist[i]);
float mm = weighted_mean(acc); float stdD = sqrtf(weighted_variance(acc)); float med = weighted_median(acc); float sk = weighted_skewness(acc);
mean und stdD work correctly, but the median is too large. It gives me about 200, but the real value should be around 75 (I checked that manually). The skewness is around 11000 (which also seems quite large to me).
So, what am I doing wrong with accumulators?
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users