Matlab : Unable to get unique rationals when implementing a formula for binary to real number conversion Part1
Asked Answered
S

1

7

There is a nonlinear dynamic system x_n = f(x_n,eta) whose functional form is x[n+1] = 2*x[n] mod 1. This is a chaotic dynamical system called as the Sawtooth map or the Bernoulli Map. I am facing difficulty in implementing the two representations of the inverse mapping given by Eq(4) and Eq(5). Following is a brief description of the problem.

description

where the sequence (s[n+k])_k=1 to N-1 is the symbolic description of the state x[n]. This description arises from the partitioning of the unit interval described below.

Let, the number of partitions M = 2 and the symbol space = {0,1} and the rule for assigning symbols is

 s[n+1] = 1 if x[n] >= 0.5, otherwise s[n+1] = 0

Authors of this paper :

Linear, Random Representations of Chaos

For Eq(5) I am not getting the same time series after inverse, few values differ after doing the binary to real conversion. Can somebody please let me the correct procedure?

I tried to implement the Bijective map for the Eqs(4) and (5), but it does not work.

Code for Eq(5) - I am binarizing into 2 ways. x contains the real numbers; s is the 0/1 binary equivalent of each real; y is the answer after converting s to real. s1 is the +1/-1 binary equivalent of x; b is the answer after converting to real. In this case of +1/-1, when I am converting from symbolic representation to real, I switch -1 with 0 and then apply the formula in Eq(5). From the answers, it can be seen that y and b are not the same as x after doing the conversion. I am also getting negative reals for b when the original reals are all unsigned rationals!! How can I correctly implement so that they are both same?

N  =10;
x(1) = 0.1;
for i =1 : N
       x(i+1) = mod(x(i)*2, 1);
end
    y = x;
 s = (y>=0.5);  %generate 0/1 logicals


for n = 1: N        
y(n) = 0.5*s(n+1) + 0.5*y(n+1);   
end

b=x;

 s1 = 2*(b>=0.5)-1; %Generate +1/-1



    for k =1: N
   if s1(k)== -1
       s1(k) = 0;
   end
b(k) = 0.5*s1(k+1) + 0.5*b(k+1);   
 end

Let, x =

 0.100000000000000  0.200000000000000   0.400000000000000   0.800000000000000   0.600000000000000   0.200000000000000   0.400000000000000   0.800000000000001   0.600000000000001   0.200000000000003   0.400000000000006

y =

0.100000000000000   0.200000000000000   0.900000000000000   0.800000000000000   0.100000000000000   0.200000000000000   0.900000000000000   0.800000000000001   0.100000000000001   0.200000000000003   0.400000000000006

b =

-0.400000000000000  0.700000000000000   0.900000000000000   -0.200000000000000  -0.400000000000000  0.700000000000000   0.900000000000000   -0.199999999999999  -0.399999999999999  -0.299999999999997  0.400000000000006
Silvester answered 1/6, 2015 at 20:58 Comment(3)
According to equation 4, k increases from n to n+N-1. So \beta_inverse(s_n) uses s_n? How? Also I don't think it uses s(9),...,s(1). Another thing, do we have to read the entire question to answer?Odyl
S_n is a vector of n symbols and you are right, S_10 uses s_10,s_11 and so on. For example, S = beta(binary_of_x) = beta(0.101) = 0.01Silvester
There are too many major edits in your questions OP, often after answers have been given. This is number six, if memory serves correctly. I'll look to report these to a moderator when I have time - in the meantime please desist from such major edits. We like to preserve questions in the form they were asked, unless there are extenuating circumstances.Hefty
T
2

this piece of your code is completely wrong ,you change s(k) but you use s(k+1), it means that changing s(k) has not any effect!

 for k =1: N
    if s1(k)== -1
       s1(k) = 0;
    end
 b(k) = 0.5*s1(k+1) + 0.5*b(k+1);   
 end

true one is:

  for k =1: N+1
    if s1(k)== -1
       s1(k) = 0;
    end
  end
  for k =1: N
      b(k) = 0.5*s1(k+1) + 0.5*b(k+1);
  end

y =

Columns 1 through 10

0.1000    0.2000    0.9000    0.8000    0.1000    0.2000    0.9000    0.8000    0.1000    0.2000

Column 11

0.4000

b =

Columns 1 through 10

0.1000    0.2000    0.9000    0.8000    0.1000    0.2000    0.9000    0.8000    0.1000    0.2000

Column 11

0.4000

x= 0.1 0.2 0.4 0.8

1)b=x => b=0.1 0.2 0.4 0.8

2)s1= 2(b>=0.5)-1 =>s1= -1 -1 -1 1

3)loop on s1=> s1= 0 0 0 1

4)b(3)=0.5*s(4)+0.5(b4)=0.5+0.4=0.9

so code is correct, but your formula is in correct! and one another thing, >step 3 and 4 cancel out each other, i mean result of step 3 and 4 together is (b>0.5), and as a conclusion! its obvious from your formula that if x(i)>0.5 and x(i-1)<0.5 then b(i-1) cannot be equal to x(i-1)

because b(i-1)=0.5*X(i)+0.5*((x(i)>0.5))

and if we assume x(i)>0.5 we could write:

b(i-1)=0.5*X(i)+0.5*1

and we know x(i)=mod(2x(i-1),1)=2*x(i-1) {because x(i-1)<0.5 so 2*x(i-1)<1}

so we have

b(i-1)=0.5*2*X(i-1)+0.5*1=X(i-1)+0.5 => b(i-1)>0.5, but x(i-1)<0.5!!!!!

so your formula is wrong.

Turgescent answered 5/6, 2015 at 1:57 Comment(6)
Thank you for your reply. However, the main problem that converting the binary to real as done by your corrected implementation Is not equal to the original real numbers, x . Why values in b is not equal to values in x?Silvester
Also, there Is a new error that I am getting Attempted to access s1(129); index out of bounds because size(s1)=[128] (where N =128 instead of N = 10Silvester
check size of x (or b ,etc) if it is 128 , N must be 127!Turgescent
Thank you for the details. N = 128 but sixe of x = 129. Also, the formula is given by the Authors of the paper that I linked to. I do not know how to solve this problem such that the binary to decimal conversion of b = x . Do you have any thoughts?Silvester
I had asked another Question here : #30633832 which is about implementing Eq(4)/ Both these formulae are celebrated formula in literature and a lot of researchers have cited them. But, as you can see implementing them (Eq(5)) for instance is giving incorrect result !! :(Silvester
@Silvester i studied mechanical engineering but don't know enough about chaos systems , so i cannot say what is the main problem of this formula, but you can send an example to the author of the paper and request for explanation, and may be you got the wrong idea about implementation of S(n). hope you can find the true answer.Turgescent

© 2022 - 2024 — McMap. All rights reserved.