Python code - kronecker product
Kronecker product - numpy
numpy.kron
(a, b)[source]
a, b์๋ kronecker product๋ฅผ ๊ตฌํ๊ณ ์ ํ๋ ํ๋ ฌ์ด ๊ฐ๊ฐ ํ๋ผ๋ฏธํฐ๋ก ๋ค์ด๊ฐ๊ณ , kronecker product์ ๊ฒฐ๊ณผ๊ฐ์ ๋ฆฌํดํฉ๋๋ค.
Kronecker product MLE ๊ตฌํํ๊ธฐ
import numpy as np
G = [[1,0,1,1],[0,1,0,1],[1,0,1,1],[1,1,1,1]]
KM = [[0.5,0.2],[0.1,0.3]]
KM = np.kron(KM, KM)
P = 1
for i in range(KM.shape[0]):
for j in range(KM.shape[1]):
# G์ ์ํ ๋.
if G[i][j]==1:
P = P*KM[i][j]
# G์ ์ํ์ง ์์ ๋.
else:
P = P*(1-KM[i][j])
# P๋ kronecker ๋ก๋ถํฐ ์์ฑ๋ ๊ทธ๋ํ๊ฐ ์ค์ G์ผ ํ๋ฅ ์ ๋ํ๋.
print(P)
PreviousChapter2. Properties of Networks, Random Graph ModelsNextChapter3. Motifs and Structural Roles in Networks
Last updated
Was this helpful?