Computer >> 컴퓨터 >  >> 프로그래밍 >> Python

Python에서 hermeint()로 축 1(axis=1)을 따라 Hermite_e 급수 적분하기

에르미트E(Hermite_e) 급수를 적분하려면 Python에서 hermite_e.hermeint() 메서드를 사용합니다. 이 메서드의 주요 매개변수는 다음과 같습니다.

첫 번째 매개변수 c: Hermite_e 급수의 계수 배열입니다. c가 다차원 배열인 경우 각 축은 서로 다른 변수에 해당하며, 각 축의 차수는 해당 인덱스로 결정됩니다.

두 번째 매개변수 m: 적분 차수를 나타내며 반드시 양수여야 합니다(기본값: 1).

세 번째 매개변수 k: 적분 상수입니다. 하한(lbnd)에서 첫 번째 적분의 값은 목록의 첫 번째 값이 되고, 두 번째 적분의 값은 두 번째 값이 되는 방식으로 지정됩니다. k == [](기본값)이면 모든 적분 상수가 0으로 설정됩니다. m == 1인 경우에는 목록 대신 단일 스칼라 값을 전달할 수도 있습니다.

네 번째 매개변수 lbnd: 적분의 하한(lower bound)입니다.

다섯 번째 매개변수 scl: 스칼라 값으로, 각 적분이 수행된 후 적분 상수가 더해지기 전에 결과에 곱해집니다(기본값: 1).

여섯 번째 매개변수 axis: 적분이 수행될 축을 지정합니다.

단계별 진행 과정

먼저 필요한 라이브러리를 임포트합니다.

import numpy as np
from numpy.polynomial import hermite_e as H

계수로 구성된 다차원 배열을 생성합니다.

c = np.arange(4).reshape(2,2)

배열을 출력합니다.

print("Our Array...\n",c)

배열의 차원을 확인합니다.

print("\nDimensions of our Array...\n",c.ndim)

배열의 데이터 타입을 확인합니다.

print("\nDatatype of our Array object...\n",c.dtype)

배열의 형태(shape)를 확인합니다.

print("\nShape of our Array object...\n",c.shape)

Hermite_e 급수를 적분하기 위해 Python에서 hermite_e.hermeint() 메서드를 사용합니다. 여기서는 axis = 1로 지정하여 축 1을 따라 적분을 수행합니다.

print("\nResult...\n",H.hermeint(c, axis = 1))

전체 예제 코드

import numpy as np
from numpy.polynomial import hermite_e as H

# 계수로 구성된 다차원 배열 생성
c = np.arange(4).reshape(2,2)

# 배열 출력
print("Our Array...\n",c)

# 차원 확인
print("\nDimensions of our Array...\n",c.ndim)

# 데이터 타입 확인
print("\nDatatype of our Array object...\n",c.dtype)

# 형태(shape) 확인
print("\nShape of our Array object...\n",c.shape)

# hermeint() 메서드로 축 1을 따라 Hermite_e 급수 적분
print("\nResult...\n",H.hermeint(c, axis = 1))

실행 결과

Our Array...
   [[0 1]
   [2 3]]

Dimensions of our Array...
2

Datatype of our Array object...
int64

Shape of our Array object...
(2, 2)

Result...
   [[0.5 0. 0.5]
   [1.5 2. 1.5]]