Python NumPy에서 polynomial.hermite_e.hermemul() 메서드를 사용하면 두 개의 Hermite_e(확률론적 에르미트) 급수를 서로 곱할 수 있습니다. 이 메서드는 두 급수의 곱(c1 * c2)에 해당하는 결과를 새로운 Hermite_e 급수 형태의 배열로 반환합니다.
인자로 전달되는 계수 시퀀스는 가장 낮은 차수 항부터 가장 높은 차수 항까지 순서대로 정렬됩니다. 예를 들어 [1, 2, 3]은 P_0 + 2*P_1 + 3*P_2라는 급수를 나타냅니다. 따라서 매개변수는 저차수부터 고차수 순으로 정렬된 Hermite_e 급수 계수의 1차원 배열입니다.
Hermite_e 급수 곱하기 단계
1단계: 필요한 라이브러리 임포트
import numpy as np from numpy.polynomial import hermite_e as H
2단계: Hermite_e 급수 계수로 1차원 배열 생성
c1 = np.array([1,2,3]) c2 = np.array([3,2,1])
3단계: 계수 배열 출력
print("Array1...\n",c1)
print("\nArray2...\n",c2)4단계: 배열의 데이터 타입 확인
print("\nArray1 datatype...\n",c1.dtype)
print("\nArray2 datatype...\n",c2.dtype)5단계: 배열의 차원(ndim) 확인
print("\nDimensions of Array1...\n",c1.ndim)
print("\nDimensions of Array2...\n",c2.ndim)6단계: 배열의 형상(shape) 확인
print("\nShape of Array1...\n",c1.shape)
print("\nShape of Array2...\n",c2.shape)7단계: hermemul() 메서드로 두 급수 곱하기
print("\nResult (multiply)....\n",H.hermemul(c1, c2))전체 예제 코드
import numpy as np
from numpy.polynomial import hermite_e as H
# Hermite_e 급수 계수로 1차원 배열 생성
c1 = np.array([1,2,3])
c2 = np.array([3,2,1])
# 계수 배열 출력
print("Array1...\n",c1)
print("\nArray2...\n",c2)
# 데이터 타입 출력
print("\nArray1 datatype...\n",c1.dtype)
print("\nArray2 datatype...\n",c2.dtype)
# 두 배열의 차원 확인
print("\nDimensions of Array1...\n",c1.ndim)
print("\nDimensions of Array2...\n",c2.ndim)
# 두 배열의 형상(shape) 확인
print("\nShape of Array1...\n",c1.shape)
print("\nShape of Array2...\n",c2.shape)
# hermemul() 메서드로 두 Hermite_e 급수 곱하기
print("\nResult (multiply)....\n",H.hermemul(c1, c2))실행 결과
Array1...
[1 2 3]
Array2...
[3 2 1]
Array1 datatype...
int64
Array2 datatype...
int64
Dimensions of Array1...
1
Dimensions of Array2...
1
Shape of Array1...
(3,)
Shape of Array2...
(3,)
Result (multiply)....
[13. 24. 26. 8. 3.]