3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【スロット】アナザーゴッドハーデスのGODを引く確率【確率】

Last updated at Posted at 2019-08-29

みなさん、GOD引いてますか?
今年の12月でハーデスは撤去ですね、ってことで記事を書きます。
IMG_2903-1-728x546.jpg

ロジック

GODを引く確率をp(=1/8192)とします。
n回回したときに、g回GODを引く確率は

{}_n C_g(1-p)^{n-g}p^g\\
g \leq n

となります。

n回回したときに、少なくとも1回以上GODを引く確率は

1-(1-p)^{n}

となります。

n回回したときに、少なくともg(≧1)回以上GODを引く確率は

1-(1-p)^{n}-\sum_{i=1}^{g-1} {}_n C_i(1-p)^{n-i}p^i

となります。

例1:
2000回回したときに、1回GODを引く確率

\begin{align}
&{}_{2000} C_1(1-1/8192)^{2000-1}(1/8192)^1\\
&\fallingdotseq0.1912748\\
&=19.12748{\%}
\end{align}

例2:
4000回回したときに、3回以上GODを引く確率

\begin{align}
&1-(1-1/8192)^{4000}-\sum_{i=1}^{3-1} {}_{4000} C_i(1-1/8192)^{4000-i}(1/8192)^i
\\
&\fallingdotseq0.0135081\\
&=1.35081{\%}
\end{align}

imagesJQHGPDJN.jpg

プログラム

プログラムはこちらから動かすことができます。
無題.png

$('#calc').click(() => {
  const p = 1 / 8192;
  const n = parseInt($('#trial_number').val());
  const g = parseInt($('#god_number').val());
  if(n < g) {
    $('#probability').text('入力値が不正です');
    return;
  }
  let gp;
  if($('input[name=type]:checked').val() === 'equal') {
    // GODを指定回数引く
    gp = math.combinations(n, g) * Math.pow(p, g) * Math.pow(1 - p, n - g);  
  } else {
    // GODを指定回数以上引く
    if(g === 0) {
      $('#probability').text('入力値が不正です');
      return;
    }
    let mgp = 0.0;
    for(let i = 1; i <= g - 1; i++) {
      mgp += math.combinations(n, i) * Math.pow(p, i) * Math.pow(1 - p, n - i); 
    }
    gp = 1 - Math.pow((1 - p), n) - mgp;
  }
  gp *= 100;
  $('#probability').text(gp.toFixed(5) + '%');
  
});

では、楽しいGODライフを!!!
無題.png

3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?