[Python] matplotlib 히스토그램 표시
hist( ) 함수 [In] import numpy as np import matplotlib.pyplot as plt data = np.array([0,1,2,3,3,4,5,6,7,8,8,1,2,3,4,8,1,0,4,9]) plt.hist(data, bins = 10) # bins는 기둥 수를 의미 plt.show() [Out]
[Python] Numpy 배열 생성
array() 함수 array() 함수로 다양한 형태의 배열 (벡터, 행렬, 텐서)를 생성할 수 있다. [In] import numpy as np a = np.array([0,1,2,3,4,5]) # 1차원 배열(=벡터) 생성 b = np.array([[0,1,2], [3,4,5]]) # 2차원 배열(=행렬) 생성 c = np.array([[[0,1,2], [3,4,5]], [[5,6,7], [2,1,0]]]) # 3차원 배열(=텐서) 생성 print(a) print(b) print(c) [Out] [0 1 2 3 4 5] [[0 1 2] [3 4 5]] [[[0 1 2] [3 4 5]] [[5 6 7] [2 1 0]]] zeros() 함수, ones() 함수 zeros() 함수 : 요소를 전부 0로 하..