Created
August 15, 2018 13:26
-
-
Save regonn/dc5abb8c1b731afa6a303a11a10d3efb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### 順列や組合せを式 nPr nCr を用いて計算できる\n", | |
"- No: 3\n", | |
"- Sub No: 3\n", | |
"- 難易度: ★\n", | |
"- カテゴリ名: 統計数理基礎\n", | |
"- 必須スキル: ◯\n", | |
"\n", | |
"\n", | |
"\n", | |
"### 順列・組合わせ\n", | |
"- 順列\n", | |
" - 異なるn個からr個を取り1列に並べる場合の数\n", | |
" - $$_nP_r$$ (Permutations)\n", | |
"- 組合わせ\n", | |
" - 異なるn個からr個を取る選び方の数\n", | |
" - $$_nC_r$$ (Combinations)\n", | |
"\n", | |
"\n", | |
"\n", | |
"### Juliaでの順列・組合わせ例\n", | |
"```julia\n", | |
"using Combinatorics\n", | |
"# 扱う配列 ['A','B','C','D']\n", | |
"```\n", | |
"\n", | |
"\n", | |
"## 順列\n", | |
"```julia\n", | |
"collect(permutations(['A','B','C','D'], 2))\n", | |
"# 異なる4個の中から異なる2個を取り出して1列に並べる\n", | |
"12-element\n", | |
"['A', 'B'] ['A', 'C'] ['A', 'D']\n", | |
"['B', 'A'] ['B', 'C'] ['B', 'D']\n", | |
"['C', 'A'] ['C', 'B'] ['C', 'D']\n", | |
"['D', 'A'] ['D', 'B'] ['D', 'C']\n", | |
"```\n", | |
"\n", | |
"\n", | |
"$$_nP_r=n×(n-1)×(n-2)...(n-r+1)$$\n", | |
"\n", | |
"$$_nP_r=\\frac{n!}{(n-r)!}$$\n", | |
"\n", | |
"$$_4P_2=4×3=12$$\n", | |
"\n", | |
"\n", | |
"## 組合わせ\n", | |
"```julia\n", | |
"collect(combinations(array, 2))\n", | |
"# 異なる4個の中から異なる2個を取り出す選び方\n", | |
"6-element\n", | |
"['A', 'B'] ['A', 'C']\n", | |
"['A', 'D'] ['B', 'C']\n", | |
"['B', 'D'] ['C', 'D']\n", | |
"```\n", | |
"\n", | |
"\n", | |
"$$_nC_r=\\frac{_nP_r}{r!}=\\frac{n!}{r!(n-r)!}$$\n", | |
"\n", | |
"$$_4C_2=\\frac{_4P_2}{2!}=\\frac{4×3}{2×1}=6 $$" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment