2
$\begingroup$

I have independent variables $X_i\in[0;1]$ and suppose they are uniformly distributed. If you want to minimize the total absolute deviation to a fixed number, how much can you gain from using the sample mean over the population median?

Therefore I am looking for

$f(n)=E_{\{x\}}\left(\sum^n|x_i-0.5|-\sum^n\left|x_i-\frac{\sum^n x_i}{n}\right|\right)$

Hope this is the correct notation :) The function depends on the number of variables used and the expectation is over all possible values of these $n$ variables.

Apparently $f(1)=0.25$ but it seemed that $f(n>1)\approx 0.17$. It would be interesting to know the analytic expression for that. Any idea?

PS: Are there easier or more interesting results if you use the squared deviation, or other distributions, or the mean of population quantity?

$\endgroup$
2
  • 1
    $\begingroup$ Why sample mean rather than sample median (which actually minimizes the sum of absolute deviations from the sample values)? $\endgroup$
    – Glen_b
    Apr 2, 2014 at 21:26
  • $\begingroup$ Because in my particular case I had only the possibility to determine the total sum of the $x_i$. And without knowing the $x_i$ I was trying to minimize the scoring function which was the absolute deviation from a fixed number I provide. $\endgroup$
    – Gere
    Apr 3, 2014 at 9:34

1 Answer 1

1
$\begingroup$

The population mean and median of a uniform distribution on $[0,1]$ are both $\frac12$ as it is symmetric about $\frac12$.

Let's write $\bar X$ for $\frac1n \sum X_i$. We can say:

  • $\mathbb E\left[|X_i-\frac12|\right]=\frac14$ so $\mathbb E\left[\frac1n\sum|X_i-\frac12|\right]=\frac14$ and $\mathbb E\left[\sum|X_i-\frac12|\right]=\frac n4$.
  • For $n=1$, $X_1=\bar X$ so $\mathbb E\left[|X_1-\bar X|\right]=0$ and $\mathbb E\left[\sum|X_i-\frac12|\right] - \mathbb E\left[\sum|X_i-\bar X|\right] =\mathbb E\left[|X_1-\frac12|\right] - \mathbb E\left[|X_1-\bar X|\right] =\frac14$.
  • For $n>1$, $\mathbb E\left[|X_i-\bar X|\right]=\mathbb E\left[\frac1n\sum|X_i-\bar X|\right]= \frac14\left(1-\frac{2}{3n}\right)$ for $n>1$
  • so $\mathbb E\left[\sum|X_i-\bar X|\right]= \frac n4-\frac{1}{6}$
  • and thus $\mathbb E\left[\sum|X_i-\frac12|\right] - \mathbb E\left[\sum|X_i-\bar X|\right] =\frac16$ for $n>1$, much as you found.

In another question, ashpool stated in comments that the $\left(1-\frac{2}{3n}\right)$ term can be proved at least for $n=2,3,4$. As an illustration, see the following simulation in R (the average absolute deviation from the sample mean is in black and from the population mean in grey, with the simulations as points and $\frac14\left(1-\frac{2}{3n}\right)$ and $\frac14$ as lines):

avabsdevunif <- function(n, low=0, high=1){
  X <- runif(n, low, high)
  meanX <- mean(X)
  return(c(mean(abs(X-meanX)), mean(abs(X-(high-low)/2))))
  } 
set.seed(2023)
cases <- 10^5
avabsdev <- matrix(nrow=2, ncol=10)
for (n in 1:10){
   simunif <- replicate(cases, avabsdevunif(n))
   avabsdev[,n] <- c(mean(simunif[1,]), mean(simunif[2,]))
   }
plot(1:10, avabsdev[1,], ylim=c(0,0.26))
curve((1-2/(3*x))/4, from=1, to=10, add=TRUE)
points(1:10, avabsdev[2,], pch=15, col="lightgrey")
abline(h=1/4, col="lightgrey")

enter image description here

A normal distribution $N(\mu, \sigma^2)$ would show a different result,

  • with $\mathbb E\left[\frac1n\sum|X_i-\frac12|\right]=\sqrt{\frac{2}{\pi}} \sigma$
  • and $\mathbb E\left[\frac1n\sum|X_i-\bar X|\right]=\sqrt{\frac{n-1}{n}} \sqrt{\frac{2}{\pi}} \sigma$,
  • so $\mathbb E\left[\sum|X_i-\mu|\right] - \mathbb E\left[\sum|X_i-\bar X|\right] = (n-\sqrt{n(n-1)})\sqrt{\frac{2}{\pi}} \sigma$
  • which gradually reduces towards $\frac{\sigma}{\sqrt{2\pi}} $ as $n$ increases.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.