I am trying out an encoding - decoding method that had been asked in this post https://stackoverflow.com/questions/40820958/matlab-help-in-implementing-a-mathematical-equation-for-generating-multi-level
and a related one Generate random number with given probability matlab
There are 2 parts to this question - encoding and decoding. Encoding of a symbolic sequence is done using inverse interval mapping using the map f_inv
. The method of inverse interval mapping yields a real valued number. Based on the real valued number, we iterate the map f()
. The solution in the post in the first link does not work - because once the final interval is found, the iteration of the map f()
using the proposed solution does not yield the same exact symbolic array. So, I tried by directly implementing the equations for the forward iteration f()
given in the paper for the decoding process, but the decoding does not generate the same symbolic sequence.
Here is a breif explanation of the problem.
Let there be an array b = [1,3,2,6,1]
containing N = 5
integer valued elements with probability of occurence of each unique integer as 0.4, 0.2, 0.2, 0.2
respectively. The array b
can take any integers from the unique symbol set 1,2,3,4,5,6,7,8
. Let n = 8
elements in the symbol set. In essence, the probability for the above data b
is
p= [ 0.4 (for symbol 1), 0.2 (for symbol 2) , 0.2 (symbol 3), 0 (for symbol 4 not occuring), 0 (for symbol 5), 0.2(for symbol 6), 0 (for symbol 7), 0 (for symbol 8)]
An interval [0,1]
is split into 8 regions. Let, the interval for the data b
assumed to be known as
Interval_b = [0, 0.4, 0.6, 0.8, 1];
In general, for n = 8
unique symbols, there are n = 8
intervals such as I_1, I_2, I_3, I_4, I_5, I_6, I_6,I_7,I_8
and each of these intervals is assigned a symbol such as [ 1 2 3 4 5 6 7 8]
Let, x = 0.2848
that has been obtained from the reverse interval mapping for the symbol array b
from the solution for the encoding procedure in the link. There is a mapping rule which maps x
to the symbol depending on the interval in which x
lies and we should obtain the same symbol elements as in b
. The rule is