{
  "schemaVersion": 1,
  "slug": "data-usage-calculator",
  "category": "household",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "c9cb7ca4932db2705872f9d0fff2f86b1c98bb88dcd2a3dae6d9e0514449be50",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/data-usage-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": "T = 30(r_s H_s + 0.15H_m + 0.1H_g + 0.8H_c + 0.5N) + D_x",
    "vars": [
      [
        "T",
        "Monthly total (GB)"
      ],
      [
        "r_s",
        "Video rate (GB/h: 0.7 SD, 1.5 HD, 7 UHD)"
      ],
      [
        "H_s",
        "Streaming hours/day"
      ],
      [
        "H_m",
        "Music hours/day"
      ],
      [
        "H_g",
        "Gaming hours/day"
      ],
      [
        "H_c",
        "Video-call hours/day"
      ],
      [
        "N",
        "Connected devices (each)"
      ],
      [
        "D_x",
        "Extra downloads (GB)"
      ]
    ],
    "note": "N devices adds 0.5 GB/day each; D_x extra downloads added in GB; daily = T÷30; percent of cap = 100T÷cap."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const streamRate = { sd: 0.7, hd: 1.5, uhd: 7 }[resolution] || 1.5; const stream = streamingHours*streamRate*30; const music = musicHours*0.15*30; const gaming = gamingHours*0.1*30; const calls = videoCalls*0.8*30; const browsing = devices*0.5*30; const other = music + gaming + calls + browsing + downloadsGB; const total = stream + other; const parts = [['Streaming video', stream], ['Music', music], ['Gaming', gaming], ['Video calls', calls], ['Browsing and downloads', browsing + downloadsGB]]; parts.sort((a, b) => b[1] - a[1]); return { streamingData: stream, otherData: other, totalPerMonth: total, totalPerDay: total/30, percentOfCap: dataCap > 0 ? total/dataCap*100 : 0, capStatus: total > dataCap ? 'Over your cap by ' + Math.round(total - dataCap) + ' GB' : 'Within your cap, ' + Math.round(dataCap - total) + ' GB spare', largestSource: parts[0][0] };",
    "inputs": [
      {
        "name": "streamingHours",
        "type": "number",
        "default": 3,
        "min": 0,
        "max": 24,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "resolution",
        "type": "select",
        "default": "hd",
        "options": [
          {
            "value": "sd"
          },
          {
            "value": "hd"
          },
          {
            "value": "uhd"
          }
        ]
      },
      {
        "name": "musicHours",
        "type": "number",
        "default": 1,
        "min": 0,
        "max": 24,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "gamingHours",
        "type": "number",
        "default": 1,
        "min": 0,
        "max": 24,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "videoCalls",
        "type": "number",
        "default": 1,
        "min": 0,
        "max": 24,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "downloadsGB",
        "type": "number",
        "default": 20,
        "min": 0,
        "max": 10000,
        "step": 1
      },
      {
        "name": "devices",
        "type": "number",
        "default": 4,
        "min": 1,
        "max": 100,
        "step": 1,
        "slider": true
      },
      {
        "name": "dataCap",
        "type": "number",
        "default": 1000,
        "min": 1,
        "max": 100000,
        "step": 1
      }
    ],
    "outputs": [
      {
        "name": "streamingData",
        "precision": 1,
        "unit": "GB"
      },
      {
        "name": "otherData",
        "precision": 1,
        "unit": "GB"
      },
      {
        "name": "totalPerMonth",
        "precision": 1,
        "unit": "GB"
      },
      {
        "name": "totalPerDay",
        "precision": 2,
        "unit": "GB"
      },
      {
        "name": "percentOfCap",
        "precision": 1,
        "unit": "%"
      },
      {
        "name": "capStatus",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "largestSource",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
