{
  "id": "dice-probability",
  "version": "fb2d06a7de00",
  "status": "published",
  "name": "Dice Probability Calculator",
  "question": "What are the odds of my dice roll?",
  "summary": "Computes the exact probability that the sum of up to 10 fair dice is exactly, at least, or at most a target, with the number of ways and the average roll.",
  "category": "statistics",
  "subcategory": "probability",
  "url": "https://www.acalculator.org/statistics/dice-probability-calculator",
  "markdown": "https://www.acalculator.org/statistics/dice-probability-calculator.md",
  "kind": "function",
  "method": "Count the rolls of n dice with s sides whose faces add up to each sum (the sidesⁿ rolls are equally likely), then probability = favourable rolls ÷ sidesⁿ.",
  "assumptions": [
    "Every die is fair, with faces numbered 1 to the number of sides, and the dice are rolled independently.",
    "The counts are exact whole numbers, so the fraction is exact; the decimal is rounded once."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "n": {
        "title": "Number of dice",
        "description": "How many dice you roll together, from 1 to 10.",
        "type": "integer",
        "minimum": 1,
        "maximum": 10
      },
      "s": {
        "title": "Sides on each die",
        "description": "The number of faces on each die, numbered 1 to that number: 6 for a standard die, 20 for a d20.",
        "type": "integer",
        "minimum": 2,
        "maximum": 100
      },
      "cmp": {
        "title": "The sum is",
        "description": "Whether the sum must equal the target, be at least the target, or be at most the target.",
        "type": "string",
        "enum": [
          "exactly",
          "atLeast",
          "atMost"
        ]
      },
      "t": {
        "title": "Target sum",
        "description": "The total of the faces you are counting.",
        "type": "integer",
        "minimum": 0,
        "maximum": 1000
      }
    }
  },
  "outputs": {
    "probability": {
      "label": "Probability",
      "description": "The chance that the sum meets the condition, as a decimal from 0 to 1.",
      "format": "number"
    },
    "fraction": {
      "label": "As a fraction",
      "description": "The same probability as an exact fraction in lowest terms, such as 1/6.",
      "format": "text"
    },
    "oneIn": {
      "label": "About 1 in",
      "description": "The total rolls divided by the favourable rolls: on average, one roll in this many meets the condition.",
      "format": "number"
    },
    "ways": {
      "label": "Favourable rolls",
      "description": "The number of equally likely rolls whose sum meets the condition.",
      "format": "integer"
    },
    "total": {
      "label": "All possible rolls",
      "description": "The number of equally likely rolls: sides to the power of the number of dice.",
      "format": "integer"
    },
    "mean": {
      "label": "Average sum",
      "description": "The expected value of the sum: dice × (sides + 1) ÷ 2.",
      "format": "number"
    },
    "sd": {
      "label": "Standard deviation of the sum",
      "description": "The spread of the sum: √(dice × (sides² − 1) ÷ 12).",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "n": 2,
      "s": 6,
      "cmp": "exactly",
      "t": 7
    },
    "outputs": {
      "probability": 0.16666666666666666,
      "fraction": "1/6",
      "oneIn": 6,
      "ways": "6",
      "total": "36",
      "mean": 7,
      "sd": 2.41522945769824
    },
    "text": "Exactly 7 on 2 dice with 6 sides: 0.166667 (1/6)."
  },
  "examples": [
    {
      "given": {
        "n": 2,
        "s": 6,
        "cmp": "exactly",
        "t": 7
      },
      "expect": {
        "probability": 0.16666666666666666,
        "fraction": "1/6",
        "ways": 6,
        "total": 36,
        "oneIn": 6,
        "mean": 7,
        "sd": 2.41522945769824
      },
      "source": "hand calculation in content.mdx: (1,6) (2,5) (3,4) (4,3) (5,2) (6,1) = 6 of 36; OpenStax, Contemporary Mathematics, §7.5 Basic Concepts of Probability. https://openstax.org/books/contemporary-mathematics/pages/7-5-basic-concepts-of-probability"
    },
    {
      "given": {
        "n": 2,
        "s": 6,
        "cmp": "atMost",
        "t": 10
      },
      "expect": {
        "probability": 0.9166666666666666,
        "ways": 33
      },
      "source": "OpenStax, Contemporary Mathematics, §7.5 Basic Concepts of Probability. https://openstax.org/books/contemporary-mathematics/pages/7-5-basic-concepts-of-probability, Example 7.22 (1 − 3/36 = 11/12)"
    },
    {
      "given": {
        "n": 3,
        "s": 6,
        "cmp": "exactly",
        "t": 10
      },
      "expect": {
        "probability": 0.125,
        "fraction": "1/8",
        "ways": 27,
        "total": 216,
        "mean": 10.5
      },
      "source": "hand calculation in content.mdx: 27 ÷ 216 = 0.125; Grinstead and Snell, Introduction to Probability, 1997, §7.1 Sums of Discrete Random Variables. https://math.dartmouth.edu/~prob/prob/prob.pdf"
    },
    {
      "given": {
        "n": 1,
        "s": 20,
        "cmp": "atLeast",
        "t": 15
      },
      "expect": {
        "probability": 0.3,
        "ways": 6,
        "oneIn": 3.3333333333333335
      },
      "source": "hand calculation in content.mdx: faces 15 to 20 are 6 of 20; OpenStax, Contemporary Mathematics, §7.5 Basic Concepts of Probability. https://openstax.org/books/contemporary-mathematics/pages/7-5-basic-concepts-of-probability"
    },
    {
      "given": {
        "n": 10,
        "s": 6,
        "cmp": "exactly",
        "t": 35
      },
      "expect": {
        "probability": 0.07269280597469897,
        "ways": 4395456,
        "total": 60466176,
        "mean": 35
      },
      "source": "hand calculation in content.mdx: coefficient of x³⁵ in (x + … + x⁶)¹⁰ is 4,395,456 (Python enumeration); Grinstead and Snell, Introduction to Probability, 1997, §7.1 Sums of Discrete Random Variables. https://math.dartmouth.edu/~prob/prob/prob.pdf"
    },
    {
      "given": {
        "n": 10,
        "s": 100,
        "cmp": "atLeast",
        "t": 1000
      },
      "expect": {
        "probability": 1e-20,
        "fraction": "1/100000000000000000000",
        "ways": 1,
        "total": "100000000000000000000"
      },
      "source": "hand calculation in content.mdx: 1 ÷ 100¹⁰; Grinstead and Snell, Introduction to Probability, 1997, §7.1 Sums of Discrete Random Variables. https://math.dartmouth.edu/~prob/prob/prob.pdf"
    }
  ],
  "sources": [
    "OpenStax, Contemporary Mathematics, §7.5 Basic Concepts of Probability (two dice, 36 outcomes). https://openstax.org/books/contemporary-mathematics/pages/7-5-basic-concepts-of-probability",
    "Grinstead and Snell, Introduction to Probability, 1997, §7.1 Sums of Discrete Random Variables. https://math.dartmouth.edu/~prob/prob/prob.pdf"
  ],
  "related": [
    "probability",
    "binomial-distribution",
    "expected-value",
    "point-buy"
  ],
  "changelog": []
}
