{
  "schemaVersion": 1,
  "python": "3.12.14",
  "scope": "J.VIP public illustrative code; reproducibility is not actual game measurement or blanket correctness certification",
  "rows": [
    {
      "slug": "cascade-history-vs-next-spin-probability",
      "block": 1,
      "codeSha256": "2483B9F1C3D6FFF2E77357BA03D4CFAD3EACAEF3F429B250A903CCE32CCACDC0",
      "assertions": 0,
      "stdout": "0 1 4\n1 3 4",
      "stderr": "",
      "exitCode": 0,
      "expectedOutputMatched": true,
      "code": "from itertools import product\npaths = list(product((0, 1), repeat=2))\nfor start in (0, 1):\n    count = sum(start + sum(path) >= 2 for path in paths)\n    print(start, count, len(paths))  # 0 1 4；1 3 4\n",
      "articleUrl": "https://jvipgt66.com/articles/cascade-history-vs-next-spin-probability/"
    },
    {
      "slug": "game-multiplier-addition-vs-multiplication",
      "block": 1,
      "codeSha256": "C145EF7B2669061EDD8C51FBC0EEB824C134CD521366E173E2F12D635A155AEA",
      "assertions": 0,
      "stdout": "33\n102\n[3, 5]",
      "stderr": "",
      "exitCode": 0,
      "expectedOutputMatched": true,
      "code": "wins = [3, 3, 3, 3]\nstages = [1, 2, 3, 5]\nprint(sum(w*m for w, m in zip(wins, stages)))  # 33\nprint(6 * sum([2, 5, 10]))                    # 102\nprint([v+1 for v in [2, 4]])                 # [3, 5]\n",
      "articleUrl": "https://jvipgt66.com/articles/game-multiplier-addition-vs-multiplication/"
    },
    {
      "slug": "hit-rate-vs-net-win-rate-counterexamples",
      "block": 1,
      "codeSha256": "54676D0560DE94A557D7C2BF93BC4F688571E6DB5FD43C4E867B9932A78F1472",
      "assertions": 2,
      "stdout": "A [Fraction(4, 5), Fraction(1, 5), Fraction(1, 10)] 24/25 6161/2500\nB [Fraction(1, 5), Fraction(1, 5), Fraction(1, 5)] 24/25 2304/625",
      "stderr": "",
      "exitCode": 0,
      "expectedOutputMatched": true,
      "code": "from fractions import Fraction as F\n\nA = [F(0)]*20 + [F(1, 2)]*60 + [F(1)]*10 + [F(28, 5)]*10\nB = [F(0)]*80 + [F(24, 5)]*20\nfor name, tickets in [(\"A\", A), (\"B\", B)]:\n    assert len(tickets) == 100\n    mean = sum(tickets, F(0)) / 100\n    variance = sum(((x-mean)**2 for x in tickets), F(0)) / 100\n    rates = [F(sum(x > 0 for x in tickets), 100),\n             F(sum(x >= 1 for x in tickets), 100),\n             F(sum(x > 1 for x in tickets), 100)]\n    assert mean == F(24, 25)\n    print(name, rates, mean, variance)\n",
      "articleUrl": "https://jvipgt66.com/articles/hit-rate-vs-net-win-rate-counterexamples/"
    },
    {
      "slug": "mahjong-ways-1-vs-2-rule-comparison",
      "block": 1,
      "codeSha256": "C2444BCA0BD3E040A629F4F57CC62E5A354B3AE9E485FB9CD716EAC7DF1035BC",
      "assertions": 0,
      "stdout": "1024 2000\n1525/16",
      "stderr": "",
      "exitCode": 0,
      "expectedOutputMatched": true,
      "code": "from fractions import Fraction\na, b = 4**5, 4*5*5*5*4\nprint(a, b)                         # 1024 2000\nprint((Fraction(b, a)-1)*100)       # 1525/16，即95.3125\n",
      "articleUrl": "https://jvipgt66.com/articles/mahjong-ways-1-vs-2-rule-comparison/"
    },
    {
      "slug": "payout-multiplier-units-and-bet-basis",
      "block": 1,
      "codeSha256": "32CBAF72DB98154C79C4E390863CFAF329D3838FB13DF9A992FEB562DF73C90D",
      "assertions": 0,
      "stdout": "1/15 40 20\n30",
      "stderr": "",
      "exitCode": 0,
      "expectedOutputMatched": true,
      "code": "from fractions import Fraction as F\nB = F(2)\nu = B/30\nv, m = 60, 10\nW = v*u*m\nprint(u, W, W/B)    # 1/15 40 20\nprint(v*B*m/W)      # 30：误用总投注产生的比例误差\n",
      "articleUrl": "https://jvipgt66.com/articles/payout-multiplier-units-and-bet-basis/"
    },
    {
      "slug": "respin-reset-counter-stopping-time",
      "block": 1,
      "codeSha256": "B05BBA982AE5FA3C73EE4DF825D89910B13C3247D7B2D702A69B6223BCAAB1A7",
      "assertions": 1,
      "stdout": "3 1/8 1/8\n4 1/16 3/16\n5 1/16 1/4\n6 1/16 5/16\n10 11/256 65/128\n14",
      "stderr": "",
      "exitCode": 0,
      "expectedOutputMatched": true,
      "code": "from fractions import Fraction as F\np = F(1, 2)\nq = 1-p\na = [F(1), F(0), F(0)]\ncdf = F(0)\nfor n in range(1, 11):\n    stop = q*a[2]\n    a = [p*sum(a), q*a[0], q*a[1]]\n    cdf += stop\n    assert sum(a)+cdf == 1\n    if n in [3, 4, 5, 6, 10]:\n        print(n, stop, cdf)\nprint((1+q+q*q)/(q*q*q))  # 14\n",
      "articleUrl": "https://jvipgt66.com/articles/respin-reset-counter-stopping-time/"
    },
    {
      "slug": "rtp-96-percent-100-spins-distribution",
      "block": 1,
      "codeSha256": "C2EF44EFE4E2FB01195649E47766821B6F4E4ABD1AE6771804325D30C28453A9",
      "assertions": 1,
      "stdout": "A exactly96 9.930021%\nA atLeast96 55.946158%\nA positiveNet 19.233758%\nB exactly96 36.972964%\nB atLeast96 63.396766%\nB positiveNet 26.423802%",
      "stderr": "",
      "exitCode": 0,
      "expectedOutputMatched": true,
      "code": "from fractions import Fraction as F\nfrom math import comb\n\nfor name, p, award in [(\"A\", F(4, 5), F(6, 5)),\n                       (\"B\", F(1, 100), F(96))]:\n    pmf = [F(comb(100, k)) * p**k * (1-p)**(100-k)\n           for k in range(101)]\n    assert sum(pmf, F(0)) == 1\n    for label, event in [\n        (\"exactly96\", lambda k: award*k == 96),\n        (\"atLeast96\", lambda k: award*k >= 96),\n        (\"positiveNet\", lambda k: award*k > 100),\n    ]:\n        q = sum((v for k, v in enumerate(pmf) if event(k)), F(0))\n        print(name, label, f\"{float(q*100):.6f}%\")\n",
      "articleUrl": "https://jvipgt66.com/articles/rtp-96-percent-100-spins-distribution/"
    },
    {
      "slug": "rtp-cannot-identify-free-spin-trigger-rate",
      "block": 1,
      "codeSha256": "74D4558CD4CE1F0829A8979785CD00A9C358D7A1B0C82F56BD48851F8119E8C0",
      "assertions": 1,
      "stdout": "A p = 1/100 R = 24/25\nB p = 1/50 R = 24/25\nC p = 1/50 R = 24/25",
      "stderr": "",
      "exitCode": 0,
      "expectedOutputMatched": true,
      "code": "from fractions import Fraction as F\n\nmodels = [\n    (\"A\", F(18, 25), F(1, 100), F(24)),\n    (\"B\", F(21, 25), F(1, 50), F(6)),\n    (\"C\", F(18, 25), F(1, 50), F(12)),\n]\nfor name, b, p, m in models:\n    by_decomposition = b + p*m\n    by_outcomes = (1-p)*b + p*(b+m)\n    assert by_decomposition == by_outcomes == F(24, 25)\n    print(name, \"p =\", p, \"R =\", by_decomposition)\n",
      "articleUrl": "https://jvipgt66.com/articles/rtp-cannot-identify-free-spin-trigger-rate/"
    },
    {
      "slug": "ways-count-vs-winning-probability",
      "block": 1,
      "codeSha256": "CBF73F85D7D29CBB4D6F4C116C6D01A76F78C03093DC38C54AFE05197BB1CBEC",
      "assertions": 2,
      "stdout": "",
      "stderr": "",
      "exitCode": 0,
      "expectedOutputMatched": true,
      "code": "from fractions import Fraction as F\nfrom itertools import product\n\nh, p = (2, 2, 2), F(1, 4)\nprobability, expected_paths = F(0), F(0)\nfor cells in product((0, 1), repeat=sum(h)):\n    count = sum(cells)\n    mass = p**count * (1-p)**(sum(h)-count)\n    a, b, c = sum(cells[:2]), sum(cells[2:4]), sum(cells[4:])\n    probability += mass * int(a > 0 and b > 0 and c > 0)\n    expected_paths += mass * a*b*c\nassert probability == F(343, 4096)\nassert expected_paths == F(1, 8)\n",
      "articleUrl": "https://jvipgt66.com/articles/ways-count-vs-winning-probability/"
    }
  ]
}
