Soccer Expected Goals Calculator Formula

Understand the math behind the soccer expected goals calculator. Each variable explained with a worked example.

Formulas Used

Total Expected Goals

total_xg = shots_inside_box * 0.12 + shots_outside_box * 0.03 + headers * 0.06 + penalties * 0.76

Total Shots

total_shots = shots_inside_box + shots_outside_box + headers + penalties

xG per Shot

xg_per_shot = (shots_inside_box * 0.12 + shots_outside_box * 0.03 + headers * 0.06 + penalties * 0.76) / max(shots_inside_box + shots_outside_box + headers + penalties, 1)

Variables

VariableDescriptionDefault
shots_inside_boxShots Inside the Box8
shots_outside_boxShots Outside the Box5
headersHeaders3
penaltiesPenalties Taken1

How It Works

Expected Goals (xG) in Soccer

Expected goals (xG) measures the quality of scoring chances by assigning each shot a probability of being scored based on historical data.

Simplified xG Values

  • Inside box: ~0.12 xG per shot
  • Outside box: ~0.03 xG per shot
  • Headers: ~0.06 xG per shot
  • Penalties: ~0.76 xG per penalty
  • Total xG = Sum of all shot xG values

    Professional xG models use 10+ variables including exact location, body part, assist type, game state, and goalkeeper position.

    Worked Example

    A team takes 8 shots inside the box, 5 outside, 3 headers, and 1 penalty.

    shots_inside_box = 8shots_outside_box = 5headers = 3penalties = 1
    1. 01Inside box xG = 8 x 0.12 = 0.96
    2. 02Outside box xG = 5 x 0.03 = 0.15
    3. 03Headers xG = 3 x 0.06 = 0.18
    4. 04Penalties xG = 1 x 0.76 = 0.76
    5. 05Total xG = 0.96 + 0.15 + 0.18 + 0.76 = 2.05

    Frequently Asked Questions

    What does xG of 2.0 mean?

    An xG of 2.0 means the team's shots had a combined probability of producing 2 goals. If they scored 3, they outperformed their xG; if they scored 1, they underperformed.

    Is xG useful for predicting results?

    Yes. Over a season, xG is a better predictor of future results than actual goals scored, because it measures underlying chance quality rather than finishing luck.

    What is a good xG per match?

    Top teams in major leagues average 1.5-2.5 xG per match. Creating 2+ xG consistently indicates a strong attack regardless of actual goals scored.

    Ready to run the numbers?

    Open Soccer Expected Goals Calculator