60%を3回試行と80%を2回試行ではどちらの期待値が高いか
60%を3回の方が高い
すみません、80%を2回の方が高いです。答えの見方を間違えておりました。
本件の最新記事はこちらです。
60%を3回試行と80%を2回試行ではどちらの期待値が高いか→80%を2回の方が高い
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | // 60%の成功率を3回チャレンジして2回以上成功する確率を教えて下さいヾ(。>д<)ノ main(); function main() {   const p = console.log;   const probabilityOf = n => Math.random() * 100 < n;   const challenge = (percent, limit, targetCnt, isBool = false) => {     let cnt = 0;     for (let i = 0; i < limit; i++) {       if (probabilityOf(percent)) {         if (isBool) {           return true;         }         cnt++;       }     }     if (isBool) {       if (cnt === 0) {         return false;       }     }     return targetCnt <= cnt;   };   const calcProportion = (percent, limit, times) => {     let cnt = 0;     for (let i = 0; i < times; i++) {       if (challenge(percent, limit, 1, true)) {         cnt++;       }     }     const proportion = cnt * 100.0 / times;     return proportion;   };   const dispProportion = (percent, limit, times) => {     const proportion = calcProportion(percent, limit, times);     let msg = percent + "% に" + limit + "回 挑戦して成功する割合 " + proportion + "% (" + times + "回試行)";     p(msg);   };   const calcHitCnt = (percent, limit) => {     let cnt = 0;     for (let i = 0; i < limit; i++) {       if (probabilityOf(percent)) {         cnt++;       }     }     return cnt;   };   const calcExpectedValue = (percent, limit, times) => {     let cnt = 0;     for (let i = 0; i < times; i++) {       cnt += calcHitCnt(percent, limit);     }     expectedValue = cnt / times;     return expectedValue;   };   const dispExpectedValue = (percent, limit, times) => {     const expectedValue = calcExpectedValue(percent, limit, times);     let msg = percent + "% に" + limit + "回 挑戦した時の期待値 " + expectedValue + "% (" + times + "回試行)";     p(msg);   };   const times = 2000000;   let percent = 60.0;   let limit = 3;   dispExpectedValue(percent, limit, times);   percent = 80.0;   limit = 2;   dispExpectedValue(percent, limit, times); } | 
| 1 2 | 60% に3回 挑戦した時の期待値 1.800217% (2000000回試行) 80% に2回 挑戦した時の期待値 1.600028% (2000000回試行) | 



