Tools for agents: Exact independent outcome sum

Compute the exact distribution, expectation and variance of a sum of independent discrete integer outcomes.

Connect with MCP

{
  "mcpServers": {
    "super-agent-tools": {
      "url": "https://app.getsupers.com/sites/agent-discrete-sum/mcp"
    }
  }
}
Streamable HTTP · No API key · Stateless

Use this URL in any client supporting remote Streamable HTTP MCP. Calls return structured JSON; inputs are processed without persistence.

Call sum_discrete_distributions

Each inner list is one finite probability distribution. Values are signed integers and probabilities are integers or quoted finite decimal/fraction strings, never JSON floats or booleans. Every inner list must sum exactly to one; inputs are not automatically normalized. Duplicate values are combined and zero-probability outcomes disappear. Results are sorted by outcome value with reduced rational strings. The sum of no distributions is deterministically zero, with expectation and variance zero. Independence is an explicit mathematical assumption: this tool does not infer dependence or validate real-world likelihoods. All outcomes must share the same unit. Minimum and maximum refer only to positive-probability support. Sparse convolution can grow rapidly when many distinct sums are possible; use finite manageable supports. This computes a sum, not a mixture, simulation or conditional probability.

Input and output schemas
{
  "name": "sum_discrete_distributions",
  "title": "Exact independent outcome sum",
  "description": "Convolve finite independent integer-valued distributions with exact rational arithmetic; return the PMF, mean and variance.",
  "inputSchema": {
    "$defs": {
      "Outcome": {
        "additionalProperties": false,
        "properties": {
          "value": {
            "title": "Value",
            "type": "integer"
          },
          "probability": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "string"
              }
            ],
            "title": "Probability"
          }
        },
        "required": [
          "value",
          "probability"
        ],
        "title": "Outcome",
        "type": "object"
      }
    },
    "properties": {
      "distributions": {
        "items": {
          "items": {
            "$ref": "#/$defs/Outcome"
          },
          "type": "array"
        },
        "title": "Distributions",
        "type": "array"
      }
    },
    "required": [
      "distributions"
    ],
    "title": "sum_discrete_distributionsArguments",
    "type": "object"
  },
  "outputSchema": {
    "additionalProperties": true,
    "title": "sum_discrete_distributionsDictOutput",
    "type": "object"
  },
  "icons": null,
  "annotations": {
    "title": null,
    "readOnlyHint": true,
    "destructiveHint": false,
    "idempotentHint": true,
    "openWorldHint": false
  },
  "meta": null,
  "execution": null
}

Run the example to see the actual result.

HTTP alternative

POST https://app.getsupers.com/sites/agent-discrete-sum/call
Content-Type: application/json

{
  "distributions": [
    [
      {
        "value": -1,
        "probability": "1/4"
      },
      {
        "value": 2,
        "probability": "3/4"
      }
    ],
    [
      {
        "value": 0,
        "probability": "1/2"
      },
      {
        "value": 3,
        "probability": "1/2"
      }
    ]
  ]
}

The HTTP and MCP interfaces execute the same implementation. Validation errors are returned explicitly. See the tool notes above for its supported inputs and behavior.

Independent sum probabilities and duplicate outcomes

Read the explanation

The example has first outcome minus one with probability one quarter or two with probability three quarters. The second outcome is zero or three, each one half. Under the stated independence assumption, the pair minus one and zero has probability one eighth, while two and zero has three eighths. Bars share eleven hundred pixels per probability unit. Independence is an input assumption, not something the tool proves about real events. Four pairs produce sums minus one, two, two and five. The two distinct pairs yielding two carry one eighth and three eighths, which add to one half. The other sums have one eighth at minus one and three eighths at five. Bars grow in the common probability unit to show how duplicate sums combine. This is convolution of independent distributions, not a mixture or Monte Carlo estimate. The first expectation is minus one times one quarter plus two times three quarters, or five quarters. The second is three halves. Their sum is eleven quarters. Variance under independence adds twenty seven sixteenths and nine quarters to sixty three sixteenths. Bars compare the expectations in one shared outcome unit. The stored page delegates service execution and lacks its local shared script; these are mathematical derivations from the source example, not verified backend outputs.

Exact Discrete Outcome Sum by Sparse Rational Convolution

How does iterative discrete convolution calculate the exact probability distribution, mean, and variance of a sum of independent integer random variables?

When independent discrete random variables are added, the probability of obtaining any sum equals the sum of products of outcome probabilities that combine to that total. The backend service computes this exact distribution by representing probabilities with rational numbers, iteratively convolving adjacent probability mass functions, accumulating duplicate sum values, and computing exact rational mean and variance without floating-point rounding.

The algorithm strictly assumes mutual independence between distributions; it does not model covariance, joint copulas, or conditional dependence. Each distribution must be finite, integer-valued, and sum exactly to 1 under rational arithmetic. Floating-point numbers are prohibited, and runtime scales with the number of unique pairwise sums formed across iterations.

Try a worked example

Click "Run tool" with the default input containing two distributions: [(-1 with prob 1/4), (2 with prob 3/4)] and [(0 with prob 1/2), (3 with prob 1/2)]. The service convolves them into three support values: -1 with probability 1/8, 2 with probability 1/2 (merging -1+3 and 2+0), and 5 with probability 3/8, yielding an exact expectation of 11/4 and variance of 63/16.

Discrete Convolution and Probability Mass Functions

The distribution of the sum of independent random variables is given by the convolution of their individual distributions, where the probability of any sum k equals the sum of products P(X = i) * P(Y = k - i). In probability theory, the expectation of a sum of independent random variables equals the sum of their individual expectations, and their variances likewise sum directly. Convolution -- from Wolfram MathWorld

Exact Rational Computation via Python Fractions

The backend implementation utilizes Python's fractions.Fraction class to carry out all addition and multiplication operations using exact integer numerators and denominators, completely avoiding binary floating-point representation drift. fractions — Rational numbers — Python 3.14.8 documentation

Sources and further reading