Info

This question is closed. Reopen it to edit or answer.

Help with binary code

1 view (last 30 days)
FRANCISCO
FRANCISCO on 27 Aug 2013
good I ask a question that has nothing to do at the moment with programming in Matlab, but with statistical issues and wonder if anyone can help,
My purpose is predicting the following number of binary string. For this, I have a sequence of binary digits that is:
s= 1(1) 0(2) 1(3) 1(4) 0(5) 0(6) 1(7) 0(8) 0(9) 1(10) 1(11) 1(12) 1(13) 0(14) 0(15) 0(16) 1(17) 1(18) 1(19) 0(20).
What I did then is creating substrings produced as follows:
1) 1 (1) 0 (2) 1 (3) 1 (4) --- [1 0 1 1]
2) 1 (1) 1 (3) 0 (5) 1 (7) --- [1 1 0 1]
3) 1 (1) 1 (4) 1 (7) 1 (10) --- [1 1 1 1]
4) 1 (1) 0 (5) 0 (9) 1 (13) --- [1 0 0 1]
5) 1 (1) 0 (6) 1 (11) 0 (16) --- [1 0 1 0]
6) 1 (1) 1 (7) 1 (13) 1 (19) --- [1 1 1 1]
7) 0 (2) 1 (3) 1 (4) 0 (5) --- [0 1 1 0]
8) 0 (2) 1 (4) 0 (6) 0 (8) --- [0 1 0 0]
9) 0 (2) 0 (5) 0 (8) 1 (11) --- [0 0 0 1]
10) 0 (2) 0 (6) 1 (10) 0 (14) --- [0 0 1 0]
11) 0 (2) 1 (7) 1 (12) 1 (17) --- [0 1 1 1]
12) 0 (2) 0 (8) 0 (14) 0 (20) --- [0 0 0 0]
13) 1 (3) 1 (4) 0 (5) 0 (6) --- [1 1 0 0]
14) 1 (3) 0 (5) 1 (7) 0 (9) --- [1 0 1 0]
15) 1 (3) 0 (6) 0 (9) 1 (12) --- [1 0 0 1]
16) 1 (3) 1 (7) 1 (11) 0 (15) --- [1 1 1 0]
17) 1 (3) 0 (8) 1 (13) 1 (18) --- [1 0 1 1]
18) 1 (4) 0 (5) 0 (6) 1 (7) --- [1 0 0 1]
19) 1 (4) 0 (6) 0 (8) 1 (10) --- [1 0 0 1]
20) 1 (4) 1 (7) 1 (10) 1 (13) --- [1 1 1 1]
21) 1 (4) 0 (8) 1 (12) 0 (16) --- [1 0 1 0]
22) 1 (4) 0 (9) 0 (14) 1 (19) --- [1 0 0 1]
23) 0 (5) 0 (6) 1 (7) 0 (8) --- [0 0 1 0]
24) 0 (5) 1 (7) 0 (9) 1 (11) --- [0 1 0 1]
25) 0 (5) 0 (8) 1 (11) 0 (14) --- [0 0 1 0]
26) 0 (5) 0 (9) 1 (13) 1 (17) --- [0 0 1 1]
27) 0 (5) 1 (10) 0 (15) 0 (20) --- [0 1 0 0]
28) 0 (6) 1 (7) 0 (8) 0 (9) --- [0 1 0 0]
29) 0 (6) 0 (8) 1 (10) 1 (12) --- [0 0 1 1]
30) 0 (6) 0 (9) 1 (12) 0 (15) --- [0 0 1 0]
31) 0 (6) 1 (10) 0 (14) 1 (18) --- [0 1 0 1]
32) 1 (7) 0 (8) 0 (9) 1 (10) --- [1 0 0 1]
33) 1 (7) 0 (9) 1 (11) 1 (13) --- [1 0 1 1]
34) 1 (7) 1 (10) 1 (13) 0 (16) --- [1 1 1 0]
35) 1 (7) 1 (11) 0 (15) 1 (19) --- [1 1 0 1]
36) 0 (8) 0 (9) 1 (10) 1 (11) --- [0 0 1 1]
37) 0 (8) 1 (10) 1 (12) 0 (14) --- [0 1 1 0]
38) 0 (8) 1 (11) 0 (14) 1 (17) --- [0 1 0 1]
39) 0 (8) 1 (12) 0 (16) 0 (20) --- [0 1 0 0]
40) 0 (9) 1 (10) 1 (11) 1 (12) --- [0 1 1 1]
41) 0 (9) 1 (11) 1 (13) 0 (15) --- [0 1 1 0]
42) 0 (9) 1 (12) 0 (15) 1 (18) --- [0 1 0 1]
43) 1 (10) 1 (11) 1 (12) 1 (13) --- [1 1 1 1]
44) 1 (10) 1 (12) 0 (14) 0 (16) --- [1 1 0 0]
45) 1 (10) 1 (13) 0 (16) 1 (19) --- [1 1 0 1]
46) 1 (11) 1 (12) 1 (13) 0 (14) --- [1 1 1 0]
47) 1 (11) 1 (13) 0 (15) 1 (17) --- [1 1 0 1]
48) 1 (11) 0 (14) 1 (17) 0 (20) --- [1 0 1 0]
49) 1 (12) 1 (13) 0 (14) 0 (15) --- [1 1 0 0]
50) 1 (12) 0 (14) 0 (16) 1 (18) --- [1 0 0 1]
51) 1 (13) 0 (14) 0 (15) 0 (16) --- [1 0 0 0]
52) 1 (13) 0 (15) 1 (17) 1 (19) --- [1 0 1 1]
53) 0 (14) 0 (15) 0 (16) 1 (17) --- [0 0 0 1]
54) 0 (14) 0 (16) 1 (18) 0 (20) --- [0 0 1 0]
55) 0 (15) 0 (16) 1 (17) 1 (18) --- [0 0 1 1]
56) 0 (16) 1 (17) 1 (18) 1 (19) --- [0 1 1 1]
57) 1 (17) 1 (18) 1 (19) 0 (20) --- [1 1 1 0]
And I've also calculated the relative frequency of these substrings
0 0 0 0------ 0,0175438596491228
0 0 0 1------ 0,0350877192982456
0 0 1 0------ 0,0877192982456140
0 0 1 1------ 0,0701754385964912
0 1 0 0------ 0,0701754385964912
0 1 0 1------ 0,0701754385964912
0 1 1 0------ 0,0526315789473684
0 1 1 1------ 0,0526315789473684
1 0 0 0------ 0,0175438596491228
1 0 0 1 0,122807017543860
1 0 1 0 0,0701754385964912
1 0 1 1 0,0701754385964912
1 1 0 0 0,0526315789473684
1 1 0 1 0,0701754385964912
1 1 1 0 0,0701754385964912
1 1 1 1 0,0701754385964912
Now let's say I want to know if the number 21 of the succession will be "0" or "1". To do this do the following:
s= 1(1) 0(2) 1(3) 1(4) 0(5) 0(6) 1(7) 0(8) 0(9) 1(10) 1(11) 1(12) 1(13) 0(14) 0(15) 0(16) 1(17) 1(18) 1(19) 0(20) X(21)
and now build substrings that have to do with X:
1: 1 (18), 1 (19), 0 (20), X (21) --- [1,1,0, X]
2: 0 (15), 1 (17), 1 (19), X (21) --- [0,1,1, X]
3: 1 (12), 0 (15), 1 (18), X (21) --- [1,0,1, X]
4: 0 (9), 1 (13), 1 (17), X (21) --- [0,1,1, X]
5: 0 (6), 1 (11), 0 (16), X (21) --- [0,1,0, X]
6: 1 (3), 0 (9), 0 (15), X (21) --- [1,0,0, X]
And replacing the X I have:
X = 1,
1: 1 (18), 1 (19), 0 (20), X (21) --- [1,1,0, 1 ]
2: 0 (15), 1 (17), 1 (19), X (21) --- [0,1,1, 1 ]
3: 1 (12), 0 (15), 1 (18), X (21) --- [1,0,1, 1 ]
4: 0 (9), 1 (13), 1 (17), X (21) --- [0,1,1, 1 ]
5: 0 (6), 1 (11), 0 (16), X (21) --- [0,1,0, 1 ]
6: 1 (3), 0 (9), 0 (15), X (21) --- [1,0,0, 1 ]
X = 0,
1: 1 (18), 1 (19), 0 (20), X (21) --- [1,1,0, 0 ]
2: 0 (15), 1 (17), 1 (19), X (21) --- [0,1,1, 0 ]
3: 1 (12), 0 (15), 1 (18), X (21) --- [1,0,1, 0 ]
4: 0 (9), 1 (13), 1 (17), X (21) --- [0,1,1, 0 ]
5: 0 (6), 1 (11), 0 (16), X (21) --- [0,1,0, 0 ]
6: 1 (3), 0 (9), 0 (15), X (21) --- [1,0,0, 0 ]
Okay, from here someone could tell me how I can study the probability to predict the next number in the string?

Answers (0)

This question is closed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!