# Probability API
> Probability distributions and combinatorics as an API. The binomial endpoint gives the probability of exactly k successes in n trials (PMF), the cumulative probability up to k (CDF), and the mean, variance and standard deviation. The poisson endpoint does the same for the Poisson distribution from a rate λ. The normal endpoint computes the z-score, probability density, cumulative probability (CDF) and percentile for a value under a normal distribution with any mean and standard deviation — and runs in reverse, turning a probability into the value (the quantile / inverse CDF) and its z-score. The combinatorics endpoint computes combinations (nCr), permutations (nPr) and factorials with exact big-integer arithmetic. Everything is computed locally and deterministically, so it is instant and private. Ideal for data science and statistics, quality control and A/B-test planning, gaming and gambling odds, risk modelling, and statistics education. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 5 endpoints. This is probability theory; for descriptive statistics on a dataset use a statistics API and for general expression evaluation use a math API.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/probability-api/..."
```

## Pricing
- **Free** (Free) — 8,035 calls/Mo, 2 req/s
- **Starter** ($10/Mo) — 17,550 calls/Mo, 8 req/s
- **Pro** ($29/Mo) — 226,500 calls/Mo, 20 req/s
- **Mega** ($67/Mo) — 1,175,000 calls/Mo, 50 req/s

## Endpoints

### Probability

#### `GET /v1/binomial` — Binomial distribution

**Parameters:**
- `n` (query, required, string) — Trials Example: `10`
- `p` (query, required, string) — Success probability Example: `0.5`
- `k` (query, required, string) — Successes Example: `5`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/probability-api/v1/binomial?n=10&p=0.5&k=5"
```

**Response:**
```json
{
    "data": {
        "k": 5,
        "n": 10,
        "p": 0.5,
        "sd": 1.5811388,
        "cdf": 0.62304687,
        "pmf": 0.24609375,
        "mean": 5,
        "variance": 2.5,
        "distribution": "binomial"
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:05.800Z",
        "request_id": "24f85575-cfdf-4965-98b9-785c69e06e5f"
    },
    "status": "ok",
    "message": "Binomial",
    "success": true
}
```

#### `GET /v1/combinatorics` — nCr / nPr / factorial

**Parameters:**
- `n` (query, required, string) — Total Example: `52`
- `r` (query, optional, string) — Chosen Example: `5`
- `op` (query, optional, string) — combinations|permutations|factorial Example: `combinations`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/probability-api/v1/combinatorics?n=52&r=5&op=combinations"
```

**Response:**
```json
{
    "data": {
        "n": 52,
        "r": 5,
        "op": "combinations",
        "result": "2598960",
        "notation": "C(52,5)"
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:05.902Z",
        "request_id": "8c38d880-bcaa-4d7a-ab3e-add64497eb8f"
    },
    "status": "ok",
    "message": "Combinatorics",
    "success": true
}
```

#### `GET /v1/normal` — Normal distribution

**Parameters:**
- `x` (query, optional, string) — A value Example: `1.96`
- `mean` (query, optional, string) — Mean (default 0) Example: `0`
- `sd` (query, optional, string) — SD (default 1) Example: `1`
- `probability` (query, optional, string) — Or a probability -> quantile

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/probability-api/v1/normal?x=1.96&mean=0&sd=1"
```

**Response:**
```json
{
    "data": {
        "x": 1.96,
        "sd": 1,
        "cdf": 0.97500217,
        "pdf": 0.058440944,
        "mean": 0,
        "z_score": 1.96,
        "percentile": 97.5002,
        "upper_tail": 0.024997826,
        "distribution": "normal"
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:05.984Z",
        "request_id": "83f4d450-acf3-443c-a5d4-7e28bdd83ab6"
    },
    "status": "ok",
    "message": "Normal",
    "success": true
}
```

#### `GET /v1/poisson` — Poisson distribution

**Parameters:**
- `lambda` (query, required, string) — Rate Example: `3`
- `k` (query, required, string) — Occurrences Example: `2`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/probability-api/v1/poisson?lambda=3&k=2"
```

**Response:**
```json
{
    "data": {
        "k": 2,
        "sd": 1.7320508,
        "cdf": 0.42319008,
        "pmf": 0.22404181,
        "mean": 3,
        "lambda": 3,
        "variance": 3,
        "distribution": "poisson"
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:06.098Z",
        "request_id": "707912c7-6a07-47c9-8870-09b756c87858"
    },
    "status": "ok",
    "message": "Poisson",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Spec

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/probability-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "name": "Probability API",
        "notes": "Normal CDF via the erf approximation; inverse via Acklam's algorithm. Combinatorics is exact big-integer. Nothing is stored.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/binomial",
                "params": {
                    "k": "successes",
                    "n": "trials",
                    "p": "success probability 0-1"
                },
                "returns": "PMF, CDF, mean, variance, sd"
            },
            {
                "path": "/v1/poisson",
                "params": {
                    "k": "occurrences",
                    "lambda": "rate"
                },
                "returns": "PMF, CDF, mean, variance, sd"
            },
            {
                "path": "/v1/normal",
                "params": {
                    "x": "a value",
                    "sd": "default 1",
                    "mean": "default 0",
                    "probability": "or a probability to get the quantile"
                },
                "returns": "z-score, PDF, CDF and percentile (or the value for a probability)"
            },
            {
                "path": "/v1/combinatorics",
                "params": {
                    "n": "total",
                    "r": "chosen",
                    "op": "combinations|permutations|factorial"
                },
                "returns": "the exact count"
            },
          
…(truncated, see openapi.json for full schema)
```


---
Marketplace page: https://www.oanor.com/api/probability-api
OpenAPI spec: https://www.oanor.com/api/probability-api/openapi.json
