{
  "id": "weighted-average",
  "version": "bb309b7ce2cd",
  "status": "published",
  "name": "Weighted Average Calculator",
  "question": "What is my weighted average score?",
  "summary": "Computes the weighted average (weighted mean) of values from their weights, with the sum of the weights and the plain average for comparison.",
  "category": "statistics",
  "subcategory": "descriptive",
  "url": "https://www.acalculator.org/statistics/weighted-average-calculator",
  "markdown": "https://www.acalculator.org/statistics/weighted-average-calculator.md",
  "kind": "function",
  "method": "weighted average = (w₁x₁ + w₂x₂ + … + wₙxₙ) ÷ (w₁ + w₂ + … + wₙ)",
  "assumptions": [
    "Each row holds one value and its weight.",
    "Weights cannot be negative, and at least one must be more than 0. They do not need to add up to 1 or 100.",
    "A weight of 0 leaves its value out of the weighted average."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "items": {
        "title": "Values and weights",
        "description": "One row per value, with its weight. Weights may be percents, counts, or credits.",
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "x": {
              "title": "Value",
              "description": "The value, such as a score.",
              "type": "number"
            },
            "w": {
              "title": "Weight",
              "description": "How much the value counts, 0 or more.",
              "type": "number",
              "minimum": 0
            }
          }
        }
      }
    }
  },
  "outputs": {
    "weightedMean": {
      "label": "Weighted average",
      "description": "The sum of each value times its weight, divided by the sum of the weights.",
      "format": "number"
    },
    "weightSum": {
      "label": "Sum of the weights",
      "description": "All the weights added up, Σw.",
      "format": "number"
    },
    "productSum": {
      "label": "Sum of value × weight",
      "description": "Each value times its weight, added up, Σw·x.",
      "format": "number"
    },
    "mean": {
      "label": "Plain average",
      "description": "The ordinary mean of the values, with every value counted once, for comparison.",
      "format": "number"
    },
    "count": {
      "label": "Count",
      "description": "How many values there are.",
      "format": "integer"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "items": [
        {
          "value": 92,
          "weight": 20
        },
        {
          "value": 85,
          "weight": 30
        },
        {
          "value": 78,
          "weight": 50
        }
      ]
    },
    "outputs": {
      "weightedMean": 82.9,
      "weightSum": 100,
      "productSum": 8290,
      "mean": 85,
      "count": 3
    },
    "text": "Weighted average of your values: 82.9."
  },
  "examples": [
    {
      "given": {
        "items": [
          {
            "value": 92,
            "weight": 20
          },
          {
            "value": 85,
            "weight": 30
          },
          {
            "value": 78,
            "weight": 50
          }
        ]
      },
      "expect": {
        "weightedMean": 82.9,
        "weightSum": 100,
        "productSum": 8290,
        "mean": 85
      },
      "source": "hand calculation in content.mdx: (92 × 20 + 85 × 30 + 78 × 50) ÷ 100 = 8290 ÷ 100 = 82.9"
    },
    {
      "given": {
        "items": [
          {
            "value": 2,
            "weight": 1
          },
          {
            "value": 3,
            "weight": 1
          },
          {
            "value": 5,
            "weight": 0
          },
          {
            "value": 7,
            "weight": 0
          },
          {
            "value": 11,
            "weight": 4
          },
          {
            "value": 13,
            "weight": 1
          },
          {
            "value": 17,
            "weight": 2
          },
          {
            "value": 19,
            "weight": 1
          },
          {
            "value": 23,
            "weight": 0
          }
        ]
      },
      "expect": {
        "weightedMean": 11.5,
        "weightSum": 10,
        "productSum": 115,
        "count": 9
      },
      "source": "NIST Dataplot Reference Manual, WEIGHTED MEAN (EQ 2-20) and its example data; hand calculation in content.mdx: 115 ÷ 10 = 11.5"
    },
    {
      "given": {
        "items": [
          {
            "value": 4,
            "weight": 3
          },
          {
            "value": 3,
            "weight": 4
          },
          {
            "value": 2,
            "weight": 3
          }
        ]
      },
      "expect": {
        "weightedMean": 3,
        "weightSum": 10,
        "productSum": 30
      },
      "source": "hand calculation in content.mdx: (4 × 3 + 3 × 4 + 2 × 3) ÷ 10 = 30 ÷ 10 = 3.0"
    }
  ],
  "sources": [
    "NIST Dataplot Reference Manual, WEIGHTED MEAN (EQ 2-20), March 18, 1997. https://itl.nist.gov/div898/software/dataplot/refman2/ch2/weigmean.pdf",
    "NIST/SEMATECH e-Handbook of Statistical Methods, section 1.3.5.1, Measures of Location (the mean). https://www.itl.nist.gov/div898/handbook/eda/section3/eda351.htm"
  ],
  "related": [
    "average",
    "standard-deviation"
  ],
  "changelog": []
}
