# How to average quantized and truncated data?

So I have data that has been quantized by an analogue to digital converter. (continuous data has been turned into discrete data and the values range from 0 to the saturation value , which is 127 in this case).

This particular instrument I used to gather the data is quite noisy, let's say there is added Gaussian noise to the real value. Luckily, when taking single measurements, I have enough time to take multiple measurements and average them to reduce the noise. Note that sampling rate is not an issue here since the thing that I'm taking measurements of is completely stable.

Obviously , taking the simple mean will produce a biased result because values cannot exceed 0 or 127 (for example, if you attempt to use a plain old averaging on something with a "real" value of 126, you will get an estimated value that is less than 126. This is because the added Gaussian noise will not give you any value higher than 127 because of the truncation). So how do I take the average so the result will give me an unbiased estimator of the real value?

• en.wikipedia.org/wiki/Winsorized_mean – whuber Mar 16 '11 at 22:59
• I guess that could help but I would really need to change how to take the winsorized mean when i'm close to saturation and zero so it really doesn't solve my problems.. I was looking for an approach with more mathematical foundations. I mean, this problem seems like such a common thing that someone must have done work on it already. – umps Mar 17 '11 at 14:50
• I don't understand the problem. The computation is simple. You only need to compute what proportion of your data are 0 and what proportion are 127 ("saturation"). Let $q$ be the larger of those two proportions. If $q\ge.50$ you're out of luck no matter what. Otherwise, let $\bar{m}$ be the mean of the middle $1-2q$ of the data (lying between the $q$ and $1-q$ quantiles), $x_{-}$ be the $q$ quantile, and $x_{+}$ be the $1-q$ quantile. The Winsorized mean equals $(1-2q)\bar{m}+q(x_{-}+x_{+})$. I don't understand the reference to "more mathematical foundations," either. – whuber Mar 17 '11 at 14:59

http://en.wikipedia.org/wiki/Truncation_%28statistics%29

This is not much help, but at least it gives the correct buzzword (truncated, not quantized; quantization is not your problem) and one pointer to a paper. This should do as a starting point for further search.

Oh, and Winsorized mean is the exact opposite from what you want.

• He's using an ADC, so he's got both truncation (i.e., saturation) and quantization effects. It's straightforward to show that if the noise is zero-mean Gaussian, then the expected value of each sample is something like $\sum_{i=1}^m q^\star_i \cdot (\Phi((q_{i} - \mu)/\sigma) - \Phi((q_{i-1}-\mu)/\sigma)$ where $q^\star_i$ is the quantization value of the $i$th bin, $q_i$ is the $i$th bin boundary and $\Phi(\cdot)$ is the standard normal cdf. If he wants something unbiased he has to find a way to get that $\mu$ outside of the $\Phi(\cdot)$ functions! – cardinal Mar 18 '11 at 3:52
• Yes, I have both truncation and quantization. That is correct, I will look into the truncation further to see if I can find anything. – umps Mar 18 '11 at 18:07
• "Exact opposite" in what sense? – whuber Mar 18 '11 at 19:51

If your data follow a truncated normal distribution, this link gives you a implementation in R language for the computation of the mean and variance of a truncated normal distribution :

http://www.r-bloggers.com/truncated-normal-distribution/