学習環境
- Surface 3 (4G LTE)、Surface 3 タイプ カバー、Surface ペン(端末)
- Windows 10 Pro (OS)
- 数式入力ソフト(TeX, MathML): MathType
- MathML対応ブラウザ: Firefox、Safari
- MathML非対応ブラウザ(Internet Explorer, Google Chrome...)用JavaScript Library: MathJax
数学読本〈4〉数列の極限,順列/順列・組合せ/確率/関数の極限と微分法(松坂 和夫(著)、岩波書店)の第16章(確からしさをみる - 確率)、16.1(確率とその基本性質)、二三の簡単な確率、問1、2、3、4、5.を取り組んでみる。
コード(Emacs)
HTML5
<pre id="output0"></pre> <button id="run0">run</button> <button id="clear0">clear</button> <script src="sample1.js"></script>
JavaScript
let btn0 = document.querySelector('#run0'),
btn1 = document.querySelector('#clear0'),
pre0 = document.querySelector('#output0'),
p = (x) => pre0.textContent += x + '\n';
let range = (start, end, step=1) => {
let iter = (i, result) => {
return i >= end ? result : iter(i + step, result.concat([i]));
}
return iter(start, []);
};
let factorial = (n) => {
return n <= 1 ? 1 : n * factorial(n - 1);
};
let combination = (n, r) => {
return factorial(n) / (factorial(r) * factorial(n - r));
};
let output = () => {
p('2-2.');
let result = [];
range(1, 7).forEach(
(x) => range(1, 7).forEach((y) => {
if (x + y === 7) {
result.push([x, y]);
}
}));
p(result);
p(result.length / 36 === 1 / 6);
p('2-3.');
result = [];
range(1, 7).forEach(
(x) => range(1, 7).forEach((y) => {
if (x + y >= 7) {
result.push([x, y]);
}
}));
p(result);
p(result.length / 36 === 7 / 12);
p('3-1.');
p(combination(4, 1) * combination(6, 1) / combination(10, 2) === 8 / 15);
p('3-2.');
p(combination(6, 2) / combination(10, 2) === 1 / 3);
p('4-1.');
p(2 * factorial(6) / factorial(8) === 1 / 28);
p('4-2.');
p(2 * 7 * factorial(6) / factorial(8) === 1 / 4);
p('4-3.');
p(6 * factorial(3) * factorial(5) / factorial(8) === 3 / 28);
p('5-1.');
p(factorial(2) * factorial(5) / factorial(7) === 1 / 21);
p('5-2.');
p(3 * 2 * factorial(5) / factorial(7) === 1 / 7);
p('5-3.');
p(factorial(3) * factorial(4) / factorial(7) === 1 / 35);
};
btn0.onclick = output;
btn1.onclick = () => {
pre0.textContent = '';
};
output();
0 コメント:
コメントを投稿