Chaotic and Memoryless Binary Sequences Based on Skew Tent Maps

0. Note

1. Introduction

2. Probability of binary sequence

3. Entropy vs Compression Ratio

4. When t ≠ c is not memoryless

5. Conclusion

6. Source Code

#!/usr/bin/ruby -wx = c = Array.new;
binary_sequence = Array.new;
$P0 = $P1 = $P00 = $P01 = $P10 = $P11 = $P0l0 = $P0l1 = $P1l0 = $P1l1 = 0;
print "Input initial value x[1] from 0 ~ 1: ";
x[1] = gets.chomp.to_f;
print "\nInput critical point c[1] from 0 ~ 1: ";
c = gets.chomp.to_f;
print "\nInput number of sequence N: ";
N = gets.chomp.to_f;
for n in 1..N
if x[n] >= 0 and x[n] < c
x[n+1] = x[n]/c;
elsif x[n] >= c and x[n] <= 1
x[n+1] = (1-x[n])/(1-c);
else
print "x must be from 0 ~ 1";
end
end
puts "P(0)_theory = c = #{c}";
puts "P(1)_theory = 1-c = #{1-c}";
puts "P(00)_theory = c*c = #{c*c}";
puts "P(01)_theory = c(1-c) = #{c*(1-c)}";
puts "P(10)_theory = (1-c)c = #{(1-c)*c}";
puts "P(11)_theory = (1-c)*(1-c) = #{(1-c)*(1-c)}";
puts "P(0|0)_theory = c = #{c}";
puts "P(0|1)_theory = c = #{c}";
puts "P(1|0)_theory = 1-c = #{1-c}";
puts "P(1|1)_theory = 1-c = #{1-c}";
puts "";
file = File.new("binary_sequence.dat", "w");for n in 1..N
if x[n] < c
binary_sequence[n] = 0;
$P0 += 1;
elsif x[n] >= c
binary_sequence[n] = 1;
$P1 += 1;
else
print "something is wrong";
end
#print binary_sequence[n];
file.syswrite(binary_sequence[n]);
end
P0_actual = $P0/N.to_f;
P1_actual = $P1/N.to_f;
for n in 1..N
if binary_sequence[n] == 0 and binary_sequence[n+1] == 0
$P00 += 1;
elsif binary_sequence[n] == 0 and binary_sequence[n+1] == 1
$P01 += 1;
elsif binary_sequence[n] == 1 and binary_sequence[n+1] == 0
$P10 += 1;
else
$P11 += 1;
end
end
P00_actual = $P00/N.to_f;
P01_actual = $P01/N.to_f;
P10_actual = $P10/N.to_f;
P11_actual = $P11/N.to_f;
P0l0_actual = P00_actual/P0_actual;
P0l1_actual = P01_actual/P1_actual;
P1l0_actual = P10_actual/P0_actual;
P1l1_actual = P11_actual/P1_actual;
puts "P(0)_actual = #{P0_actual}";
puts "P(1)_actual = #{P1_actual}";
puts "P(00)_actual = #{P00_actual}";
puts "P(01)_actual = #{P01_actual}";
puts "P(10)_actual = #{P10_actual}";
puts "P(11)_actual = #{P11_actual}";
puts "P(0|0)_actual = #{P0l0_actual}";
puts "P(0|1)_actual = #{P0l1_actual}";
puts "P(1|0)_actual = #{P1l0_actual}";
puts "P(1|1)_actual = #{P1l1_actual}";
puts "";
puts Entropy = ((-P1_actual)*(Math.log2(P1_actual)))-((P0_actual)*(Math.log2(P0_actual)));puts "Total of '0' is #{$P0}";
puts "Total of '1' is #{$P1}";
puts "Total of '00' is #{$P00}";
puts "Total of '01' is #{$P01}";
puts "Total of '10' is #{$P10}";
puts "Total of '11' is #{$P11}";

Mirrors

this blog contains all my articles licensed under creative commons attribution customized sharealike (cc-by-sa) where you can sell but mention the open one here

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store