# Negative variance result when calculating standard deviation

Please note, I am still in secondary school so please keep your answers simple. A question on my homework states to calculate the standard deviation from a given frequency table with several class widths and frequencies. When calculating my variance, the result turned out to be a negative number, which means that the standard deviation cannot be a realistic number as you cannot square root a negative number.

I rechecked my calculations, asked my dad, looked online, back in my book, and in several text books and followed the instructions there; and even did some other standard deviation questions, albeit with the correct result in the other questions. My question is thus, what could have happened that would cause the variance to be a negative number?

I know I cannot be much help by displaying the actual data here because of problems with formatting, but here are the column names and what I named them as:

Price (y) (£) Frequency (f) Midpoint (x) f * x (fx) fx * x (fx^2)

My method to find the variance was as follows:

1) Total up the frequency column, and store the answer in Σf

2) Multiply each number in the frequency column by its corresponding number in the midpoint column, and store each of these answers in a column called fx.

3) Multiply each number in the fx column by its corresponding number in the frequency column, and store each of these answers in a column called fx^2.

4) Total up the fx and fx^2 columns, and store the answers in Σfx and Σfx^2, respectively.

5) Find the mean by diving Σfx by Σf and storing it in x̄.

6) Find the variance by doing:

Σfx^2/Σf - (Σfx/Σf)^2

The numbers I have are:

Σf = 28

Σfx = 119250

Σfx^2 = 669750

Could anybody possibly tell me what I am doing wrong here?

EDIT:

Requested table, sorry, this is my best attempt at a table, apologies for bad formatting:

Price (y) (£)

 500 \< x < 1000
1000 \< x < 2000
2000 \< x < 4000
4000 \< x < 6000
6000 \< x < 8000
8000 \< x < 10000


Frequency (f)

3
4
6
8
5
2

• Your fx^2 calculation is totally wrong. You're multiplying the midpoint values by the square of the frequency. You need the midpoint values squared times the frequency. – Mark L. Stone May 2 '16 at 16:20
• Mark, so for the first one, would I do 750^3? – Leo Chashchin May 2 '16 at 16:23
• No, (750^2)*3. Note that the parentheses are redundant, but I included them for clarity. – Mark L. Stone May 2 '16 at 16:25
• Thanks Mark, that helped me sort out my fx^2 column, and now my variance and standard deviation both look more realistic. Thanks again! – Leo Chashchin May 2 '16 at 16:33

In that situation the sampled variance should be:

\begin{align}S^{2}&=\frac{\sum f\left(X-\overline{X}\right)^{2}}{\left(\sum{f}\right)-1}=\frac{\sum f\left(X-\overline{X}\right)^{2}}{n-1}\\\overline{X}&=\frac{\sum{f\dot{}X}}{\sum{f}}=\frac{\sum{f\dot{}X}}{n}\end{align}

And there's no way that could be negative.

So, you have to:

• Determine $n = \sum{f}$

• Add a column $f\dot{}X$ to your table

• Use $\frac{\sum{f\dot{}X}}{n}$ to compute $\overline{X}$

• Add a column $\left(X-\overline{X}\right)$

• Square it in another column $\left(X-\overline{X}\right)^{2}$

• Multiply it by the frequency $f\dot{}\left(X-\overline{X}\right)^{2}$ in another column

• Then sum the values of this last column and divide to calculate $S^{2}=\frac{\sum{f\dot{}\left(X-\overline{X}\right)^{2}}}{n-1}$