np.outer

2024. 10. 22. 20:10정보처리,전산/Python

반응형

np.outer 함수는 두 벡터의 외적(outer product)을 계산하여 2D 배열(행렬)을 생성한다.

 외적의 정의

- 주어진 두 1차원 배열(벡터) \( \mathbf{a} \)와 \( \mathbf{b} \)가 있을 때, \( \text{np.outer}(\mathbf{a}, \mathbf{b}) \)는 다음과 같은 행렬을 생성한다:
  \[
  \text{outer}(a, b) = \begin{bmatrix}
  a_1 \cdot b_1 & a_1 \cdot b_2 & \cdots & a_1 \cdot b_n \\
  a_2 \cdot b_1 & a_2 \cdot b_2 & \cdots & a_2 \cdot b_n \\
  \vdots & \vdots & \ddots & \vdots \\
  a_m \cdot b_1 & a_m \cdot b_2 & \cdots & a_m \cdot b_n
  \end{bmatrix}
  \]

두 벡터를 입력으로 받아서 이들의 곱을 통해 2D 배열을 생성하는 함수이다

 
 

 

 

반응형