What is E(|0.5-X|) when X ~ B(2, 2)?

54 Views Asked by At

What is the expected value of |0.5-X| when X is following the beta distribution of the first kind(alpha=2, beta=2)?

The reason why I want to do is to compare the performance between normal quick sort and median-of-three quick sort.
Normal quick sort: pick up the first element as pivot
Median-of-three quick sort: pick up the first, middle and end element and pick up the median of those, then take it as pivot.

memo

Probability Density Function of B(2,2)

$$f(x)=cx^{a-1}(1-x)^{b-1} = 6x(1-x)$$ $$E(X)=\int_{-\infty}^{\infty} xf(x) \,dx$$ $$E(|0.5-X|)=\int_{x=0}^{\frac12} (0.5-x)6x(1-x) \,dx + \int_{x=\frac12}^{1} (x-0.5)6x(1-x) \,dx=0.1875$$

2

There are 2 best solutions below

1
On BEST ANSWER

enter image description here

Just integrate the (symmetric) beta distribution between $0$ and $1/2$ (or from $1/2$ to $1$) to find $0.1875$.

$$\frac{\int\limits_{x=0}^{1/2} (x-.5) x (1-x)\ dx}{\int\limits_{x=0}^{1/2} x (1-x)\ dx} = .1875$$

0
On

You can easily calculate this using the Law of the unconscious statistician which states that for a function $g(X)$ of a random variable $X$: $$E[g(X)] = \int\limits_{x=-\infty}^{\infty} g(X)f_X(x) dx$$

In your case $g(X) = \left|0.5-X\right|$