学習環境
- 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. 291)を取り組んでみる。
自分で考えてみよう(p. 291)
| x | P(X = x) | 0.75の指数 | 0.25の指数 |
| 1 | 0.75^2 × 0.25 × 3 | 2 | 1 |
| 2 | 0.75^1 × 0.25^2 × 3 | 1 | 2 |
| 3 | 0.25^3 × 3 | 0 | 3 |
コード(Emacs)
HTML5
<pre id="output0"></pre> <button id="run">run</button> <button id="clear0">clear</button> <script src="sample5.js"></script>
JavaScript
let pre0 = document.querySelector('#output0'),
btn0 = document.querySelector('#run'),
btn1 = document.querySelector('#clear0'),
p = (x) => pre0.textContent += x,
range = (start, end, step=1) => {
let res = [];
for (let i = start; i < end; i += step) {
res.push(i);
}
return res;
};
let factorial = (n) => range(1, n + 1).reduce((prev, next) => prev * next, 1),
combinations = (n, m) => factorial(n) / (factorial(n - m) * factorial(m));
let output = () => {
p(
range(1, 4)
.map((x) => 0.75 ** (3 - x) * 0.25 ** x * combinations(3, x))
.join('\n')
);
};
btn0.onclick = output;
btn1.onclick = () => pre0.textContent = '';
output();
0 コメント:
コメントを投稿