So I need to calculate the entropy for a code. We are not allowed to use a calculator and I wonder how I can make my life easier.
Given the following expression:
$$ -\frac{6}{24}\log_2\left(\frac{6}{24}\right) - \frac{4}{24}\log_2\left(\frac{4}{24}\right) -\frac{9}{24}\log_2\left(\frac{9}{24}\right) - \frac{1}{24}\log_2\left(\frac{1}{24}\right)-\frac{4}{24}\log_2\left(\frac{4}{24}\right)$$
how can i calculate that without a calculator properly? I tried this now several times but i end up with lots of fractions which seem to be very hard for me to calculate in time without a calculator.
Any tips on how you would calculate this properly?
First, write $\log(a/24)=\log(a)-\log(24),$ so you get: $$\log_2 24-\frac{1}{24}\left(6\log_2 6 + 4\log_2 4 +9\log_2 9 +4\log_2 4\right)$$
Then use $$\begin{align}\log_2 24&=3+\log_2 3,\\\log_2 6&=1+\log_2 3,\\\log_2 4&=2,\\\log_2 9&=2\log_2 3.\end{align}$$
you get: $$3+\log_2 3-\frac{1}{24}\left(22+24\log_2 3\right)=\frac{25}{12}$$
In general, if $p_i=\frac{n_i}{N}$ for $i=1,\dots,k$ then the entropy will be:
$$\log_2 N -\frac{1}{N}\sum_{i=1}^{k} n_i\log_2 n_i$$