본문 바로가기

공부는 언제까지 해야 하나

[Python] numpy module - mathematics / statistics

import numpy as np

 

shpae이 같다면, 사칙연산 모두 지원함

a * b : inner / outer product가 아니라 elementwise calculate임

참고로 python list과 np.array에서의 multiplication/summation은 다름

- Python standard lib list는 list extension , np.array는 elementwize claculation

np..inf(infinity) & np.nan(not a number)

a.sum( )

 - python built in function의 sum( ) 은 only for 1D list임. - std( ), var( ), median( ) 지원 안함. 

 - statistic function 제공은 Python built in function < Numpy < Statistics

a.prod( )

 - product result를 number로 return

a.mean( )

a.var( )

a.std( )

np.median( )

np.sum( ndarray, axis = 0 / 1 )

 - numpy module에 있는 통계 함수

 - axis = 0 : ↓ 방향 summation

 - axis = 1 : → 방향 summation

 - a.sum( axis = 0 / 1)은 np.array의 instance method임

np.corrcoef( ndarray )

 - 각 row들 간의 상관계수

np.con( ndarray )

 - 각 row들 간의 공분산

 - 상관계수 / 공분산은 only at 2D ndarray object에서만 가능