TITLE: supremum of expectation $\le$ expectation of supremum?
QUESTION [20 upvotes]: Suppose that $X$ is an arbitrary random variable, is the following is true for any function $f$: 
$$\underset{y\in \mathcal Y} \sup \mathbb E\big[f(X,y)\big] \le \mathbb E\big[\underset{y\in \mathcal Y} \sup f(X,y)\big]?$$
If $f$ is convex in $X$, then the inequality clearly holds, since the supremum of a family of convex functions is still convex.  If $f$ is not convex in $X$, I think the inequality still holds for the following reason:  
For any realization of $X$ and any value of $y$, we have $f(X,y) \le \underset{y\in \mathcal Y} \sup f(X,y)$.  Therefore, for any $y$, $\mathbb E\big[f(X,y)\big] \le \mathbb E\big[\underset{y\in \mathcal Y} \sup f(X,y)\big]$.  In other words, $\mathbb E\big[\underset{y\in \mathcal Y} \sup f(X,y)\big]$ is an upper bound of the set $\left\{\mathbb E\big[f(X,y)\big]: y\in \mathcal Y\right\}$, so it follows that $\underset{y\in \mathcal Y} \sup \mathbb E\big[f(X,y)\big] \le \mathbb E\big[\underset{y\in \mathcal Y} \sup f(X,y)\big]$.
So it appears that convexity of $f$is not needed at all for the inequality to hold. Am I mistaken somewhere?  I'd appreciate it if someone would correct me, if I missed something.  Thanks a lot!

REPLY [3 votes]: How can you assure $\sup_{y\in \mathcal{Y}} f(X,y)$ is measurable? This is the case if the map $y\mapsto f(x,y)$ is continuous