{
  "schemaVersion": 1,
  "slug": "z-score-calculator",
  "category": "statistics",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "feede18b7b630f546a1c67cf2e8f09e13cd9d034589a1adf39856cf99e29f676",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/z-score-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "z = (x − μ) ÷ σ; P = Φ(z) × 100",
    "vars": [
      [
        "x",
        "Value"
      ],
      [
        "μ",
        "Mean"
      ],
      [
        "σ",
        "Standard deviation"
      ],
      [
        "z",
        "Z-score"
      ],
      [
        "P",
        "Percentile (%)"
      ]
    ],
    "note": "The standard-normal CDF Φ is approximated by: t = 1 ÷ (1 + 0.2316419|z|), φ = 0.3989423 × e^(−z² ÷ 2), Q = φ × t × (0.3193815 + t(−0.3565638 + t(1.781478 + t(−1.821256 + t × 1.330274)))); Φ(z) = 1 − Q for z > 0, otherwise Q. The percentile and upper-tail probability are approximations and require a suitable normal model."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "if(sd===0)return {z:null,percentile:null,deviation:null,probabilityAbove:null,__error:'inputError'};if(!(sd>0)||![value,mean,sd].every(Number.isFinite))return {z:null,percentile:null,deviation:null,probabilityAbove:null,__error:'inputError'};const deviation=value-mean;if(!Number.isFinite(deviation))return {z:null,percentile:null,deviation:null,probabilityAbove:null,__error:'inputError'};const z=deviation/sd;if(!Number.isFinite(z))return {z:null,percentile:null,deviation:null,probabilityAbove:null,__error:'inputError'};const cdf=x=>{const t=1/(1+0.2316419*Math.abs(x)),d=0.3989423*Math.exp(-x*x/2),p=d*t*(0.3193815+t*(-0.3565638+t*(1.781478+t*(-1.821256+t*1.330274))));return x>0?1-p:p;};return {z,percentile:cdf(z)*100,deviation,probabilityAbove:(1-cdf(z))*100};",
    "inputs": [
      {
        "name": "value",
        "type": "number",
        "default": 85,
        "min": -1000000000000,
        "max": 1000000000000,
        "step": 0.01
      },
      {
        "name": "mean",
        "type": "number",
        "default": 70,
        "min": -1000000000000,
        "max": 1000000000000,
        "step": 0.01
      },
      {
        "name": "sd",
        "type": "number",
        "default": 10,
        "min": 0,
        "max": 1000000000000,
        "step": 0.01
      }
    ],
    "outputs": [
      {
        "name": "z",
        "precision": 4,
        "unit": ""
      },
      {
        "name": "percentile",
        "precision": 2,
        "unit": "%"
      },
      {
        "name": "deviation",
        "precision": 4,
        "unit": ""
      },
      {
        "name": "probabilityAbove",
        "precision": 2,
        "unit": "%"
      }
    ],
    "interpret": null
  }
}
