Calculate weighted average of values with corresponding weights
This weighted average calculator combines a list of values with a matching list of weights and returns the weighted average, weighted sum, total weight, and item count.
Run — free
It is useful whenever some observations contribute more than others, including grades, ratings, prices, measurements, and composite scores. The calculation is deterministic and transparent: every value is multiplied by the weight in the same position, those products are added, and the result is divided by the sum of the weights. A zero weight total is rejected because it would make the division undefined.
Pair every value with its intended weight
Enter values and weights as two lists with exactly the same number of items. Position establishes the relationship: the first weight applies to the first value, the second weight applies to the second value, and so on. For example, values of 82, 91, and 76 paired with weights of 0.25, 0.5, and 0.25 give the middle value twice the influence of either outside value. Weights do not need to add up to one or one hundred, because the formula divides by their total automatically. The lists may represent test scores and assessment percentages, product ratings and review counts, investment returns and allocations, or any other paired numerical observations. Use only finite JSON numbers. Blank entries, text labels, infinity, missing arrays, empty arrays, and lists of different lengths are rejected instead of being silently ignored. This strict pairing prevents an omitted weight from shifting every later association and producing a plausible but incorrect result. Before calculating, check that both lists use the same ordering and that every weight expresses the influence you actually intend.
Understand the calculation and returned totals
The calculator multiplies each value by its corresponding weight and adds all of those products to obtain the weighted sum. It separately adds the weights to obtain the weight sum, then divides the weighted sum by the weight sum. The response exposes all three figures: weighted_average is the final result, weighted_sum is the numerator, and weight_sum is the denominator. It also returns count so you can confirm how many pairs participated. These intermediate totals make the result easy to audit in a spreadsheet, report, test, or downstream service. Scaling every weight by the same nonzero factor does not change the weighted average; weights of 2, 3, and 5 therefore have the same relative effect as 20, 30, and 50. Zero weights are allowed and simply give their paired values no influence. Negative weights are accepted as mathematical weights, although they can move the result outside the ordinary range of the supplied values and should only be used when the method genuinely calls for them. The implementation performs one deterministic pass and makes no network requests.
Avoid zero totals and interpret the result carefully
The sum of the weights must be nonzero. If all weights are zero, or positive and negative weights cancel exactly, division by the total would be undefined, so the calculator returns an invalid-input error rather than a misleading number. When weights describe percentages, verify that the chosen figures cover the intended components. They may total 100, 1, or another nonzero amount, but missing components can still make the answer conceptually incomplete even though the arithmetic is valid. For grades, decide how to treat work that has not yet been assessed: excluding an assignment is different from including it with a score of zero, while including it with a zero weight removes its effect entirely. For frequency-weighted data, weights normally represent counts and should usually be nonnegative. For portfolio or index calculations, negative weights may be meaningful but require domain-specific interpretation. Compare the returned weight_sum with the total you expected, and compare count with the number of source rows. Those two checks catch many input mistakes before the weighted average is stored, published, or used in another decision.
What you can do with it
Combine course components
Calculate a final grade when exams, projects, quizzes, and participation contribute different proportions.
Aggregate ratings by volume
Combine group ratings while giving groups with more observations the appropriate influence.
Build a composite score
Merge normalized indicators using explicit importance weights and retain the totals for auditing.
FAQ
What does the calculation cost?
Each API request costs $0.002; the browser calculator can run the same deterministic calculation locally.
Do weights have to add up to 100 or 1?
No. Any nonzero total works because the weighted sum is divided by the actual sum of the weights.
What happens when the weights sum to zero?
The request returns an invalid-input error because division by a zero total is undefined.
Can the lists have different lengths?
No. Every value must have exactly one corresponding weight at the same array position.
Are zero or negative individual weights allowed?
Yes, provided the total weight is not zero. A zero weight removes one value's influence, while negative weights require careful interpretation.
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/calc3/weighted-average-grade \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"values":[82,91,76],"weights":[0.25,0.5,0.25]}'const res = await fetch("https://api.kit.forhosting.com/calc3/weighted-average-grade", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"values": [
82,
91,
76
],
"weights": [
0.25,
0.5,
0.25
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/calc3/weighted-average-grade",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"values": [
82,
91,
76
],
"weights": [
0.25,
0.5,
0.25
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/calc3/weighted-average-grade", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"values":[82,91,76],"weights":[0.25,0.5,0.25]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"values":[82,91,76],"weights":[0.25,0.5,0.25]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/calc3/weighted-average-grade", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"values": [
82,
91,
76
],
"weights": [
0.25,
0.5,
0.25
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "calc3.weighted_average_grade",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |