Help replicating a simple calculation in a paper on Asymmetric Number Systems

130 Views Asked by At

This question is rather simple, it boils down to whether I am reading a math paper correctly? I am attempting to read this paper by Jarek Duda on Assyemtric Number Systems and their use in compression of data.

https://arxiv.org/pdf/1311.2540v2.pdf

I'm a bit rusty on my math lingo so I tried to replicate the calculations to help me understand them, and I failed. Am I missing something? This is roughly what is on page 7:

Encoding is

$$ C(x,s)= \left\{ \begin{array}{11} \big\lceil\frac{x+1}{1-p}\big\rceil-1 & \mbox{if } s = 0 \\ \big\lfloor\frac{x}{p}\big\rfloor & \mbox{if } s = 1 \end{array} \text{or}=\Bigg\{ \begin{array}{11} \big\lfloor\frac{x}{1-p}\big\rfloor & \mbox{if } s = 0 \\ \big\lceil\frac{x+1}{p}\big\rceil-1 & \mbox{if } s = 1 \end{array} \right. $$ For p = 1/2 it is the standard binary numeral system with switched digits. The starting values for this formula and p = 0.3 are presented in bottom-right of Fig. 1. Here is an example of encoding process by inserting succeeding symbols: $$ 1\xrightarrow{1} 3\xrightarrow{0} 5\xrightarrow{0} 8\xrightarrow{1} 26\xrightarrow{0} 38\xrightarrow{1} 128\xrightarrow{0} 184\xrightarrow{0} 264... $$

I tried to calculate this sequence myself, and I got different results

s: 1 x: 1 x': 3
s: 0 x: 3 x': 5
s: 0 x: 5 x': 8
s: 1 x: 8 x': 26
s: 0 x: 26 x': 38
s: 1 x: 38 x': 126
s: 0 x: 126 x': 181
s: 0 x: 181 x': 259

Here is my calculation program in the Python language:

from fractions import Fraction as F
import math

def C(s,x):
        p=F(3,10)
        if s==0: return math.ceil(F(x+1,1-p))-1
        elif s==1: return math.floor(F(x,p))
        else: print("error")

x = 1
for s in 1,0,0,1,0,1,0,0:
        print('s:',s,'x:',x,end='')
        x = C(s,x)
        print(" x':",x)

Thanks

1

There are 1 best solutions below

1
On BEST ANSWER

Sorry, my bad. This was historically the first variant (uABS from 2006), which has some advantages but also rounding issue one need to be careful about.

It is interesting question if uABS approach can be expanded to a larger alphabet?

In practice there are used large alphabet: tabled tANS (2007), or much more crude rANS (2013).