Block Entropy TutorialΒΆ

This tutorial will walk you though how to create a plot like figure 1 from the sync control paper.


add reference to sync control, show fig1.

First we import a few libraries that will be needed:

import numpy as np
import matplotlib.pyplot as plt
from cmpy.machines import NRPS

Fnd now we compute our block entropies using CMPy’s cmech_quantities() method:

m = NRPS()
L = np.arange(0, 8)
be, bse, asm = m.cmech_quantities(['HX0L', 'HX0LSL', 'HX0L~'], L[-1])
R = m.markov_order()
k = m.cryptic_order()
E = asm[0]
Cmu = bse[0]

Next we will construct a figure and axes for the plotting:

fig = plt.figure()
ax = plt.axes()
ax.plot(L, be, label=r"$\BE{\ell}$")
ax.plot(L, bse, label=r"$\BSE{\ell}$")
ax.plot(L, asm, 'k--', label=r"$\EE + \ell \hmu$")
ymax = ax.get_ylim()[1]
ax.axvline(k, ymin=0, ymax=bse[k]/ymax, ls=':', c='k')
ax.axvline(R, ymin=0, ymax=be[R]/ymax, ls=':', c='k')
ax.set_xlabel(r"Block length $\ell$")
ax.set_ylabel(r"Entropy [bits]")
ax.set_xticks([k, R])
ax.set_yticks([E, Cmu])
ax.set_xticklabels([r'$\COrder$', r'$\MOrder$'])
ax.set_yticklabels([r'$\EE$', r'$\Cmu'$])
ax.set_title(r'Block entropy curves for {0}'.format(

This will produce the following image: