Calculate E[X] from incomplete data? The exercise I'm doing describes the random variable $X$ as the following
| Number of cars |  0  |  1 |  2 |  3 |  4+ |

| % of families  |  15 | 45 | 25 | 13 |  2  |

Then it asks me to evaluate $E[X]$. But if there could be cases with 4+ cars, wouldn't that make it impossible to calculate the expectancy?
 A: The percentages of families (15%, 45%, etc.) add to 100% so you
can take  $r_0 = 0.15, r_1=.0.45, r_2 = 0.25, r_3 = 0.13, p_4 = 0.02$
as approximate relative frequencies as the numbers of cars 0, 1, ..., 4
of cars per family. It is possible that a very small percentage of
families has more than 4 cars, but for an an approximate value of $E(X)$ it seems unlikely that the value would be far off.
Then you find $$E(X) \approx \sum_{k = 0}^4 kr_k
= 0(.15) + 1(.45) + \cdots + 4(.02) = 1.42.$$
So it seems that, on average, a family has about 1.42 cars.

This is an important concept, because as the size of the sample of
families increases, the relative frequencies $r_k$ become increasingly close
estimates of $P(X = k).$ Then the formal distribution of the
expectation $E(X)$ of the random variable $X$ becomes
$$E(X) = \sum_k kP(X = k),$$
where the sum is taken over all possible values $k.$
For another example, consider the random variable $Y$ that counts
the number of Heads when a fair coin is tossed four times. The
possible numbers of heads are $0, 1, 2, 3, 4$ and and the corresponding probabilities are $1/16,\, 4/16,\, 6/16,\, 4/16,\, 1/16.$ Thus, $E(Y) = \frac{0+4+12+12 + 4}{16} = 2.$
A: Elaborating on @Martijn Weterings' comment, you have what I believe is called right censored data - families with more than 4 cars get their actual number of cars censored at 4.
You can't directly calculate the mean number of cars without making some assumptions, some of which are discussed in Glass and Grey (citation below). That paper involves left censored data; they are using an instrument with a known lower detection limit to measure the level of some substance, hence a reading of 0 could actually be anywhere from 0 to the lower limit.
Related, but in survival analysis, we commonly have censoring. Usually, we conduct a study with a fixed follow-up time. Some patients die during the study. At the end of the study, we know the rest of them died anywhere from the study's end point to infinity. Survival analysis does compensate for this type of censoring. Alternatively, in a regression framework, Tobit regression can handle either left or right censoring and produce consistent inference about regression coefficients. Both are related to your data issue, but they don't help your specific question - this is just for general information.
The paper is DC Glass and CN Gray (2001), Estimating Mean Exposures from Censored Data: Exposure to Benzene in the Australian Petroleum Industry, Annals of Occupational Hygiene. It's web-searchable and available for free (I believe), but I can't link directly to the paper.
