ForHosting KIT · Math

Marginal probability calculator

For the joint table 0.1, 0.2, 0.3, 0.4, the row marginal is 0.3 and 0.7 and the column marginal is 0.4 and 0.6. Paste the table, pick rows or columns, and the grand total is checked first. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon

Runs in your browser. Free, unlimited — your data never leaves this page.

A joint probability table lists every combination of two discrete variables and the probability of each pair. The marginal probability of one variable is what remains after you sum out the other: for the row variable you add across each row, and for the column variable you add down each column. This marginal probability calculator accepts a rectangular joint matrix of non-negative cells, checks that the grand total equals one, and returns the chosen marginal vector together with shape metadata and the textbook formula.

What a marginal probability tells you

In elementary probability a joint table for discrete variables X and Y stores P(X equals i and Y equals j) in cell (i, j). The law of total probability says the marginal of X is obtained by summing over every level of Y: P(X equals i) equals the sum over j of the joint cell in that row. Symmetrically, the marginal of Y is the sum over i of each column.

Those two operations are the entire mathematical core of this calculator. You send a rectangular matrix of finite non-negative numbers and a variable flag of row or column. The engine first measures the grand total of every cell.

Only when that total equals one within a tight floating-point tolerance does it compute the requested margin. Classic classroom checks include the two-by-two table with cells zero point one, zero point two, zero point three, and zero point four: the row marginal is zero point three and zero point seven, and the column marginal is zero point four and zero point six. Nothing is invented beyond the sum: there is no independence test, no conditional probability, and no continuous density.

Where marginal probability shows up in real work

Survey and market-research teams collapse multi-way response grids into one-way margins for reports without re-deriving row and column sums by hand in every spreadsheet. Machine-learning feature pipelines that start from estimated joint histograms need deterministic marginal checks before independence diagnostics or mutual-information code runs. Quality and reliability engineers turn joint failure-mode tables into marginal rates per component when communicating risk to non-statisticians.

Keep tables small, pin the rounded marginal in tests, and you get reproducible answers for homework, LMS plugins, and edge workers without standing up a full statistics library of your own. If you later need conditional probability given a joint cell, complement rules, or binomial distributions, treat those as separate search intents and landings rather than overloading this marginal calculator page.

Classroom contingency-table drills

Students paste a joint probability matrix and choose row or column to verify the marginal distribution matches the textbook sum-out rule.

Survey and market-research margins

Collapse a two-way response joint into one-way category probabilities for decks and dashboards without spreadsheet copy-paste errors.

How do you compute a marginal from a joint table?

For the row variable, sum each row across columns: P(X=i) = Σ_j P(X=i, Y=j). For the column variable, sum each column down the rows: P(Y=j) = Σ_i P(X=i, Y=j).

What does it cost?

The browser tool is free and runs locally.

What happens if my joint table does not add up to 1?

No marginal is returned. The calculator adds every cell first and only sums the rows or columns when the grand total equals one, within a tiny rounding tolerance, so a broken table cannot produce a convincing answer.

Should I choose the row or the column marginal?

Choose row for the distribution of the variable listed down the side, which adds across each row. Choose column for the variable across the top, which adds down each column. Either way you get one probability per level.

Can it calculate conditional probabilities or test independence?

No. It only sums one variable out of the joint table. Conditional probabilities, independence tests and continuous densities are different questions, so they need a separate tool.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/stat/marginal-probability

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/stat/marginal-probability \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"table":[[0.1,0.2],[0.3,0.4]],"variable":"row"}'
{
  "table": [
    [
      0.1,
      0.2
    ],
    [
      0.3,
      0.4
    ]
  ],
  "variable": "row"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "stat.marginal_probability",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Successful API calls are priced at the published base of $0.002 per item; validation failures are not charged.

What marginal probability means and what the response contains

The response echoes the cleaned joint table, reports the number of rows and columns, restates which variable was chosen, returns the marginal array in index order, reports the verified total, and includes a short formula string such as P(X equals i) equals sum over j of P(X equals i, Y equals j).

Input contract, aliases, validation, and error behaviour

Each row must be a non-empty array of finite non-negative numbers, all rows must share the same length, and dimensions are capped at sixty-four by sixty-four to keep browser and edge workers light. After parsing, the engine sums every cell. Negative cells fail even if the total happens to be one. On success the body includes table, rows, cols, variable, marginal, total, and formula. POST a JSON body with two required ideas: the joint table and which variable to marginalize to. The table field accepts aliases joint, matrix, joint_table, and p; provide exactly one so two conflicting matrices cannot slip through. Numeric strings are accepted per cell; empty strings, objects, NaN, and Infinity fail with invalid_input naming the row and column. The variable field accepts row or column, with classroom aliases x and zero for the row margin and y, one, and col for the column margin; margin, axis, var, and which are synonyms for the field name itself. If the absolute difference from one exceeds a small epsilon, the call fails with a message that the joint table total must equal one and that the marginal is undefined when the joint does not sum to one. That strict check is intentional: silent renormalization would hide transcription errors, percentage-scale mistakes such as sending whole numbers that sum to one hundred, and incomplete contingency tables. Pricing for successful API calls is the published base of $0.002 per item; validation failures do not consume prepaid balance and return the same invalid_input code the rest of the KIT catalog uses for client-side mistakes.

Where marginal probability shows up in real work

Secondary-school and college probability units constantly assign contingency-table drills, two-way frequency tables converted to joints, and “find the marginal of X” word problems; a single trusted oracle that returns cleaned JSON speeds grading, demo setup, and interactive lesson design. Curriculum authors building browser widgets want the same JSON shape free on the page and paid through the API so offline worksheets and online auto-graders stay aligned. Because this capability is a pure parse engine, every successful call costs the published $0.002 base price with no model tokens and no outbound network, and failed validation does not consume balance.

Grading fixtures and ML joint checks

Generate deterministic expected marginals for auto-graders, unit tests, and histogram pipelines that must sum out one axis of a joint table.

What if the joint cells do not add up to 1?

The request fails with invalid_input. This calculator does not renormalize; the table total must equal one before a marginal is returned.

Can I use matrix or joint as the field name?

Yes. Aliases table, joint, matrix, joint_table, and p all accept the same rectangular array of rows. Provide only one of them.

What values are allowed for variable?

Use row (aliases x, 0) for the row marginal or column (aliases y, 1, col) for the column marginal. Field-name aliases include margin, axis, var, and which.

Read the full KIT documentation →