Let XX be a random variable taking value in some set 𝒮\mathcal{S}. Then, 𝔼[X]=∑s∈𝒮Pr[X=s]⋅s\mathbb{E}[X]=\sum_{s \in \mathcal{S}} \mathrm{Pr}[X=s]\cdot s
or for continuous r.v., 𝔼[X]=∫s∈𝒮Pr(s)⋅sds\mathbb{E}[X]=\int_{s \in \mathcal{S}} \mathrm{Pr}(s)\cdot s \,ds