GitLab Repo

amachine.am_visualization.am_block_entropy_curves

 1import matplotlib.pyplot as plt
 2import numpy as np
 3
 4def draw_block_entropy_curve( m ) :
 5    
 6    h_mu = m.h_mu()
 7    E = m.E()
 8
 9    if not "H_L" in m.complexity :
10        _ = m.block_convergence()
11
12    H_L = m.complexity[ "H_L" ]
13    L = np.asarray( [ i+1 for i in range( len( H_L ) ) ], dtype='float64')
14    y = E + L*h_mu
15
16    plt.style.use('seaborn-v0_8-darkgrid') 
17    fig, ax = plt.subplots(figsize=(10, 6), dpi=120)
18
19    ax.plot( L, H_L, color='#1E88E5', linewidth=2.0, linestyle='-', label=r'$H(L)$')
20    ax.plot( L, y, color='#D81B60', linewidth=1.5, linestyle='--', label=r'$\mathbf{E} + h_{\mu}L$')
21
22    ax.fill_between(
23        L, H_L, y, 
24        color='gray', 
25        alpha=0.5, 
26        label=r'Transient information $\mathbf{T}$'
27    )
28
29    ax.set_title('Block Entropy Curve', fontsize=16, fontweight='bold', pad=15)
30    ax.set_xlabel('L', fontsize=12, labelpad=10)
31    ax.set_ylabel('Bits', fontsize=12, labelpad=10)
32
33    legend = ax.legend(
34        loc='upper left', 
35        title_fontsize='11',
36        fontsize='10',
37        frameon=True,
38        facecolor='white',
39        shadow=True
40    )
41
42    legend.get_title().set_fontweight('bold')
43    plt.tight_layout() 
44    plt.show()
45
46def draw_block_measure_curves(m) :
47
48    if not "H_L" in m.complexity :
49        _ = m.block_convergence()
50
51    H_L = m.complexity[ "H_L" ]
52    E_L = m.complexity[ "E_L" ]
53    T_L = m.complexity[ "T_L" ]
54    S_L = m.complexity[ "S_L" ]
55    H_sync = m.complexity[ "H_sync" ][1:]
56    h_mu_L = m.complexity[ "h_mu_L" ]
57
58    L = np.asarray( [ i+1 for i in range( len( H_L ) ) ], dtype='float64')
59
60    plt.style.use('seaborn-v0_8-darkgrid') 
61    fig, ax = plt.subplots(figsize=(10, 6), dpi=120)
62    colors = plt.cm.tab10.colors 
63
64    ax.plot( L, H_L, color=colors[0], linewidth=2.0, linestyle='-', label=r'$H(L)$')
65    ax.plot( L, E_L, color=colors[1], linewidth=2.0, linestyle='-', label=r'$\mathbf{E}(L)$')
66    ax.plot( L, T_L, color=colors[2], linewidth=2.0, linestyle='-', label=r'$\mathbf{T}(L)$')
67    ax.plot( L, S_L, color=colors[3], linewidth=2.0, linestyle='-', label=r'$\mathbf{S}(L)$')
68    ax.plot( L, H_sync, color=colors[4], linewidth=2.0, linestyle='-', label=r'$\mathcal{H}(L)$')
69    ax.plot( L, h_mu_L, color=colors[5], linewidth=2.0, linestyle='-', label=r'$h_{\mu}(L)$')
70
71    ax.set_title('Block Measures', fontsize=16, fontweight='bold', pad=15)
72    ax.set_xlabel('L', fontsize=12, labelpad=10)
73    ax.set_ylabel('Bits', fontsize=12, labelpad=10)
74
75    legend = ax.legend(
76        loc='upper left', 
77        title_fontsize='11',
78        fontsize='10',
79        frameon=True,
80        facecolor='white',
81        shadow=True
82    )
83
84    legend.get_title().set_fontweight('bold')
85    plt.tight_layout() 
86    plt.show()
87    
def draw_block_entropy_curve(m):
 5def draw_block_entropy_curve( m ) :
 6    
 7    h_mu = m.h_mu()
 8    E = m.E()
 9
10    if not "H_L" in m.complexity :
11        _ = m.block_convergence()
12
13    H_L = m.complexity[ "H_L" ]
14    L = np.asarray( [ i+1 for i in range( len( H_L ) ) ], dtype='float64')
15    y = E + L*h_mu
16
17    plt.style.use('seaborn-v0_8-darkgrid') 
18    fig, ax = plt.subplots(figsize=(10, 6), dpi=120)
19
20    ax.plot( L, H_L, color='#1E88E5', linewidth=2.0, linestyle='-', label=r'$H(L)$')
21    ax.plot( L, y, color='#D81B60', linewidth=1.5, linestyle='--', label=r'$\mathbf{E} + h_{\mu}L$')
22
23    ax.fill_between(
24        L, H_L, y, 
25        color='gray', 
26        alpha=0.5, 
27        label=r'Transient information $\mathbf{T}$'
28    )
29
30    ax.set_title('Block Entropy Curve', fontsize=16, fontweight='bold', pad=15)
31    ax.set_xlabel('L', fontsize=12, labelpad=10)
32    ax.set_ylabel('Bits', fontsize=12, labelpad=10)
33
34    legend = ax.legend(
35        loc='upper left', 
36        title_fontsize='11',
37        fontsize='10',
38        frameon=True,
39        facecolor='white',
40        shadow=True
41    )
42
43    legend.get_title().set_fontweight('bold')
44    plt.tight_layout() 
45    plt.show()
def draw_block_measure_curves(m):
47def draw_block_measure_curves(m) :
48
49    if not "H_L" in m.complexity :
50        _ = m.block_convergence()
51
52    H_L = m.complexity[ "H_L" ]
53    E_L = m.complexity[ "E_L" ]
54    T_L = m.complexity[ "T_L" ]
55    S_L = m.complexity[ "S_L" ]
56    H_sync = m.complexity[ "H_sync" ][1:]
57    h_mu_L = m.complexity[ "h_mu_L" ]
58
59    L = np.asarray( [ i+1 for i in range( len( H_L ) ) ], dtype='float64')
60
61    plt.style.use('seaborn-v0_8-darkgrid') 
62    fig, ax = plt.subplots(figsize=(10, 6), dpi=120)
63    colors = plt.cm.tab10.colors 
64
65    ax.plot( L, H_L, color=colors[0], linewidth=2.0, linestyle='-', label=r'$H(L)$')
66    ax.plot( L, E_L, color=colors[1], linewidth=2.0, linestyle='-', label=r'$\mathbf{E}(L)$')
67    ax.plot( L, T_L, color=colors[2], linewidth=2.0, linestyle='-', label=r'$\mathbf{T}(L)$')
68    ax.plot( L, S_L, color=colors[3], linewidth=2.0, linestyle='-', label=r'$\mathbf{S}(L)$')
69    ax.plot( L, H_sync, color=colors[4], linewidth=2.0, linestyle='-', label=r'$\mathcal{H}(L)$')
70    ax.plot( L, h_mu_L, color=colors[5], linewidth=2.0, linestyle='-', label=r'$h_{\mu}(L)$')
71
72    ax.set_title('Block Measures', fontsize=16, fontweight='bold', pad=15)
73    ax.set_xlabel('L', fontsize=12, labelpad=10)
74    ax.set_ylabel('Bits', fontsize=12, labelpad=10)
75
76    legend = ax.legend(
77        loc='upper left', 
78        title_fontsize='11',
79        fontsize='10',
80        frameon=True,
81        facecolor='white',
82        shadow=True
83    )
84
85    legend.get_title().set_fontweight('bold')
86    plt.tight_layout() 
87    plt.show()