<jupyter_start><jupyter_text>数値実験の設定<jupyter_code>N = 4000  # 列数
alpha = 0.5  # 圧縮率
M = int(alpha*N)  # 行数
rho = 0.2  # 非零成分の割合
SNR = 60  # 信号対雑音比
kappa = 5  # 条件数
P = 10  # ノード数
T = 30  # 反復回数
sim = 100  # 実験数
x = [bernouli_gaussian(N, rho) for _ in range(sim)]<jupyter_output><empty_output><jupyter_text>i.i.d.ガウス行列での信号再構成<jupyter_code>MSE_iidG = np.empty((sim, 4, T+1))
CommCost_iidG = np.empty((sim, 2, T))
for i in tqdm(range(sim)):
    iidG = iidGaussian(M, N, m=0, v=1/M)
    algo = [AMP(iidG.A, x[i], SNR), 
            D_AMP(iidG.A, x[i], SNR, P), 
            OAMP(iidG.A, x[i], SNR), 
           D_OAMP(iidG.A, x[i], SNR, P)]

    algo[0].estimate(T) # AMP
    algo[1].estimate(T) # D-AMP
    algo[2].estimate(T, ord='LMMSE') # OAMP
    algo[3].estimate(T, ord='LMMSE') # D-OAMP
        
    for j in range(4):
        MSE_iidG[i, j] = algo[j].mse
        if j % 2 == 1:
            k = int(j/2)
            CommCost_iidG[i, k] = algo[j].communication_cost
MSE_iidG_mean = np.empty((4, T+1))
CommCost_iidG_mean = np.empty((2, T))

for i in range(4):
    MSE_iidG_mean[i] = np.mean(MSE_iidG[:, i], axis=0)
    if i % 2 == 1:
        j = int(i/2)
        CommCost_iidG_mean[j] = np.mean(CommCost_iidG[:, j], axis=0)
plt.figure(figsize=(14, 5.5))

plt.subplot(121)
plt.title('Communication Cost(i.i.d. Gaussian)')
plt_CC(CommCost_iidG_mean[0], 'DAMP', T, N, P, 'tab:blue')
plt_CC(CommCost_iidG_mean[1], 'DOAMP', T, N, P, 'tab:red')
plt.grid()

plt.subplot(122)
plt.title('MSE(i.i.d. Gaussian)')
plt_MSE(MSE_iidG_mean[0], 'AMP', T, 'tab:cyan')
plt_MSE(MSE_iidG_mean[1], 'DAMP', T, 'tab:blue')
plt_MSE(MSE_iidG_mean[2], 'OAMP', T, 'tab:orange')
plt_MSE(MSE_iidG_mean[3], 'DOAMP', T, 'tab:red')
plt.grid()
plt_CC(CommCost_iidG_mean[0], 'DAMP', T, N, P, 'tab:blue')
plt_CC(CommCost_iidG_mean[1], 'DOAMP', T, N, P, 'tab:red')
plt.grid()
plt_MSE(MSE_iidG_mean[0], 'AMP', T, 'tab:cyan')
plt_MSE(MSE_iidG_mean[1], 'DAMP', T, 'tab:blue')
plt_MSE(MSE_iidG_mean[2], 'OAMP', T, 'tab:orange')
plt_MSE(MSE_iidG_mean[3], 'DOAMP', T, 'tab:red')
plt.grid()<jupyter_output><empty_output><jupyter_text>ユニタリ不変行列での信号再構成<jupyter_code>MSE_UniInv = np.empty((sim, 4, T+1))
CommCost_UniInv = np.empty((sim, 2, T))
for i in tqdm(range(sim)):
    UniInv = UniInvar(M, N, kappa)
    algo = [AMP(UniInv.A, x[i], SNR), 
            D_AMP(UniInv.A, x[i], SNR, P), 
            OAMP(UniInv.A, x[i], SNR), 
           D_OAMP(UniInv.A, x[i], SNR, P)]
    
    algo[0].estimate(T) # AMP
    algo[1].estimate(T) # D-AMP
    algo[2].estimate(T, ord='LMMSE') # OAMP
    algo[3].estimate(T, ord='LMMSE') # D-OAMP
        
    for j in range(4):
        MSE_UniInv[i, j] = algo[j].mse
        if j % 2 == 1:
            k = int(j/2)
            CommCost_UniInv[i, k] = algo[j].communication_cost
MSE_UniInv_mean = np.empty((4, T+1))
CommCost_UniInv_mean = np.empty((2, T))

for i in range(4):
    MSE_UniInv_mean[i] = np.mean(MSE_UniInv[:, i], axis=0)
    if i % 2 == 1:
        j = int(i/2)
        CommCost_UniInv_mean[j] = np.mean(CommCost_UniInv[:, j], axis=0)
plt.figure(figsize=(14, 5.5))

plt.subplot(121)
plt.title('Communication Cost(Unitary-Invariant Matrix)')
#plt_CC(CommCost_UniInv_mean[0], 'DAMP', T, N, P, 'tab:blue')
plt_CC(CommCost_UniInv_mean[1], 'GCOAMP', T, N, P, 'tab:red')
plt.grid()

plt.subplot(122)
plt.title('MSE(Unitary-Invariant Matrix)')
#plt_MSE(MSE_UniInv_mean[0], 'AMP', T, 'tab:cyan')
#plt_MSE(MSE_UniInv_mean[1], 'DAMP', T, 'tab:blue')
plt_MSE(MSE_UniInv_mean[2], 'OAMP', T, 'tab:orange')
plt_MSE(MSE_UniInv_mean[3], 'GCOAMP', T, 'tab:red')
plt.grid()
#plt_CC(CommCost_UniInv_mean[0], 'DAMP', T, N, P, 'tab:blue')
plt_CC(CommCost_UniInv_mean[1], 'GCOAMP', T, N, P, 'tab:red')
plt.grid()
#plt_MSE(MSE_UniInv_mean[0], 'AMP', T, 'tab:cyan')
#plt_MSE(MSE_UniInv_mean[1], 'DAMP', T, 'tab:blue')
plt_MSE(MSE_UniInv_mean[2], 'OAMP', T, 'tab:orange')
plt_MSE(MSE_UniInv_mean[3], 'GCOAMP', T, 'tab:red')
plt.grid()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2047244094488189, 'fraction_numerical': 0.026416052832105665, 'mean_word_length': 4.147712418300654, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '665828', 'license': 'MIT', 'n_tokens_mistral': 2090, 'n_tokens_neox': 2004, 'n_words': 332, 'path': 'examples/sample2.ipynb', 'repo_name': 'Ken529n/Lassolver', 'size': '3937'}