I'd like to know if it's correct to numerically evaluate the expected value in this way, and, if yes, why it's right. I have a discrete random variable $X$ with a binomial distribution, the discrete density is a vector $densità$ and the values of $X$ are in the vector $x$. The numerical mean:
$$ mean = \sum _{i} x_i \, densità_i $$
I found this formula in the handout of my professor and it's quite strange the presence of the density, I was expected the probability (definition of the expected value for a discrete random variable):
$$ mean = \sum _{x \in \mathbb{R}} x \, P(X = x) $$