Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Shannon–Fano coding
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Example=== [[Image:ShannonCodeAlg.svg|right|thumb|300px|Shannon–Fano Algorithm]] We continue with the previous example. :{| class="wikitable" style="text-align: center;" ! Symbol ! A ! B ! C ! D ! E |- ! Count | 15 | 7 | 6 | 6 | 5 |- ! Probabilities | 0.385 | 0.179 | 0.154 | 0.154 | 0.128 |} All symbols are sorted by frequency, from left to right (shown in Figure a). Putting the dividing line between symbols B and C results in a total of 22 in the left group and a total of 17 in the right group. This minimizes the difference in totals between the two groups. With this division, A and B will each have a code that starts with a 0 bit, and the C, D, and E codes will all start with a 1, as shown in Figure b. Subsequently, the left half of the tree gets a new division between A and B, which puts A on a leaf with code 00 and B on a leaf with code 01. After four division procedures, a tree of codes results. In the final tree, the three symbols with the highest frequencies have all been assigned 2-bit codes, and two symbols with lower counts have 3-bit codes as shown table below: :{| class="wikitable" style="text-align: center;" ! Symbol ! A ! B ! C ! D ! E |- ! Probabilities | 0.385 | 0.179 | 0.154 | 0.154 | 0.128 |- ! First division | colspan="2" | 0 | colspan="3" | 1 |- ! Second division | rowspan="2" style="vertical-align:top"; | 0 | rowspan="2" style="vertical-align:top"; | 1 | rowspan="2" style="vertical-align:top"; | 0 | colspan="2" | 1 |- ! Third division | 0 | 1 |- ! Codewords | 00 | 01 | 10 | 110 | 111 |} This results in lengths of 2 bits for A, B and C and per 3 bits for D and E, giving an average length of :<math display="block">\frac{2\,\text{bits}\cdot(15+7+6) + 3\,\text{bits} \cdot (6+5)}{39\, \text{symbols}} \approx 2.28\,\text{bits per symbol.}</math> We see that Fano's method, with an average length of 2.28, has outperformed Shannon's method, with an average length of 2.62.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)