How rounding real numbers affect mean

99 Views Asked by At

First of all, I am not used to construct mathematical demonstration, so I will discuss my point in a argument based fashion. This is why I am asking to mathematician a more formal and correct way to prove my point.

I often have to compute mean of rounded numbers, and I would make sure that rounding number does not affect too much the mean.

Having three functions, $\mathrm{floor}$, $\mathrm{round}$ and $\mathrm{ceil}$ which respectively take the previous, the closest, the next integer to $x_i$, the following relations hold: $$ \mathrm{floor}(x_i) \leq \mathrm{round}(x_i) \leq \mathrm{ceil}(x_i) $$

And also:

$$ \mathrm{floor}(x_i) \leq x_i \leq \mathrm{ceil}(x_i) $$

I have the intuition that rounding number cannot change the mean more than a unit. Thus I would like to prove than:

$$ |\bar{x} - \bar{x}^*| \leq 1 $$

Where:

$$ \bar{x} = \frac{1}{n}\sum_i^n{x_i} \,,\quad \bar{x}^* = \frac{1}{n}\sum_i^n{\mathrm{round}(x_i)} $$

My reasoning is the following:

I may state that:

$$ \frac{1}{n}\sum_i^n{\mathrm{floor}(x_i)} \leq \bar{x}^* \leq \frac{1}{n}\sum_i^n{\mathrm{ceil}(x_i)} $$

And:

$$ \frac{1}{n}\sum_i^n{\mathrm{floor}(x_i)} \leq \bar{x} \leq \frac{1}{n}\sum_i^n{\mathrm{ceil}(x_i)} $$

Because of the definition of those functions and linearity of inequalities operations (there are only addition and multiplication by positive numbers).

We also may observe than:

$$ \mathrm{ceil}(x_i) \leq x_i + 1 $$

And:

$$ \mathrm{floor}(x_i) \geq x_i - 1 $$

By expanding summation, it leads to:

$$ \bar{x} - 1 \leq \bar{x}^* \leq \bar{x} + 1 $$

Which is what I want to prove. I am right doing this reasoning. How could I make it more formal?