I understand the definition of convexity in a function $f: \mathbb R^d \to \mathbb R$ as the inequality for all $a,b\in\mathbb R^d$ and $0<\theta<1:$
$$\theta f(a) + (1-\theta)f(b) \geq f(\theta a + (1-\theta)b).$$
However, I am confused - likely because I never had formal training - about the index notation in the definition of convexity for random variables:
$$\sum w_i \mathbb E\Big[f(X_i) \Big]\ge \mathbb E\Big[ \sum f(w_i X_i) \Big]$$
Both $X_i$ and $f(X_i)$ are random variables, and random variables can be indexed.
So what is $w_i$? I am used to $w$ being weights - like a vector of probabilities, with $i$ in $w_i$ being each specific entry, but that doesn't make sense. I guess the $i$ just refers to the index $i$ of the random variable, which I don't know what differentiating function it has in a general definition.. It is an issue of confusion between random variable and specific values of that random variable.
Here is an example of how I would interpret the equation:
set.seed(0)
nsim = 10
N = 10 # no. of values to be drawn from the interval [0, 10]
m = matrix(,2,nsim) # Initializing empty matrix
for (i in 1:nsim){
w = prop.table(runif(N)) # Vector of probabilities (w_i)
x = sample(seq(0,10,0.00001), N) # Drawing these random values X_1,..., X_N.
y = x^2 # f(X_i) or payoff function.
wx = w * x # Dot product <w_i, X_i>
m[1,i] <- (mean(wx))^2 # Mean squared.
wy = w * y # Dot product <w_i, f(X_i)>
m[2,i] <- (mean(wy))^2 # Mean of f(X_i) squared.
}
plot(m[2,], col=5, pch=19, ylim = c(0,10), ylab="Payoff", xlab="Simulation")
points(m[1,], col=2, pch=19)
Would this be interpreting the notation correctly?