ForHosting KIT · Developer Utilities

Two-stage probability tree calculator

A two-stage probability tree turns a sequence of uncertain events into a complete list of outcomes.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Enter the probabilities for the first stage, then enter the conditional probabilities for every second-stage branch under each first-stage result. The calculator multiplies along each path to find every leaf probability and checks the structure before returning an answer. If the first-stage branches or any conditional branch set do not sum to one, the request fails with a clear validation message instead of presenting a misleading distribution.

Describe the first stage and its conditional branches

Start by listing every mutually exclusive outcome that can occur in the first stage. Give each outcome a distinct label and a probability between zero and one. Those first-stage probabilities must sum to one because together they represent all possible ways the process can begin. Next, add the second-stage outcomes as conditional rows. Each row identifies its first-stage parent, names the second-stage outcome, and supplies the probability of that outcome given the parent. A parent label must match a first-stage label exactly. Second-stage labels only need to be unique within their own parent, so a label such as “success” can appear below several first-stage branches. Include at least one second-stage row for every parent. The conditional probabilities below each individual parent must also sum to one. This flat row format makes a larger tree easy to enter, review, store, or generate from another application without hiding the relationships in nested, handwritten JSON.

Understand how each leaf probability is calculated

Every returned row represents one complete route from the root through the first stage and then through the second stage. Its probability is the first-stage probability multiplied by the relevant conditional probability. For example, if rain has probability 0.30 and being late given rain has probability 0.40, the rain-then-late path has probability 0.12. This multiplication rule is the standard product rule for a joint event expressed through a conditional probability. The result preserves both factors beside the computed path probability, which makes the arithmetic transparent and suitable for checking, teaching, spreadsheets, or downstream code. It also reports the number of leaf paths and the sum of all path probabilities. Valid complete trees have a total probability of one, apart from the tiny representation effects inherent in floating-point arithmetic. The calculator does not assume that second-stage probabilities are independent of the first stage; the point of separate conditional branch sets is to model that dependence directly.

Catch incomplete trees before using the results

A probability tree can look plausible while silently omitting an outcome or counting overlapping outcomes twice. The calculator therefore validates the probability mass at every branching point. It rejects a first stage whose probabilities do not sum to one, and it independently rejects the conditional set under any parent that does not sum to one. It also rejects missing conditional sets, unknown parent labels, duplicate first-stage labels, duplicate child labels within one parent, non-numeric values, non-finite values, and probabilities outside the zero-to-one range. A small numerical tolerance accommodates ordinary decimal floating-point representation, but it does not excuse a materially incomplete distribution. Use the output when you need leaf probabilities, not simulation results: the calculation is exact for the supplied numbers and uses no random sampling. The same deterministic solver runs for each request, so identical valid input produces identical output. API automation is available for $0.002 per request, while the declared structure remains suitable for an interactive form.

Map diagnostic outcomes

Combine a condition's initial probability with conditional positive and negative test outcomes to list every complete path.

Plan operational scenarios

Calculate final probabilities for delivery, demand, staffing, or weather outcomes whose second stage depends on the first.

Check probability homework

Verify multiplication along branches and detect incomplete probability sets before comparing a worked solution.

What is a leaf path probability?

It is the joint probability of following one first-stage branch and then one of its conditional second-stage branches.

Why must every branch set sum to one?

Each set is expected to describe all mutually exclusive outcomes available at that branching point. A different total indicates missing, overlapping, or incorrect probabilities.

How is a path probability calculated?

The calculator multiplies the first-stage probability by the second-stage probability conditional on that first-stage outcome.

Can the same second-stage label appear under different parents?

Yes. It must be unique within a parent branch, but the same outcome name may be meaningful under several different parents.

Does this calculator simulate random trials?

No. It deterministically computes exact products from the probabilities you provide; it does not sample or estimate through simulation.

What does an API request cost?

Each API request costs $0.002. No per-branch price is added.

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/probability-tree-two-stage

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/probability-tree-two-stage \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"first_stage":[{"label":"Rain","probability":0.3},{"label":"Dry","probability":0.7}],"conditional_second_stage":[{"first_stage":"Rain","label":"Late","probability":0.4},{"first_stage":"Rain","label":"On time","probability":0.6},{"first_stage":"Dry","label":"Late","probability":0.1},{"first_stage":"Dry","label":"On time","probability":0.9}]}'
{
  "first_stage": [
    {
      "label": "Rain",
      "probability": 0.3
    },
    {
      "label": "Dry",
      "probability": 0.7
    }
  ],
  "conditional_second_stage": [
    {
      "first_stage": "Rain",
      "label": "Late",
      "probability": 0.4
    },
    {
      "first_stage": "Rain",
      "label": "On time",
      "probability": 0.6
    },
    {
      "first_stage": "Dry",
      "label": "Late",
      "probability": 0.1
    },
    {
      "first_stage": "Dry",
      "label": "On time",
      "probability": 0.9
    }
  ]
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "stat.probability_tree_two_stage",
  "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.

max_first_stage_branches100
max_conditional_branches1000
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.

Read the full KIT documentation →