I am currently trying to split the last part of the below equation into three parts, but am struggling to do so.
\begin{align*}
\notag \mathbb{E}_{(x,y) \sim P(X,Y)}\left[(y-f(x))^2 + (f(x)-\hat{f}(x))^2\right] &= \mathbb{E}_{(x,y) \sim P(X,Y)}\left[(y-f(x))^2 + (f(x)-\hat{f}(x))^2\right]\\
\notag &= \sigma^{2}(x) + \mathbb{E}_{x \sim P(X)}\left[\left(f(x)-\hat{f}(x)\right)^2\right]\\
\notag &=\sigma^{2}(x)+ \mathbb{E}_{x \sim P(X)}\left[\left(f(x)-\mathbb{E}_{x}\left[\hat{f}(x)\right]\right)^{2}+2\left(\left(f(x)-\mathbb{E}_{x}\left[\hat{f}(x)\right]\right)\left(\mathbb{E}_{x}\left[\hat{f}(x)\right]-\hat{f}(x)\right)\right)+\left(\mathbb{E}_{x}\left[\hat{f}(x)\right] - \hat{f}(x)\right)^2\vphantom{\mathbb{E}_{x \sim P(X)}}\right].
\end{align*}
I've tried
\begin{align*}
\notag \mathbb{E}_{(x,y) \sim P(X,Y)}\left[(y-f(x))^2 + (f(x)-\hat{f}(x))^2\right] &= \mathbb{E}_{(x,y) \sim P(X,Y)}\left[(y-f(x))^2 + (f(x)-\hat{f}(x))^2\right]\\
\notag &= \sigma^{2}(x) + \mathbb{E}_{x \sim P(X)}\left[\left(f(x)-\hat{f}(x)\right)^2\right]\\
\begin{split}
\notag &=\sigma^{2}(x)+ \mathbb{E}_{x \sim P(X)}\left[\left(f(x)-\mathbb{E}_{x}\left[\hat{f}(x)\right]\right)^{2}\right.\\
\left.+2\left(\left(f(x)-\mathbb{E}_{x}\left[\hat{f}(x)\right]\right)\left(\mathbb{E}_{x}\left[\hat{f}(x)\right]-\hat{f}(x)\right)\right)\right.\\
\left.+\left(\mathbb{E}_{x}\left[\hat{f}(x)\right] - \hat{f}(x)\right)^2\vphantom{\mathbb{E}_{x \sim P(X)}}\right].
\end{split}
\end{align*}
which seems to work but doesn't align the bottom part of the equation correctly. The problem also seems to be that I have \left
and \right
within my equation that I would like to split. Basically, I'd like to split the third line of the equation and align them within the \mathbb{E}
sign.
Thanks in advance.
\left...\right
here in the first place. I see no reason for any of them in this example.\left...\right
is there for the expected value notation since I have several equations wrapped within it.\left...\right
in the cases that really need it.