ForHosting KIT · Math

Geometric distribution calculator

If each try succeeds with probability 0.25, the first success lands exactly on the third try with probability 0.140625, and you should expect 4 tries on average. Enter the success chance and the trial number to get both. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Power (W)
0.25
K
3
You get
Q
0.75
Probability
0.140625
Probability number
0.140625
Probability percent
14.0625

The geometric distribution answers a simple repeated-trial question: if every attempt succeeds with the same probability p, what is the chance that the first success lands exactly on trial k? Students meet this model in textbooks; analysts meet it in retry loops, sales funnels, and quality-control spot checks. This capability evaluates the classic trials-until-first-success form of the geometric law: P(X equals k) equals (1 minus p) to the power (k minus 1), times p, for positive integers k. It also returns the expectation E[X] equals one over p, the variance, and the cumulative probability that the first success has already happened by trial k. Inputs are validated strictly: p must lie in the open-closed interval (0, 1], and k must be a whole positive integer within published limits.

What the geometric model covers and how probability is defined

Imagine independent Bernoulli trials that each succeed with fixed probability p and fail with probability q equals one minus p. Keep going until the first success appears. The random variable X is the trial number of that first success, so the support is the positive integers one, two, three, and so on.

Exactly one path produces a first success on trial k: fail on the first k minus one trials, then succeed on trial k. Because trials are independent, that path has probability q to the power (k minus one) times p. That expression is the probability mass function returned by this calculator.

The expectation follows from the standard series for the geometric law: on average you need one over p trials before the first success, so a process with p equals one fourth expects four attempts. Variance is q over p squared, which grows when successes are rare.

The cumulative distribution function F of k equals one minus q to the power k, which is the probability that the first success has already occurred on or before trial k—useful when a policy says “give up after ten tries” and you want the chance you already succeeded by then. This landing deliberately uses the trials-until-success convention (support starts at one), not the failures-before-success convention (support starts at zero). Both appear in literature; they shift k by one and change the expectation from one over p to q over p.

Coin-flip style demos with p equals one half and small k are easy to check by hand: for k equals three you get (one half) squared times one half equals one eighth. Edge cases are handled explicitly: when p equals one, the first success is certain on trial one and impossible later; when p approaches zero the mass spreads over large k and the expectation grows without bound—so p equals zero is rejected rather than returning a silent infinity.

Retry and polling design

Given an estimated per-attempt success rate, compute the chance the first success lands on attempt k and the mean number of tries before a service answers.

Quality control and inspection sampling

Model independent item inspections until the first defect (or first pass) and report both the trial-k probability and the expected inspection count.

Which geometric convention does this use?

Trials until first success: X is the trial number of the first success, so k starts at 1 and P(X=k)=(1-p)^(k-1)*p with E[X]=1/p.

What values of p are allowed?

p must be in (0, 1]: greater than zero and at most one.

Is the result approximate or exact?

The formulas are exact; floating-point evaluation uses log-space for large k so the PMF remains stable. No random sampling is used.

Is the geometric distribution calculator free?

The browser tool is free and runs locally.

What is the chance of succeeding by trial k at the latest?

That is the cumulative value: one minus the failure chance raised to the power k. With a success chance of 0.25 and the third try it is 0.578125, useful when a rule says to give up after a fixed number of attempts.

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/prob/geometric-distribution

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/prob/geometric-distribution \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"p":0.25,"k":3}'
{
  "p": 0.25,
  "k": 3
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "prob.geometric_distribution",
  "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_k1000000
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.

Values of p outside zero to one are rejected with invalid_input so homework answers and production retries stay honest.

What the geometric model covers and how probability is defined

If your textbook writes P of Y equals k as q to the k times p for k starting at zero, translate by setting this tool’s k to Y plus one, or compare only the shared p and the PMF formula printed in the JSON.

How to call the API and read the JSON response

Two formula strings document the convention so downstream UIs can show the same definition humans searched for. Classic check: p equals zero point two five and k equals three yields probability zero point one four zero six two five, expected trials four, and variance twelve. Another check: p equals one and k equals one yields probability one and expected trials one; the same p with k equals two yields probability zero. Send a JSON body with two required fields. Field p is the success probability on each trial; aliases probability, success_p, and prob are accepted. It must be a finite number strictly greater than zero and at most one. Field k is the trial index of the first success you care about; aliases trial, n, and trials map to the same meaning. k must be a whole integer from one through one million. A successful response echoes the normalized p and k, the failure probability q, and the PMF as both a trimmed decimal string (probability) and an IEEE double (probability_number) plus a percentage string. It also returns expected_trials as one over p, variance as q over p squared, and the CDF at k as cdf and cdf_number. Pricing is a flat $0.002 per successful request with unit item and zero marginal unit price. Prefer probability (string) when you need stable display digits; use probability_number when you will chain further floating-point math in a client script.

Practical tips, limits, and how this differs from related tools

Do not confuse this landing with binomial tools or combination counters elsewhere in the kit: the binomial law counts how many successes occur in a fixed number of trials, while the geometric law stops at the first success and treats the trial index as random. Dice-sum probability landings answer a different search intent—sums of polyhedral faces—not repeated Bernoulli waits. If you need the failures-before-success parameterization, convert: number of failures before first success is X minus one, with expectation q over p; this calculator keeps the trial-number form because that matches the phrase “first success on trial k” in search queries. Stay inside k at most one million so log-space evaluation of the PMF stays cheap in both Worker and browser. For classroom demos, prefer small textbook pairs—p equals one half with k equals one through five, or p equals one tenth with k equals ten—so students can expand (one minus p) to the power (k minus one) by hand and match the API line by line. When modeling software retries, map “attempt number” to k and the observed success rate to p; expected_trials then tells you the mean number of attempts before a healthy endpoint answers, and the CDF tells you how often you finish within a budgeted attempt limit. Failed validation never spends prepaid balance, so exploratory scripts can probe edges cheaply. Prefer the printed formula fields when documenting homework solutions, and prefer expected_trials over ad-hoc spreadsheet inverses of p so every teammate shares the same definition of the mean wait.

Homework and probability teaching labs

Assign geometric PMF and expectation exercises and let students check P(X=k) and E[X]=1/p against a deterministic API or free browser result.

What does expected_trials mean?

It is E[X] = 1/p, the mean number of independent trials needed until the first success under this geometric model.

Read the full KIT documentation →