Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been trying to follow this video to implement my own Arithmetic Coding algorithm in Java. I am having a bit of trouble figuring out what some of the variables in the video should be.

For example if I have:

An Input alphabet - { 1,  2  , 3 , 4}
Probabilities     - {0.1,0.1,0.1,0.7} 
An Input of       - [12312]

Would my values for the following be correct?

P1 = 1/4
P2 = 1/4
P3 = 1/4
P4 = 1/4

C1 = 0
C2 = 1
C3 = 2
C4 = 3

D1 = 1
D2 = 2
D3 = 3
D4 = 4 

I am pretty confused by some definitions in the linked video, any advice would be appreciated !

share|cite|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.