{
  "schemaVersion": 1,
  "slug": "batting-average-calculator",
  "category": "sports",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "db14010da717d40963be616cea48e7cea1d55410b1eced29a398454ae765f10f",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/batting-average-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": "Average = Runs / Dismissals; Strike rate = 100·Runs / Balls faced",
    "vars": [
      [
        "I",
        "Innings"
      ],
      [
        "n",
        "Not outs"
      ],
      [
        "D",
        "Dismissals"
      ],
      [
        "r",
        "Runs"
      ],
      [
        "b",
        "Balls faced"
      ],
      [
        "A",
        "Batting average"
      ],
      [
        "SR",
        "Strike rate"
      ]
    ],
    "note": "This is a cricket batting average and strike-rate calculator. It does not calculate baseball batting average."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "if (![runs,innings,notOuts,ballsFaced].every(Number.isFinite)||![runs,innings,notOuts,ballsFaced].every(Number.isInteger)||notOuts>innings)return{average:null,strikeRate:null,dismissals:null,ballsPerDismissal:null,__error:'inputError'};const dismissals=innings-notOuts,average=dismissals>0?runs/dismissals:null,strikeRate=ballsFaced>0?runs/ballsFaced*100:null,bpd=dismissals>0?ballsFaced/dismissals:null;return{average,strikeRate,dismissals,ballsPerDismissal:bpd};",
    "inputs": [
      {
        "name": "runs",
        "type": "number",
        "default": 850,
        "min": 0,
        "max": 100000,
        "step": 1
      },
      {
        "name": "innings",
        "type": "number",
        "default": 25,
        "min": 0,
        "max": 2000,
        "step": 1,
        "slider": true
      },
      {
        "name": "notOuts",
        "type": "number",
        "default": 5,
        "min": 0,
        "max": 2000,
        "step": 1,
        "slider": true
      },
      {
        "name": "ballsFaced",
        "type": "number",
        "default": 900,
        "min": 0,
        "max": 200000,
        "step": 1
      }
    ],
    "outputs": [
      {
        "name": "average",
        "precision": 2,
        "unit": "",
        "optional": true
      },
      {
        "name": "strikeRate",
        "precision": 1,
        "unit": "",
        "optional": true
      },
      {
        "name": "dismissals",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "ballsPerDismissal",
        "precision": 1,
        "unit": "",
        "optional": true
      }
    ],
    "interpret": null
  }
}
