
Calculate the expected value of distributions
Source:R/central-tendency.R, R/ddf-class.R
expected_value.RdThis function calculates the mean/expected value of a discrete distribution
with finite support given as a ddf object.
Usage
expected_value(dist)
# S4 method for class 'ddf'
mean(x)Details
The expected value of a discrete random variable \(X\) with finite support \(\{x_1, \dots, x_n\}\) and corresponding probabilities \(p_1, \dots, p_n\) is defined as the weighted average of the \(x_k\) values with weights \(p_k\), $$E[X] := \sum_{k=1}^n x_k p_k.$$ As we only work with discrete distributions with finite support, we don't provide a more general definition using the tools from measure theory and instead content ourselves with the basic one above.
Note that there are two ways to use this function, one being
expected_value() and the other one being the S4 generic method mean().
See also ‘Examples.’