Here is the question:
The time, to the nearest whole minute, that a city bus takes to go from one end of its route to the other has the probability distribution shown. As sometimes happens with probabilities computed as empirical relative frequencies, probabilities in the table add up only to a value other than $1.00$ because of round-off error. $$ \begin{array}{c|cccccc} x & 42 & 43 & 44 & 45 & 46 & 47 \\ \hline P(x) & 0.10 & 0.23 & 0.34 & 0.25 & 0.05 & 0.02 \\ \end{array} $$ a. Find the average time the bus takes to drive the length of its route.
b. Find the standard deviation of the length of time the bus takes to drive the length of its route.(Original image here.)
I did the first part and got $E(X)=43.54$, which is the correct answer. However, for the second part, I use the formula $\sigma = \sqrt{(\sum x^{2}P(x))-E(X)^{2}}$ and get approximately $4.517$. The answer is $1.204$. Where did I go wrong?
You are dealing with a slight inaccuracy due to rounding. By definition, the mean is $\mu = \sum_{i=1}^5 p_ix_i$ and the variance is $\sigma^2 = \sum_{i=1}^5p_i(x_i - \mu)^2.$ By a formula, derived from the definition, $$\sigma^2 = E(X^2) - \mu^2 = \sum_{i=2}^5p_ix_i^2 - \mu^2.$$ However, the formula is very sensitive to round-off error.
In R, the mean can be computed as follows:
This agrees with what you found.
According to the definition, the variance and standard deviation are
But the formula (exaggerating the errors) gives the standard deviation as
I don't know what you are supposed to show as the solution to this problem. However, to make sense of it, I think the logical course of action is to adjust the probabilities so that they add to 1:
Then use adjusted probabilities from the start to get the true mean and standard deviation (where both the definition and formula agree):