学習環境
- Surface 3 (4G LTE)、Surface 3 タイプ カバー、Surface ペン(端末)
- Windows 10 Pro (OS)
- 数式入力ソフト(TeX, MathML): MathType
- MathML対応ブラウザ: Firefox、Safari
- MathML非対応ブラウザ(Internet Explorer, Microsoft Edge, Google Chrome...)用JavaScript Library: MathJax
- 参考書籍
Head First Statistics (Dawn Griffiths (著)、黒川 利明 (翻訳)、木下 哲也 (翻訳)、黒川 洋 (翻訳)、黒川 めぐみ (翻訳)、オライリージャパン)の7章(幾何分布、二項分布、ポアソン分布 - いろいろな離散確率分布)、自分で考えてみよう(p. 281)を取り組んでみる。
自分で考えてみよう(p. 281)
コード(Emacs)
HTML5
<div id="output0"></div> <button id="run">run</button> <button id="clear0">clear</button> <script src="sample3.js"></script>
JavaScript
let div0 = document.querySelector('#output0'), btn0 = document.querySelector('#run'), btn1 = document.querySelector('#clear0'), p = (x) => div0.innerHTML += x; range = (start, end, step=1) => { let res = []; for (let i = start; i < end; i += step) { res.push(i); } return res; }; let P = (r) => 0.8 ** (r - 1) * 0.2; let output = () => { let t = 0, s = ''; s = '<table border="1">' + '<tr><td>x</td>' + '<td>P(X = x)</td>' + '<td>x^2P(X = x)</td>' + '<td>x^2P(X <= x)</td></tr>'; range(1, 11).forEach((x) => { t += x ** 2 * P(x); s += `<tr><td>${x}</td><td>0.8^${x - 1} × 0.2 = ${P(x)}</td>` + `<td>${x**2 * P(x)}</td>` + `<td>${t}</td></tr>`; }); s += '</table>'; p(s); }; btn0.onclick = output; btn1.onclick = () => div0.innerHTML = ''; output();
x | P(X = x) | x^2P(X = x) | x^2P(X <= x) |
1 | 0.8^0 × 0.2 = 0.2 | 0.2 | 0.2 |
2 | 0.8^1 × 0.2 = 0.16000000000000003 | 0.6400000000000001 | 0.8400000000000001 |
3 | 0.8^2 × 0.2 = 0.12800000000000003 | 1.1520000000000004 | 1.9920000000000004 |
4 | 0.8^3 × 0.2 = 0.10240000000000003 | 1.6384000000000005 | 3.6304000000000007 |
5 | 0.8^4 × 0.2 = 0.08192000000000002 | 2.0480000000000005 | 5.678400000000002 |
6 | 0.8^5 × 0.2 = 0.06553600000000002 | 2.359296000000001 | 8.037696000000002 |
7 | 0.8^6 × 0.2 = 0.052428800000000025 | 2.569011200000001 | 10.606707200000002 |
8 | 0.8^7 × 0.2 = 0.041943040000000015 | 2.684354560000001 | 13.291061760000003 |
9 | 0.8^8 × 0.2 = 0.033554432000000016 | 2.7179089920000012 | 16.008970752000003 |
10 | 0.8^9 × 0.2 = 0.026843545600000015 | 2.6843545600000014 | 18.693325312000006 |
0 コメント:
コメントを投稿