Showing that randomness is undesired for prediction accuracy

67 Views Asked by At

Let's say I have a random variable $x \sim Bernouilli(\pi)$ for $\pi < 0.5$. Suppose my prediction also followes a Bernouilli distribution $ \hat{x} \sim Bernouilli(p)$.

Compute the expected accuracy $\mathbb{E}[ I {( x=\hat{x} )}]$ where I is the indicator function. What is the value of $p$ that yields the highest expected accuracy?

For solving the expected accuracy, I did the following:

$$ \mathbb{E}[ I {( x=\hat{x} )}] = \sum_{x} P(x)x = 0 \cdot P(x=0) + 1 \cdot P(x=1) $$

$$ = \pi $$

However, I'm not sure how to find the value of $p$ that yields the highest expected accuracy.

2

There are 2 best solutions below

1
On BEST ANSWER

The way you've computed $\mathbb{E}[I(x=\hat{x})]$ is wrong, besides it doesn't really take in account the choice of $p$.

I will try to as rigorous as I can in my computation below.


Let $X,\hat{X}$ be the unkown RV and the prediction respectively. Let $I$ be a random variable such that it has the value of the indicator function $I = I(X =\hat{X})$. Then \begin{align} \mathbb{E}[I(x =\hat{x})] =\mathbb{E}[I] &=\sum_{i\in\{0,1\}} \mathbb{E}[I\ |\ \hat{X}=i]\cdot \mathbb{P}(\hat{X} = i)\\ &=\sum_{i\in\{0,1\}} \mathbb{P}(\hat{X} = i)\cdot \mathbb{E}[I\ |\ \hat{X}=i] \\ &=\sum_{i\in\{0,1\}} \mathbb{P}(\hat{X} = i)\sum_{j\in\{0,1\}} j\cdot \mathbb{P}(I=j\ |\ \hat{X}=i) \\ &=\sum_{i\in\{0,1\}} \mathbb{P}(\hat{X} = i)\cdot \mathbb{P}(I=1\ |\ \hat{X}=i) \\ &=\sum_{i\in\{0,1\}}\mathbb{P}(\hat{X} = i)\cdot\mathbb{P}\left(I(X=\hat{X})=1\ |\ \hat{X}=i\right) \\ &=\sum_{i\in\{0,1\}}\mathbb{P}(\hat{X} = i)\cdot\mathbb{P}\left(X=\hat{X}\ |\ \hat{X}=i\right) \\ &=\sum_{i\in\{0,1\}}\mathbb{P}(\hat{X} = i)\cdot\mathbb{P}(X=i) \\ &=\mathbb{P}(\hat{X} = 0)\cdot\mathbb{P}(X=0) + \mathbb{P}(\hat{X} = 1)\cdot\mathbb{P}(X=1) \\ &=(1-p)(1-\pi) + p\cdot\pi \end{align}

Now what is the best $p$ ? Well our computation shows that $\mathbb{E}[I] = (2\pi - 1)p + (1 - \pi)$. This shows something... not so interesting. If $2\pi-1\geq 0 \iff \pi \geq \frac{1}{2}$ ($X$ more likely to be $1$) then our best guess is that $X$ will be $1$ more times than not, so the best $p$ is $1$ (the max it can be). If $\pi <\frac{1}{2}$ then the best $p$ is $0$.

0
On

Since $I(x=\hat x)\sim Bern(P(x=\hat x)),$ $$E[I(x=\hat x)]=P(x=\hat x)=P(x=1,\hat x=1)+P(x=0,\hat x=0).$$

If $x,\hat x$ are independent, then this simplifies to

$$P(x=1)P(\hat x=1)+P(x=0)P(\hat x=0)=\pi p+(1-\pi)(1-p).$$