Generating Arithmetic Coding in DC

Description
The ‘coder’ object attached to this article can work box implementation of an arithmetic encoder. However, to use it, we used understand the basics of statistical modeling for arithmetic coding and  concepts of arithmetic coding.
In general, using arithmetic coding effects creating a statistical model of the data. In this example, I will assume that we are trying to encode the words “HELLO WORLD”.
Creating the statistical model of the data proceeds as follows:

  1. Taking the number of independent characters in the words to be encoded (HELLO WORLD), we obtain, in alphabetical order:
    1. D
    2. E
    3. H
    4. L
        1. O
        2. R
        3. W
      The total number of characters to be encoded is 10. For convenience and clarity, I have ignored the space between the words HELLO and WORLD.
      1. We can arrange these characters into a table with their corresponding frequency, as below:
      Character
      Frequency
      D
      1
      E
      1
      H
      1
      L
      3
      O
      2
      R
      1
      W
      1
      1. Each of the characters will be assigned a range based on its frequency/ probability of occurrence. This range will be between 0 and 1, as below (note that I have not used any optimizations for the frequency and probability model; for the most optimal compression, this is necessary; however, for the purposes of our example, this should do).
      Character
      Frequency
      Probability
      Range
      D
      1
      1/10
      0.0 – 0.1
      E
      1
      1/10
      0.1 – 0.2
      H
      1
      1/10
      0.2 – 0.3
      L
      3
      3/10
      0.3 – 0.6
      O
      2
      2/10
      0.6 – 0.8
      R
      1
      1/10
      0.8 – 0.9
      W
      1
      1/10
      0.9 – 1.0
      1. The algorithm for encoding is as below:

      Set low to 0.0
      Set high to 1.0
      While there are still input symbols do
          get an input symbol
          code_range = high - low.
      1. The algorithm for decoding the number and retrieving the encoded string/data is as below:
      Find the symbol represented by the range that the number is in, output it. Remove the effects of encoding and repeat. In pseudo-code: