Weighted average calculator

Weighted average calculator: enter values with weights, one pair per line, for the weighted mean, sum of weights and each value's contribution.

Drafted with AI writing toolsUpdated Checked examples: 7

One pair per line: the value, then its weight. Separate them with a space, comma or tab, and don't use thousands separators. A label in front is optional.
Try
Weighted average
Weighted average: 82.9
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

Value 118.4Value 225.5Value 339

Share of the total weight

82.9weighted average
Value 120%Value 230%Value 350%
Each value's share Rows: 3
ItemValueWeightShare of weightValue × weightContribution
Value 1922020 %1,84018.4
Value 2853030 %2,55025.5
Value 3785050 %3,90039
How it's calculated S
  1. Multiply each value by its weight

    92×20=1,84085×30=2,55078×50=3,900\begin{aligned} 92 \times 20 &= 1{,}840 \\ 85 \times 30 &= 2{,}550 \\ 78 \times 50 &= 3{,}900 \end{aligned}
  2. Add the products and the weights

    ∑wx=1,840+2,550+3,900=8,290∑w=20+30+50=100\sum wx = 1{,}840 + 2{,}550 + 3{,}900 = 8{,}290 \qquad \sum w = 20 + 30 + 50 = 100
  3. Divide

    xˉw=∑wx∑w=8,290100=82.9\bar x_w = \frac{\sum wx}{\sum w} = \frac{8{,}290}{100} = 82.9
  4. Compare with the unweighted average

    xˉ=∑xn=2553=85\bar x = \frac{\sum x}{n} = \frac{255}{3} = 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 purchaseSecond purchaseTotal quantityAverage price
100 × 10110 × 2030106.666667
100 × 1090 × 203093.333333
100 × 10120 × 2030113.333333
100 × 10110 × 1020105
100 × 0.5110 × 1.52107.5
100 × 10110 × 010100
101 × 10111 × 2030107.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.

ExampleSum of weightsSum of productsWeighted average
Default percentage grade100829082.9
Proportional integer grade1082982.9
Percentage total of eighty80640080
Mixed percent notation80640080
Credit-weighted GPA1448.73.478571
Equal general weights36020
Zero-weighted general value18080
Negative mathematical values8243

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.

Worked examples

Course grade (default)

Values and weights
92 20% 85 30% 78 50%
Weighted average
82.9
Sum of weights
100 %
Sum of value × weight
8,290
Number of values
3
Unweighted average
85

Checked against: Hand calculation: (92 × 20 + 85 × 30 + 78 × 50) / 100 = 8290 / 100 = 82.9

GPA by credit hours (Inch Calculator example)

Values and weights
3.0 4 4.0 3 3.7 4 3.3 3
Weighted average
3.48
Sum of weights
14
Sum of value × weight
48.7

Checked against: Inch Calculator weighted average page: (3.0×4 + 4.0×3 + 3.7×4 + 3.3×3) / 14 = 48.7 / 14, GPA 3.48

GPA with four classes (Omni Calculator example)

Values and weights
A 4 4 B 3 4 A 4 3 C+ 2.3 2
Weighted average
3.430769
Sum of weights
13
Sum of value × weight
44.6
Unweighted average
3.325

Checked against: Omni Calculator weighted average page: (4·4 + 3·4 + 4·3 + 2.3·2) / 13 = 3.43

Average share price

Values and weights
100 10 110 20
Weighted average
106.666667
Sum of value × weight
3,200
Sum of weights
30
Unweighted average
105

Checked against: Hand calculation: (100 × 10 + 110 × 20) / 30 = 3200 / 30 = 106.67

Questions

How do you calculate a weighted average?

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.

About this calculator

xˉw=∑i=1nwixi∑i=1nwi\bar x_w = \frac{\sum_{i=1}^{n} w_i x_i}{\sum_{i=1}^{n} w_i}

Sources

  1. Wolfram MathWorld: Weighted mean
  2. NIST Dataplot reference manual: WEIGHTED SUM (Σ wᵢxᵢ)

Checked against references

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.

Height
Preview the embed

Keep the credit line. It is the only condition, and it is what keeps these calculators free.