<jupyter_start><jupyter_text>The heat map of the actual coupling matrix `w0` is plotted:<jupyter_code>plt.figure(figsize=(3,3))
plt.title('actual coupling matrix')
plt.imshow(w0,cmap='rainbow',origin='lower')
plt.xlabel('j')
plt.ylabel('i')
plt.clim(-0.5,0.5)
plt.colorbar(fraction=0.045, pad=0.05,ticks=[-0.5,0,0.5])
plt.show()<jupyter_output><empty_output><jupyter_text>Using the function `simulate.generate_data`, we then generate a time series of variable states according to the kinetic Ising model with a data length $L = 2000$.<jupyter_code>l = 2000
s = simulate.generate_data(w0,l)
n = s.shape[1]

h0 = np.zeros(n)
w = np.zeros((n,n))
for i0 in range(n):
    x = s[:-1,:]
    y = s[1:,i0]    
    h0[i0],w[i0,:] = inference.fit(x,y)
plt.figure(figsize=(11,3.2))

plt.subplot2grid((1,3),(0,0))
plt.title('actual coupling matrix')
plt.imshow(w0,cmap='rainbow',origin='lower')
plt.xlabel('j')
plt.ylabel('i')
plt.clim(-0.5,0.5)
plt.colorbar(fraction=0.045, pad=0.05,ticks=[-0.5,0,0.5])

plt.subplot2grid((1,3),(0,1))
plt.title('predicted coupling matrix')
plt.imshow(w,cmap='rainbow',origin='lower')
plt.xlabel('j')
plt.ylabel('i')
plt.clim(-0.5,0.5)
plt.colorbar(fraction=0.045, pad=0.05,ticks=[-0.5,0,0.5])

plt.subplot2grid((1,3),(0,2))
plt.plot([-1,1],[-1,1],'r--')
plt.scatter(w0,w)
plt.xlabel('actual couplings')
plt.ylabel('inferred couplings')

plt.tight_layout(h_pad=1, w_pad=1.5)
plt.show()<jupyter_output><empty_output><jupyter_text>The inference accuracy is measured by mean square error between actual couplings and inferred couplings: MSE = $\frac{1}{N^{2}} \sum_{i,j=1}^N (W_{ij} - W_{ij}^{\text{actual}})$<jupyter_code>MSE = ((w0-w)**2).mean()
print(MSE)<jupyter_output>0.002225819241798028
{'fraction_non_alphanumeric': 0.21449444769140855, 'fraction_numerical': 0.07130333138515488, 'mean_word_length': 6.642857142857143, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '500546', 'license': 'MIT', 'n_tokens_mistral': 836, 'n_tokens_neox': 747, 'n_words': 116, 'path': '.ipynb_checkpoints/er_def-checkpoint.ipynb', 'repo_name': 'danhtaihoang/expectation-reflection', 'size': '1711'}