= R.shape[0], R.shape[1] U, V = np.zeros((T, N, D)), np.zeros((T, M, D)) # Gibbs Sampling Ͱ Tݸ ͷαϯϓϧΛܭࢉ for t in range(T - 1): # U, V ͷύϥϝʔλͷαϯϓϦϯά lamU, muU = sample_param_U(U[t, :, :]) lamV, muV = sample_param_V(V[t, :, :]) # U ͷαϯϓϦϯά for i in range(N): U[t+1, i, :] = sample_U(R[i, :], U[t, :, :], V[t, :, :], lamU, muU) # V ͷαϯϓϦϯά for j in range(M): V[t+1, j, :] = sample_V(R[i, :], U[t+1, :, :], V[t, :, :], lamV, muV) return U, V