ForHosting KIT · Math

Expected value calculator

A fair die with faces 1 to 6 has an expected value of 3.5: the long-run average of many rolls, though no single roll shows it. List outcomes and probabilities to get the mean, variance and standard deviation. 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
Outcomes
1, 2, 3, 4, 5, 6
Probabilities
0.1666666667, 0.1666666667, 0.1666666667, 0.1666666667, 0.1666666667, 0.1666666667
You get
N
6
Sum probabilities
1
Expected value
3.5
Variance
2.9166666667

Expected value is the probability-weighted average of every possible outcome of a discrete random variable. Portfolio analysts weight returns by scenario probabilities, game designers weight payoffs by win chances, and students weight exam scores by likelihood of each grade. This calculator takes a list of numeric outcomes and a matching list of probabilities, verifies that the probabilities sum to one, and returns the expected value, the second moment, the variance, and the standard deviation of the distribution.

What expected value, variance, and standard deviation mean for a discrete distribution

The expected value E of X is the sum of each outcome times its probability: it is the long-run average you would observe if the experiment were repeated under the same measure forever. Two distributions can share the same mean yet behave very differently: one may put almost all mass near the mean while another places large mass on far tails. Variance captures that spread as the expected squared deviation from the mean, equivalently the second moment minus the square of the mean.

Standard deviation is the square root of variance and restores the original units of the outcomes, which is why risk reports and homework keys usually quote both the mean and the standard deviation side by side. Because every quantity is a finite sum of products, the formulas are classical and fully deterministic: the same outcomes and the same probabilities must always produce the same expected value, the same variance, and the same standard deviation.

That property makes the numbers safe to pin in automated tests, lesson answer keys, and reproducible notebooks without Monte Carlo noise that never quite settles twice.

How this calculator validates inputs and computes the moments

Call the capability with two required arrays of equal length: outcomes, the finite numeric support points, and probabilities, the weight of each point. After validation, the core walks the support once, accumulating the probability-weighted sum of the outcomes and the probability-weighted sum of their squares. Expected value is that first weighted sum; variance is the second moment minus the square of the mean, with a microscopic clamp so floating round-off cannot invent a negative variance for a valid measure; standard deviation is the non-negative square root of variance.

Homework and introductory probability labs

Students and graders verify E[X], Var(X), and SD for dice, coins, and custom discrete tables, including the hard rule that probabilities must sum to one.

Games of chance and fair-game checks

Designers weight payoffs by win probabilities to obtain expected return and spread before shipping a balance pass or tutorial example.

Scenario and risk dashboards

Analysts convert finite scenario outcomes and probabilities into a stable mean, variance, and standard deviation for reports and automated oracles.

What happens if the probabilities do not sum to one?

The message reports the observed sum so you can renormalize or correct the list. Validation failures are not charged.

How are variance and standard deviation computed?

Variance is E[X²] minus (E[X])² from a single pass over the support. Standard deviation is the square root of that variance, always non-negative for a valid probability measure.

Is the expected value calculator free?

The browser tool runs free on your device.

Does this simulate random samples from the distribution?

No. It evaluates the closed-form discrete moments deterministically. The same outcomes and probabilities always return the same expected value, variance, and standard deviation.

What is the expected value of a fair die?

It is 3.5. Each face from 1 to 6 has probability one sixth, so the weighted sum is 3.5, even though no single roll can show it: it is the long-run average over many rolls.

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/expected-value

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/expected-value \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"outcomes":[1,2,3,4,5,6],"probabilities":[0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666,0.1666666666666667]}'
{
  "outcomes": [
    1,
    2,
    3,
    4,
    5,
    6
  ],
  "probabilities": [
    0.16666666666666666,
    0.16666666666666666,
    0.16666666666666666,
    0.16666666666666666,
    0.16666666666666666,
    0.1666666666666667
  ]
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "prob.expected_value",
  "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_outcomes10000
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.

Lists that do not form a valid probability measure are rejected with a clear invalid_input error so broken models never produce silent nonsense numbers. The arithmetic is fully deterministic, runs free in your browser, and is available over the API at $0.002 per successful request.

What expected value, variance, and standard deviation mean for a discrete distribution

A discrete random variable X is completely described by a finite support of outcomes x_one through x_n together with probabilities p_one through p_n that are non-negative and sum exactly to one.

How this calculator validates inputs and computes the moments

The engine also accepts the aliases values and x for outcomes, and probs and p for probabilities, so scripts that already speak in those terms do not need a rename step. Validation rejects missing fields, empty arrays, mismatched lengths, non-finite numbers, negative probabilities, probabilities above one, and any list whose sum is not one within a tiny floating tolerance, all with invalid_input and without charging balance.

Practical use, limits, pricing, and delivery

Use the browser tool when you want an immediate mean and spread while checking a homework answer, sizing a simple game of chance, or explaining risk without installing a statistics package. Results are fully deterministic: the same outcomes and probabilities always yield the same expected value, variance, and standard deviation. There is no language model, no external probability service, and no randomness, so the capability is safe to pin in continuous-integration checks and reproducible lesson materials. Each successful request is one billable item at $0.002; failed validation does not consume balance. Accepted lists keep the loop bounded for Worker isolates: up to ten thousand support points cover common classroom and business examples while still finishing quickly. Wire the endpoint into decision-theory tutorials, fair-game checks, portfolio scenario sheets, or coding-interview sandboxes where you already prefer closed-form moment arithmetic over approximate simulation histograms that never quite land on the same mean twice.

How do I compute expected value with this calculator?

Send JSON with outcomes (array of numbers) and probabilities (matching array of weights that sum to 1) to prob.expected_value. The response returns expected_value, variance, standard_deviation, and second_moment.

Read the full KIT documentation →