λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
μ•Œκ³ λ¦¬μ¦˜

[μˆ˜ν•™,μ‘°ν•©λ‘ ] 이항 κ³„μˆ˜ (1)

by SeopπŸ˜€ 2022. 7. 1.
λ°˜μ‘ν˜•

en.wikipedia.org/wiki/Binomial_coefficient

 

Binomial coefficient - Wikipedia

 

en.wikipedia.org

μœ„κΈ€μ˜ λ‚΄μš©μ„ μ°Έκ³ ν•΄ 짧게 정리λ₯Ό ν•΄λ΄€λ‹€.

 

 

μ΄ν•­κ³„μˆ˜λž€?

  • μ£Όμ–΄μ§„ μ§‘ν•©μ—μ„œ μ›ν•˜λŠ” 개수만큼 μˆœμ„œμ—†μ΄ λ½‘λŠ” μ‘°ν•©μ˜ 개수λ₯Ό λ§ν•œλ‹€.
  • 전체 μ§‘ν•©μ—μ„œ μ›μ†Œμ˜ 개수 n에 λŒ€ν•΄ k개의 μ›μ†Œλ₯Ό λ½‘λŠ” μ‘°ν•©μ˜ 수
\(\begin{pmatrix}n \\k\end{pmatrix}=\dfrac{n!}{k!\left( n-k\right) !}=nCr\)

μ½”λ“œλ‘œ λ‚˜νƒ€λ‚΄λ©΄ μ•„λž˜μ™€ κ°™λ‹€. νŒ©ν† λ¦¬μ–Όμ€ ν•¨μˆ˜λ‘œ λ‚˜μ™€μžˆμ§€λ§Œ μ§μ ‘κ΅¬ν˜„

 

def binomial_coefficient(n,k) :
    return factorial(n)//factorial(k)//factorial(n-k)

def factorial(x):
    result = 1
    for i in range(2,x+1) :
        result *= i
    return result

 

이항 κ³„μˆ˜μ˜ 식을 μ•Œκ³  μžˆλ‹€λ©΄ 직관적이고 μ‰½κ²Œ ν’€ 수 μžˆλŠ” μ •λ„μ˜ 레벨이라고 μƒκ°ν•œλ‹€. 

ν•˜μ§€λ§Œ νŒ©ν† λ¦¬μ–Όμ€ n의 값이 컀지면 컀질수둝 overflow λ‚  κ°€λŠ₯성이 크닀. λ‹€λ₯Έλ°©λ²•이 ν•„μš”ν•˜λ‹€.

μ΄ν•­κ³„μˆ˜μ˜ μ„±μ§ˆμ„ μ‚΄νŽ΄λ³΄μž.

 

\(nCr=nCn-r\)

=> \(\begin{pmatrix} n \\ k \end{pmatrix}=\left( \dfrac{n}{n-k}\right)\)

=> \(\begin{pmatrix} n \\ 0 \end{pmatrix}=\begin{pmatrix} n \\ n \end{pmatrix}=1\)
'파슀칼의 μ‚Όκ°ν˜•(법칙) μ°Έκ³ '

\(_{n+1}^{}\textrm{C}_{r+1} = nCr = nC_{r+1}\)

=> \(\begin{pmatrix} n+1 \\ r+1 \end{pmatrix}=\begin{pmatrix} n \\ r \end{pmatrix}+\begin{pmatrix} n \\ r+1 \end{pmatrix}\)

=> \(\begin{pmatrix} n \\ r \end{pmatrix}=\begin{pmatrix} n-1 \\ r-1 \end{pmatrix}+\begin{pmatrix} n-1 \\ r \end{pmatrix}\)

μœ„μ˜ μ„±μ§ˆμ—μ„œ μ•Œκ³ λ¦¬μ¦˜μ˜ 핡심인 '점화식'을 얻을 수 μžˆλ‹€.

 

점화식을 μ΄μš©ν•œ μ½”λ“œλŠ” λ‹€μŒμž₯μ—μ„œ 확인가λŠ₯ν•©λ‹ˆλ‹€.

'μ•Œκ³ λ¦¬μ¦˜' μΉ΄ν…Œκ³ λ¦¬μ˜ λ‹€λ₯Έ κΈ€

2차원 리슀트(ν–‰λ ¬) 90도 νšŒμ „  (0) 2022.05.17

λŒ“κΈ€