{
  "schema": "leumas.docs.page/1",
  "id": "adapter:domain/statistics",
  "slug": "adapters/domain/statistics",
  "kind": "capabilities",
  "bucket": "package",
  "title": "statistics (engines/adapters/domain/statistics)",
  "name": "statistics",
  "eyebrow": "engines/adapters/domain/statistics",
  "chip": null,
  "summary": "Inferential statistics capability pack (pure JavaScript, zero dependencies): descriptive summary (mean, median, mode, variance, standard deviation, min, max, range, quartiles, IQR, skewness...",
  "keywords": [
    "statistics",
    "variance",
    "quartiles",
    "skewness",
    "kurtosis",
    "leumas statistics",
    "correlation",
    "pearson"
  ],
  "audience": "both",
  "funnel": {
    "product": null,
    "cta": null
  },
  "body": "# statistics (`engines/adapters/domain/statistics`)\n\nInferential-statistics capability pack. **Pure JavaScript, zero dependencies** — every special\nfunction (erf / normal CDF, log-gamma, regularized incomplete beta & gamma for t / F / chi-square\np-values, Acklam inverse-normal) is implemented inline with Node built-ins only.\n\nOne contract (`export default { metadata, adapters }`); every tool takes ONE args object (an HTTP\nPOST body maps 1:1) and returns a plain JSON-serializable result. Numeric inputs are coerced from\nJSON arrays, CSV/space strings, or single numbers; bad inputs throw `TypeError`/`Error`.\n\n## Tools (17)\n\n| tool | what it does |\n|------|--------------|\n| `describe` | full descriptive summary: mean, median, mode, min/max/range, Q1/Q3/IQR, sample & population variance/stdDev, skewness, excess kurtosis |\n| `correlation` | Pearson (linear) or Spearman (rank) correlation of `x`,`y` + t-test significance (`method`) |\n| `covariance` | sample (n-1) and population (n) covariance of `x`,`y` |\n| `linearRegression` | ordinary least squares `y = slope·x + intercept`, R², std errors, slope t-test |\n| `polynomialRegression` | least-squares polynomial fit of any `degree` (normal equations + Gaussian elimination), R² + adjusted R² |\n| `tTest` | Student t-test: `one-sample` (vs `mu`), `two-sample` (Welch), or `paired` (`method`) |\n| `zTest` | one-sample z-test with known population `sigma` |\n| `chiSquareTest` | chi-square `goodness`-of-fit (`observed`/`expected`) or `independence` (2D contingency `observed`) |\n| `anovaOneWay` | one-way ANOVA / F-test across `groups` (array of numeric arrays) |\n| `confidenceInterval` | CI for a mean — t-interval (sigma unknown) or z-interval (`sigma` given), any `confidence` |\n| `normalPdf` / `normalCdf` | normal density / cumulative probability at `value` for `mean`,`sigma` |\n| `binomial` | binomial PMF `P(X=k)` or CDF (`cumulative`) for `n`,`p` |\n| `poisson` | Poisson PMF `P(X=k)` or CDF (`cumulative`) for rate `lambda` |\n| `zScore` | standardize one `value` (vs `mean`/`sigma`) or a whole `data` sample |\n| `percentile` | value(s) at given `percentile`(s) via linear interpolation |\n| `histogram` | equal-width bins (Sturges' rule default, or explicit `bins`) with counts + density |\n\n## Usage\n\n```js\nimport statistics from './index.js';\n\nstatistics.adapters.describe({ data: [4, 8, 15, 16, 23, 42] });\n// { count: 6, mean: 18, median: 15.5, ... skewness, kurtosis }\n\nstatistics.adapters.tTest({ method: 'two-sample', x: [5, 7, 6, 8], y: [9, 11, 10, 12] });\n// { variant: 'welch', t: ..., df: ..., pValue: ... }\n\nstatistics.adapters.linearRegression({ x: [1, 2, 3, 4], y: [2, 4, 6, 8] });\n// { slope: 2, intercept: 0, rSquared: 1, equation: 'y = 2x + 0' }\n\nstatistics.adapters.binomial({ n: 10, p: 0.5, k: 3, cumulative: true });\n```\n\n`op` selects the tool when invoked through the adapter registry / MCP gateway. `adapterToServer()`\n(`@leumas/mcp-kit`) exposes each tool as an MCP tool + HTTP endpoint + form.\n\n## DRY boundary vs `numbers`\n\n`numbers` owns **descriptive** series analytics (running average, normalize/scale, percentile\ninsights, anomaly detection, derivatives, weighted scoring) plus scalar math and unit/base\nconversion. **This pack owns inferential statistics**: hypothesis tests, regression modelling,\ncorrelation/covariance, probability distributions, confidence intervals, and\nstandardization/percentile/histogram utilities. `describe` is offered here as a fuller descriptive\nsummary (skew/kurtosis/quartiles) so a statistical workflow is self-contained — for lightweight,\nstreaming series work reach for `numbers` instead. Neither pack imports the other.\n",
  "source": {
    "path": "shared/engines/adapters/domain/statistics/README.md",
    "blobSha": "",
    "commit": "",
    "committedAt": "",
    "provenance": "no-git",
    "bytes": 3870,
    "hash": "946df9736063b248a18aa1b7f12e329426309a3b"
  },
  "urls": {
    "html": "/p/adapters/domain/statistics",
    "json": "/docs/adapters/domain/statistics.json",
    "md": "/docs/adapters/domain/statistics.md"
  },
  "links": {
    "composes": [],
    "usedBy": [],
    "product": [],
    "howTo": [],
    "skills": []
  }
}
