
Simple and weighted average
Calculate the arithmetic average of a list, with or without weights.
Your inputs stay in your browser. Displayed results are rounded to a maximum of 12 significant digits.
Method and assumptions
Method version 1.0.0 · Updated
Simple average
Formula: Σx / n
Separate numbers with a semicolon or line break (1 to 1,000 values). A dot or comma can be used as the decimal separator, without thousands separators. Values remain in your browser. Each value has equal weight. Example: 10; 12; 14 → 12.
- values
- Values
Weighted average
Formula: Σ(x × w) / Σw
Separate numbers with a semicolon or line break (1 to 1,000 values). A dot or comma can be used as the decimal separator, without thousands separators. Values remain in your browser. One weight per value, in the same order. Weights are non-negative and their sum must be positive. A zero weight excludes the value. Example: values 10; 20, weights 1; 3 → 17.5.
- values
- Values
- weights
- Weights
High-precision decimal intermediate calculation, numeric result displayed with at most 12 significant digits. Results outside the numeric range are reported.
Calculate with code
These short examples use the same inputs and core calculation as this tool. Adapt validation and formatting to your application.
JavaScript
const values = [10, 12, 15];
const mean = values.reduce((sum, x) => sum + x, 0) / values.length;
console.log(mean); // 12.333…TypeScript
const values: number[] = [10, 12, 15];
const mean = values.reduce((sum, x) => sum + x, 0) / values.length;
console.log(mean); // 12.333…Python
values = [10, 12, 15]
print(sum(values) / len(values)) # 12.333…Java
double[] values = {10, 12, 15};
double mean = java.util.Arrays.stream(values).average().orElseThrow();
System.out.println(mean); // 12.333…C#
double[] values = [10, 12, 15];
Console.WriteLine(values.Average()); // 12.333… (using System.Linq)