1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

麻雀は何試合で実力が収束するのか?

Last updated at Posted at 2024-10-07

検証方法

N試合の平均着順を求める。
これを10000個のパラレルワールドで行い、
各パラレルワールドごとの平均着順の誤差が0.01になるまでの試合数を求める。

統計学の知識は0なのでプログラムでゴリ押しで求めていく。

あといろいろ検証するのが面倒くさいので平均着順は2.5で固定する。

ソースコード

main.js
const パラレルワールドの数 = 10000
const 試合数 = Number(process.argv[2])

const 期待順位分布 = [1, 1, 1, 1]
const 期待平均順位 = 平均順位(期待順位分布)

let 誤差合計 = 0
for (let i = 0; i < パラレルワールドの数; i++) {
    const 実際順位分布 = [0, 0, 0, 0]
    for (let j = 0; j < 試合数; j++) {
        const 順位 = ランダム順位(期待順位分布)
        実際順位分布[順位 - 1] += 1
    }
    誤差合計 += Math.abs(期待平均順位 - 平均順位(実際順位分布))
}

console.log(`試合数:${試合数}, 期待平均順位:${平均順位(期待順位分布)}`)
console.log(`平均順位誤差:${誤差合計 / パラレルワールドの数}`)

function ランダム順位(期待順位分布) {
    const 総数 = 期待順位分布.reduce((a, b) => a + b, 0)
    let r = Math.random()
    if (r < 期待順位分布[0] / 総数) {
        return 1
    }
    if (r < (期待順位分布[0] + 期待順位分布[1]) / 総数) {
        return 2
    }
    if (r < (期待順位分布[0] + 期待順位分布[1] + 期待順位分布[2]) / 総数) {
        return 3
    }
    return 4
}

function 平均順位(順位分布) {
    return (順位分布[0] + 順位分布[1] * 2 + 順位分布[2] * 3 + 順位分布[3] * 4) / (順位分布[0] + 順位分布[1] + 順位分布[2] + 順位分布[3])
}

結果

いろいろ試合数をいじって調べた結果!

試合数:3600, 期待平均順位:2.5
平均順位誤差:0.01474852777777778

約3600試合すれば、実力の平均着順との誤差が0.01になると分かりました。

終わり。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?