跳至內容
Astera Technology

列出假設標籤分布,不當作實際比例

先計各類錯誤比例,有另提供工作比重才做有條件加權。

下載完整個案資料及參考答案 ↓

訂明本例驗收任務

假設驗收分 standard 及 exception 兩類,各列錯誤與總數。先報各類錯誤比例及整組比例。另有必需的 standardShare 欄;正式工作比重未知須明示 null,有比重則以0至10000整數基點表示;只在此假設下加權。比重為 null,正式工作錯誤比例仍未知。這些是有限假設資料,不是流量實測或已驗證人口估算。

  1. 按各類錯誤及總數計比例
  2. 整組假設比例另列
  3. 有另提供比重才計正式加權

數量或比重無效便停計;比重未知用明示 null,省略欄位則無效。

使用已填個案

原創假設輸入及確切答案鍵
個案已提供輸入預期結構化結果判斷及原因
正式工作比重未量度{"standard":{"errors":1,"total":4},"exception":{"errors":3,"total":4},"standardShare":null}{"standardError":[1,4],"exceptionError":[3,4],"fixtureError":[1,2],"assumedDeploymentError":null}平衡個案錯誤為 1/2;欠正式比重不能推出正式加權數字。
另提供九比一假設{"standard":{"errors":1,"total":4},"exception":{"errors":3,"total":4},"standardShare":9000}{"standardError":[1,4],"exceptionError":[3,4],"fixtureError":[1,2],"assumedDeploymentError":[3,10]}另設比重下 0.9×1/4+0.1×3/4=3/10,不同於平衡個案 1/2。
欠比重欄位{"standard":{"errors":1,"total":4},"exception":{"errors":3,"total":4}}{"error":"counts-or-prevalence"}資料須有 standardShare;比重未知要明示 null,不能省略欄。
另設全屬一般類{"standard":{"errors":1,"total":4},"exception":{"errors":3,"total":4},"standardShare":10000}{"standardError":[1,4],"exceptionError":[3,4],"fixtureError":[1,2],"assumedDeploymentError":[1,4]}比重恰好全 standard,只加權其 1/4;exception 依據仍列出。
下載可編輯 CSV ↓

逐步處理 all-standard-assumption 個案,須得到甚麼結果?原因是甚麼?

查看參考答案

{"standardError":[1,4],"exceptionError":[3,4],"fixtureError":[1,2],"assumedDeploymentError":[1,4]}。比重恰好全 standard,只加權其 1/4;exception 依據仍列出。

執行完整本機驗算

另存為 .mjs,以 Node.js 執行;只驗提供的個案
import assert from 'node:assert/strict';

function evaluate(x){
 const gcd=(a,b)=>b?gcd(b,a%b):a,frac=(n,d)=>{const g=gcd(n,d);return [n/g,d/g];};const a=x.standard,b=x.exception;
 if([a,b].some(c=>!Number.isInteger(c.errors)||!Number.isInteger(c.total)||c.total<1||c.total>10000||c.errors<0||c.errors>c.total)||(x.standardShare!==null&&(!Number.isInteger(x.standardShare)||x.standardShare<0||x.standardShare>10000)))return {error:'counts-or-prevalence'};
 const deployment=x.standardShare===null?null:frac(x.standardShare*a.errors*b.total+(10000-x.standardShare)*b.errors*a.total,10000*a.total*b.total);
 return {standardError:frac(a.errors,a.total),exceptionError:frac(b.errors,b.total),fixtureError:frac(a.errors+b.errors,a.total+b.total),assumedDeploymentError:deployment};
}

const cases = [
  {
    "id": "unknown-prevalence",
    "input": {
      "standard": {
        "errors": 1,
        "total": 4
      },
      "exception": {
        "errors": 3,
        "total": 4
      },
      "standardShare": null
    },
    "expected": {
      "standardError": [
        1,
        4
      ],
      "exceptionError": [
        3,
        4
      ],
      "fixtureError": [
        1,
        2
      ],
      "assumedDeploymentError": null
    }
  },
  {
    "id": "supplied-ninety-ten",
    "input": {
      "standard": {
        "errors": 1,
        "total": 4
      },
      "exception": {
        "errors": 3,
        "total": 4
      },
      "standardShare": 9000
    },
    "expected": {
      "standardError": [
        1,
        4
      ],
      "exceptionError": [
        3,
        4
      ],
      "fixtureError": [
        1,
        2
      ],
      "assumedDeploymentError": [
        3,
        10
      ]
    }
  },
  {
    "id": "share-channel-omitted",
    "input": {
      "standard": {
        "errors": 1,
        "total": 4
      },
      "exception": {
        "errors": 3,
        "total": 4
      }
    },
    "expected": {
      "error": "counts-or-prevalence"
    }
  },
  {
    "id": "all-standard-assumption",
    "input": {
      "standard": {
        "errors": 1,
        "total": 4
      },
      "exception": {
        "errors": 3,
        "total": 4
      },
      "standardShare": 10000
    },
    "expected": {
      "standardError": [
        1,
        4
      ],
      "exceptionError": [
        3,
        4
      ],
      "fixtureError": [
        1,
        2
      ],
      "assumedDeploymentError": [
        1,
        4
      ]
    }
  }
];
for (const c of cases) assert.deepEqual(evaluate(c.input), c.expected, c.id);
console.log(JSON.stringify({checked:cases.length,caseIds:cases.map(c=>c.id)}));
下載可執行例子 ↓

加權數字連同比重假設來源保存。正式工作類別比例改會改此條件推算;個案未保證各類錯誤率可移用真實工作。

相關資源