# How to calculate the entropy rate hmu of a processΒΆ

The entropy rate hmu is defined as the entropy per symbol of infinitely long blocks of symbols. . Practically, it can be calculated in two ways.

First, as the asymptotic increase in block entropy per symbol when considering ever larger blocks of symbols:

where

The quantity can be calculated in cmpy via the cmech_quantities function for a whole range of values of L:

```
m=cmpy.machines.RRX()
Lmax=32
hmu_of_L=m.cmech_quantities(['hmu'],Lmax)
```

This returns a masked array of length Lmax+1 of for L=0..Lmax. The true value of hmu to which hmu(L) converges for L to infinite is returned in multiples of L via:

```
hmuL=machine.cmech_quantities(['hmuL'],Lmax)
```

This again returns a masked array of length Lmax+1 with each entry being hmu*L for L=0..Lmax. The entropy rate can then be found as:

```
hmu=hmuL[0,1]
```

Naturally, if only hmu is desired, it is enough to set Lmax=1.

We can also demonstrate the convergence of the block entropy against the entropy rate. With:

```
block_entro_over_L=machine.cmech_quantities(['HX0L'],Lmax)/range(0,Lmax+1)
```

we obtain a masked array of the block entropy per symbol. Note the use of the masked array as it allows us to divide by block lengths of zero.

The following figure was created with the help of these commands and shows the convergence of both and against hmu.