# Descriptive formula for the expected value of a discrete frequency distribution

by Mike T   Last Updated March 13, 2016 08:08 AM

I'm trying to typeset a formula for an R expression that determines the mean or expected value of data for discrete distribution. Here's some example data to describe my question.

d <- density(c(8.4, 9.1, 10.2), n=201, from=0, to=20) # don't focus on this line!
x <- d[["x"]]   # these are the discrete points 0.0, 0.1, ..., 19.9, 20.0
fx <- d[["y"]]  # 9.20e-19 5.72e-19 3.14e-18 3.49e-19 0.00 ...


In this example, all that I have are two sequences of (e.g.) 201 points that describe the discrete points $x$ and their frequency intensities $f(x)$.

This is my R function to get the expected value (mean) of the discrete distribution:

sum(fx * x) / sum(fx)  # 9.233334


What should this formula look like? My best attempt is:

$\frac{\sum_{i=1}^n f(x)_i x_i}{\sum_{i=1}^n f(x)_i}$

But do I need the two sums, each with $i$ symbols? Are they even in the right place?

Tags :