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
Arithmetic 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!
===Encoding and decoding: example=== [[Image:Arithmetic encoding.svg|400px|thumb|right|A diagram showing decoding of 0.538 (the round dot) in the example model. The region is divided into subregions proportional to symbol frequencies, then the subregion containing the point is successively subdivided in the same way.]] Consider the process for decoding a message encoded with the given four-symbol model. The message is encoded in the fraction 0.538 (using decimal for clarity, instead of binary; also assuming that there are only as many digits as needed to decode the message.) The process starts with the same interval used by the encoder: <nowiki>[0,1)</nowiki>, and using the same model, dividing it into the same four sub-intervals that the encoder must have. The fraction 0.538 falls into the sub-interval for NEUTRAL, <nowiki>[0, 0.6)</nowiki>; this indicates that the first symbol the encoder read must have been NEUTRAL, so this is the first symbol of the message. Next divide the interval <nowiki>[0, 0.6)</nowiki> into sub-intervals: * the interval for NEUTRAL would be <nowiki>[0, 0.36)</nowiki>, ''60% of <nowiki>[0, 0.6)</nowiki>''. * the interval for POSITIVE would be <nowiki>[0.36, 0.48)</nowiki>, ''20% of <nowiki>[0, 0.6)</nowiki>''. * the interval for NEGATIVE would be <nowiki>[0.48, 0.54)</nowiki>, ''10% of <nowiki>[0, 0.6)</nowiki>''. * the interval for END-OF-DATA would be <nowiki>[0.54, 0.6)</nowiki>, ''10% of <nowiki>[0, 0.6)</nowiki>''. Since 0.538 is within the interval <nowiki>[0.48, 0.54)</nowiki>, the second symbol of the message must have been NEGATIVE. Again divide our current interval into sub-intervals: * the interval for NEUTRAL would be <nowiki>[0.48, 0.516)</nowiki>. * the interval for POSITIVE would be <nowiki>[0.516, 0.528)</nowiki>. * the interval for NEGATIVE would be <nowiki>[0.528, 0.534)</nowiki>. * the interval for END-OF-DATA would be <nowiki>[0.534, 0.540)</nowiki>. Now 0.538 falls within the interval of the END-OF-DATA symbol; therefore, this must be the next symbol. Since it is also the internal termination symbol, it means the decoding is complete. If the stream is not internally terminated, there needs to be some other way to indicate where the stream stops. Otherwise, the decoding process could continue forever, mistakenly reading more symbols from the fraction than were in fact encoded into it.
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)