Maximum decimal places: 6; Nearest, ties away from zero
Sum of weights
100%
Sum of value × weight
8,290
Number of values
3
Unweighted average
85
The weighted average is 82.9: the products add up to 8,290 and the weights to 100. The unweighted average is 85. Value 3, with the largest weight (50% of the total), pulls the result down toward 78.
What each value adds to the weighted average
Share of the total weight
Value 120%Value 230%Value 350%
Each value's share Rows: 3
Item
Value
Weight
Share of weight
Value × weight
Contribution
Value 1
92
20
20 %
1,840
18.4
Value 2
85
30
30 %
2,550
25.5
Value 3
78
50
50 %
3,900
39
How it's calculated S
Multiply each value by its weight
92×2085×3078×50=1,840=2,550=3,900
Add the products and the weights
∑wx=1,840+2,550+3,900=8,290∑w=20+30+50=100
Divide
xˉw=∑w∑wx=1008,290=82.9
Compare with the unweighted average
xˉ=n∑x=3255=85
Weighting moves the average down by 2.1.
About the weighted average calculator
A weighted average multiplies each value by its weight, adds the products and divides by the sum of the weights: Σwx ÷ Σw. Values with larger weights pull the result toward themselves, and with equal weights it is the ordinary mean.
Course grades are the usual case. With homework at 92 counting 20%, the midterm at 85 counting 30% and the final at 78 counting 50%, the products add up to 8,290 and the weights to 100, so the weighted average is 82.9, while the plain average of the three scores is 85. Weights can be credits for a GPA, share counts for an average purchase price, or any relative importance.
Weights only need to be in proportion: 20%, 30% and 50% give the same answer as 2, 3 and 5. They must not be negative, and at least one must be above zero. A label before the numbers on a line, such as “Final exam”, is carried into the table.
How to calculate a weighted average
Multiply each value by its weight, add the products, and divide by the sum of the weights: Σ(value × weight) / Σweight. Homework at 92, a midterm at 85 and a final exam at 78, weighted 20%, 30% and 50%, give (1,840 + 2,550 + 3,900) / 100 = 82.9. Their plain average is 85.
Weights only need to be in proportion, so 2, 3 and 5 give the same 82.9. In a spreadsheet the formula is =SUMPRODUCT(values, weights)/SUM(weights). The NIST Dataplot weighted-mean reference defines it the same way.
Each value contributes value × weight ÷ Σweight, and the contributions add up to the average. In the grade example they are 18.4 + 25.5 + 39 = 82.9, so the final exam supplies almost half of the result.
Average purchase price of shares
For shares bought at different prices, the price is the value and the number of shares is the weight. Ten shares at 100 and twenty at 110 cost 1,000 + 2,200 = 3,200 for 30 shares, an average of 106.666667 per share.
Averaging the two prices gives 105, which ignores that twice as many shares were bought at 110. Write each purchase as price, then quantity, on its own line:
100 10
110 20
First purchase
Second purchase
Total quantity
Average price
100 × 10
110 × 20
30
106.666667
100 × 10
90 × 20
30
93.333333
100 × 10
120 × 20
30
113.333333
100 × 10
110 × 10
20
105
100 × 0.5
110 × 1.5
2
107.5
100 × 10
110 × 0
10
100
101 × 10
111 × 20
30
107.666667
Multiplying every quantity by the same factor leaves the average unchanged, and the average always lies between the lowest and highest prices bought. Fractional quantities work, and a lot with quantity 0 has no effect.
If you record lots as shares then price, with fees as one total, the stock average cost calculator works that way and also gives unrealized profit or loss and a position size.
Weighted grades, GPA and percentage weights
For a course grade, the scores are the values and each component's share of the grade is its weight. A % sign marks a relative weight, so 20% counts as 20 and a plain 0.2 counts as 0.2. Use one scale on every line.
Example
Sum of weights
Sum of products
Weighted average
Default percentage grade
100
8290
82.9
Proportional integer grade
10
829
82.9
Percentage total of eighty
80
6400
80
Mixed percent notation
80
6400
80
Credit-weighted GPA
14
48.7
3.478571
Equal general weights
3
60
20
Zero-weighted general value
1
80
80
Negative mathematical values
8
24
3
Percentage weights need not total 100. If they total 80% because an exam is still to come, dividing by 80 gives the average of the work done so far. Mixing % and plain weights treats them all as plain numbers.
For GPA, use grade points as values and credits as weights. Grades of 3.0, 4.0, 3.7 and 3.3 over 4, 3, 4 and 3 credits give 48.7 / 14 = 3.478571. The GPA calculator converts letter grades for you.
Values can be negative, as in (−3 × 2 + 5 × 6) / 8 = 3, but weights cannot.
Purchase fees and tax cost basis
To include purchase fees, spread each fee over its lot. A fee of 10 on ten shares at 100 makes the price 101; a fee of 20 on twenty shares at 110 makes it 111. The total outlay is then 3,230 for 30 shares, an average of 107.666667.
Average purchase price is not always the cost basis allowed for tax; the rules depend on the asset and the country.
The IRS stock-basis FAQ separates specific identified lots and first-in, first-out treatment from the limited cases where average basis is allowed.
How to type values and weights
One pair per line: the value, then its weight, separated by a space, comma or tab.
No thousands separators. "1,000 10" is read as the value 0 with weight 10, so type 1000 10.
An optional label goes first, as in First lot 100 10; blank lines and lines starting with # are skipped.
Weights must be zero or more, with at least one above zero, and a list can hold up to 500 pairs.
Multiply each value by its weight, add the products, and divide by the total weight. For scores of 92, 85 and 78 weighted 20%, 30% and 50%: 92 × 20 + 85 × 30 + 78 × 50 = 8,290, and 8,290 ÷ 100 = 82.9. In a spreadsheet the same formula is =SUMPRODUCT(values, weights)/SUM(weights).
Do the weights have to add up to 100%?
No. Dividing by the sum of the weights rescales them automatically, so weights of 2, 3 and 5 give the same result as 20%, 30% and 50%. If percentage weights add up to 90% because a grade item is still missing, the result is the average of the work done so far, with each item's weight divided by 0.9.
How do you calculate a weighted GPA?
Use the grade points as values and the credit hours as weights. For a B (3.0) in a 4-credit class, an A (4.0) in 3 credits, an A− (3.7) in 4 credits and a B+ (3.3) in 3 credits, the quality points are 12 + 12 + 14.8 + 9.9 = 48.7 over 14 credits, a GPA of 3.48. The GPA calculator converts letter grades for you.
What is the difference between a weighted average and a simple average?
A simple average gives every value the same weight, 1/n. A weighted average lets some values count more. For the default grades the simple average is (92 + 85 + 78) ÷ 3 = 85, but the final exam, worth half the grade, pulls the weighted average down to 82.9. Equal weights always give the same result; unequal weights can also balance to the same average.
How do you find the average price of shares bought at different prices?
Weight each price by the number of shares bought at it. Buying 10 shares at $100 and 20 at $110 costs $1,000 + $2,200 = $3,200 for 30 shares, an average of $106.67 per share, not the $105 you get by averaging the two prices. This is the mathematical average purchase price before fees. Tax cost basis depends on the asset and applicable rules; this arithmetic does not select a permitted basis method.
This calculator includes 7 worked examples with independently sourced answers. They run in the test suite, and you can run them here too.
Put this calculator on your site
Paste this where you want the calculator to appear. It is free to use, it stays in step with corrections made here, and the credit line below it links back so your readers can find the full version.