{
  "openapi": "3.1.1",
  "info": {
    "title": "Probability & Statistics Studio API",
    "version": "1.0.0",
    "summary": "Distributions, descriptive stats, confidence intervals and t, chi-square and z tests with p-values.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://probabilitystatisticsstudio.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Distributions, descriptive stats, confidence intervals and t, chi-square and z tests with p-values.",
        "description": "Probabilities, densities and quantiles for the normal, t, chi-square, F, binomial, Poisson, exponential and uniform distributions with plots; descriptive statistics of a data set; confidence intervals for a mean or a proportion; and one-sample, two-sample and paired t-tests, chi-square goodness-of-fit and independence tests and z-tests for proportions, each with a p-value and a plain-language interpretation.\n\nMethodology:\n- Special functions are implemented directly: log-gamma (Lanczos), the regularised incomplete gamma function (series and continued fraction) and the regularised incomplete beta function (continued fraction). The normal CDF uses erfc via the incomplete gamma function; its quantile uses Acklam’s approximation refined by Halley steps.\n- CDFs: t and F via the incomplete beta function, chi-square and Poisson via the incomplete gamma function, binomial via the incomplete beta function. Quantiles of continuous distributions are found by bisection with a Newton polish; discrete quantiles are the smallest k with P(X ≤ k) ≥ p.\n- Values are checked in the test suite against published tables (e.g. Φ(1.96) = 0.975002, t₀.₉₇₅ with 10 df = 2.228139, χ²₀.₉₅ with 5 df = 11.0705, F₀.₉₅(5, 10) = 3.3258).\n- Descriptive statistics use the sample (n − 1) variance, quartiles by linear interpolation (the R/Excel default), the adjusted skewness and excess kurtosis, and the 1.5 × IQR outlier rule.\n- Tests: one-sample, Welch or pooled two-sample and paired t-tests; chi-square goodness-of-fit and independence (without continuity correction); one- and two-proportion z-tests (pooled for the test, unpooled for the interval). The interpretation compares p with α = 1 − confidence.\n\nA p-value is not the probability that H0 is true, and “not significant” does not prove H0. Check the assumptions listed with each test.",
        "tags": [
          "math"
        ],
        "x-mcp-tool": "probability_statistics_studio",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProbabilityStatisticsStudioInput"
              },
              "examples": {
                "example1": {
                  "summary": "Normal: P(Z ≤ 1.96) and the 97.5% quantile",
                  "value": {
                    "analysis": "distribution",
                    "distribution": "normal",
                    "param1": 0,
                    "param2": 1,
                    "x": 1.96,
                    "probability": 0.975
                  }
                },
                "example2": {
                  "summary": "Binomial: exactly / at most 5 heads in 10 flips",
                  "value": {
                    "analysis": "distribution",
                    "distribution": "binomial",
                    "param1": 10,
                    "param2": 0.5,
                    "x": 5,
                    "x2": 7
                  }
                },
                "example3": {
                  "summary": "Descriptive statistics",
                  "value": {
                    "analysis": "describe",
                    "data": "12, 15, 11, 18, 14, 15, 22, 13, 16, 15, 40"
                  }
                },
                "example4": {
                  "summary": "One-sample t-test",
                  "value": {
                    "analysis": "t-one",
                    "data": "5.1 4.9 5.6 5.8 6.0 5.3 5.5 5.7",
                    "mu0": 5
                  }
                },
                "example5": {
                  "summary": "Welch two-sample t-test",
                  "value": {
                    "analysis": "t-two",
                    "data": "20.1 22.3 19.8 21.5 23.0 20.7",
                    "data2": "18.2 19.5 17.9 18.8 20.1 19.0 18.4"
                  }
                },
                "example6": {
                  "summary": "Chi-square test of independence",
                  "value": {
                    "analysis": "chisq-indep",
                    "data": "30 10\n20 40"
                  }
                },
                "example7": {
                  "summary": "Confidence interval for a proportion",
                  "value": {
                    "analysis": "ci-proportion",
                    "successes": 42,
                    "trials": 120,
                    "confidence": 0.95
                  }
                },
                "example8": {
                  "summary": "Two-proportion z-test",
                  "value": {
                    "analysis": "z-two-prop",
                    "successes": 45,
                    "trials": 100,
                    "successes2": 30,
                    "trials2": 100
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProbabilityStatisticsStudioResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "ProbabilityStatisticsStudioInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "analysis": {
            "title": "Analysis",
            "type": "string",
            "enum": [
              "distribution",
              "describe",
              "ci-mean",
              "ci-proportion",
              "t-one",
              "t-two",
              "t-paired",
              "chisq-gof",
              "chisq-indep",
              "z-one-prop",
              "z-two-prop"
            ],
            "default": "distribution"
          },
          "distribution": {
            "title": "Distribution",
            "type": "string",
            "enum": [
              "normal",
              "t",
              "chisq",
              "f",
              "binomial",
              "poisson",
              "exponential",
              "uniform"
            ],
            "default": "normal"
          },
          "param1": {
            "title": "Parameter 1",
            "description": "Defaults: normal μ = 0, t df = 10, chi-square df = 1, F d1 = 5, binomial n = 10, Poisson λ = 1, exponential λ = 1, uniform a = 0.",
            "type": "number"
          },
          "param2": {
            "title": "Parameter 2",
            "description": "Defaults: normal σ = 1, F d2 = 10, binomial p = 0.5, uniform b = 1.",
            "type": "number"
          },
          "x": {
            "title": "Value x",
            "description": "Distribution: compute pdf/pmf and P(X ≤ x).",
            "type": "number"
          },
          "x2": {
            "title": "Second value x₂",
            "description": "Optional: also compute P(x ≤ X ≤ x₂).",
            "type": "number"
          },
          "probability": {
            "title": "Probability p (for a quantile)",
            "description": "Distribution: the x with P(X ≤ x) = p (e.g. 0.975).",
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "data": {
            "title": "Data / sample 1 / observed counts / table",
            "description": "Numbers separated by spaces, commas or new lines. For the independence test: one row of counts per line.",
            "type": "string",
            "maxLength": 200000
          },
          "data2": {
            "title": "Sample 2 / expected counts",
            "description": "Two-sample and paired tests: the second sample. Goodness of fit: expected counts or proportions (optional; equal by default).",
            "type": "string",
            "maxLength": 200000
          },
          "mu0": {
            "title": "Hypothesised mean μ0",
            "type": "number",
            "default": 0
          },
          "sigma": {
            "title": "Known population SD σ",
            "description": "Optional, for a z interval for the mean.",
            "type": "number",
            "minimum": 0
          },
          "successes": {
            "title": "Successes x (group 1)",
            "type": "integer",
            "minimum": 0
          },
          "trials": {
            "title": "Trials n (group 1)",
            "type": "integer",
            "minimum": 1
          },
          "successes2": {
            "title": "Successes x (group 2)",
            "type": "integer",
            "minimum": 0
          },
          "trials2": {
            "title": "Trials n (group 2)",
            "type": "integer",
            "minimum": 1
          },
          "p0": {
            "title": "Hypothesised proportion p0",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.5
          },
          "confidence": {
            "title": "Confidence level",
            "description": "Also sets α = 1 − confidence for the tests.",
            "type": "number",
            "minimum": 0.5,
            "maximum": 0.9999,
            "default": 0.95
          },
          "alternative": {
            "title": "Alternative hypothesis",
            "type": "string",
            "enum": [
              "two-sided",
              "less",
              "greater"
            ],
            "default": "two-sided"
          },
          "equalVariances": {
            "title": "Assume equal variances (pooled two-sample t-test)",
            "type": "boolean",
            "default": false
          }
        },
        "required": []
      },
      "ProbabilityStatisticsStudioResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "analysis",
              "distribution",
              "descriptive",
              "interval",
              "test",
              "warnings"
            ],
            "properties": {
              "analysis": {
                "type": "string",
                "enum": [
                  "distribution",
                  "describe",
                  "ci-mean",
                  "ci-proportion",
                  "t-one",
                  "t-two",
                  "t-paired",
                  "chisq-gof",
                  "chisq-indep",
                  "z-one-prop",
                  "z-two-prop"
                ]
              },
              "distribution": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "label": {
                    "type": "string"
                  },
                  "discrete": {
                    "type": "boolean"
                  },
                  "mean": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "variance": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "sd": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "pdfAtX": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "cdfAtX": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "survivalAtX": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "P(X > x)"
                  },
                  "between": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "P(x ≤ X ≤ x₂)"
                  },
                  "quantile": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "x": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "x2": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "probability": {
                    "type": [
                      "number",
                      "null"
                    ]
                  }
                }
              },
              "descriptive": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "properties": {
                  "n": {
                    "type": "integer"
                  },
                  "mean": {
                    "type": "number"
                  },
                  "median": {
                    "type": "number"
                  },
                  "modes": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  },
                  "sd": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "variance": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "min": {
                    "type": "number"
                  },
                  "max": {
                    "type": "number"
                  },
                  "q1": {
                    "type": "number"
                  },
                  "q3": {
                    "type": "number"
                  },
                  "iqr": {
                    "type": "number"
                  },
                  "se": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "skewness": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "kurtosis": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "sum": {
                    "type": "number"
                  },
                  "outliers": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  }
                }
              },
              "interval": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "properties": {
                  "method": {
                    "type": "string"
                  },
                  "confidence": {
                    "type": "number"
                  },
                  "estimate": {
                    "type": "number"
                  },
                  "lower": {
                    "type": "number"
                  },
                  "upper": {
                    "type": "number"
                  },
                  "margin": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "alternatives": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "method": {
                          "type": "string"
                        },
                        "lower": {
                          "type": "number"
                        },
                        "upper": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              },
              "test": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "h0": {
                    "type": "string"
                  },
                  "h1": {
                    "type": "string"
                  },
                  "statistic": {
                    "type": "number"
                  },
                  "statisticName": {
                    "type": "string"
                  },
                  "df": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "pValue": {
                    "type": "number"
                  },
                  "alpha": {
                    "type": "number"
                  },
                  "reject": {
                    "type": "boolean"
                  },
                  "estimate": {
                    "type": "number"
                  },
                  "ciLower": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "ciUpper": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "effectName": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "effectSize": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "interpretation": {
                    "type": "string"
                  },
                  "details": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "value": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}