Basic Examples
Basic Examples
Retrieve the sequence packed into bytes:
In[]:=
bytes=ResourceData["A Billion Bits of the Center Column of the Rule 30 Cellular Automaton"]
Out[]=
ByteArray
Unpack the sequence as bits (this can take some time):
In[]:=
bits=Flatten[IntegerDigits[#,2,8]&/@Normal[bytes]];
The sequence contains a billion bits:
In[]:=
Length[bits]
Out[]=
1000000000
It uses about 8 GB of memory:
In[]:=
ByteCount[bits]
Out[]=
8000000144
Show the first 100 bits:
In[]:=
Take[bits,100]
Out[]=
{1,1,0,1,1,1,0,0,1,1,0,0,0,1,0,1,1,0,0,1,0,0,1,1,1,0,1,0,1,1,1,0,0,1,1,1,0,1,0,1,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,1,1,0,1,0,1,0,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,1,0,0,1,0,1,1,0,0}
Compare with a direct computation:
In[]:=
CellularAutomaton[30,{{1},0},{100,{{0}}}]
Out[]=
{1,1,0,1,1,1,0,0,1,1,0,0,0,1,0,1,1,0,0,1,0,0,1,1,1,0,1,0,1,1,1,0,0,1,1,1,0,1,0,1,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,1,1,0,1,0,1,0,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,1,0,0,1,0,1,1,0,0,0}
Count the total number of 1s and 0s in the full sequence:
In[]:=
Counts[bits]
Out[]=
1500025038,0499974962
Count the number of occurrences of possible 2-grams:
In[]:=
SequenceCount[bits,#]&/@Tuples[{1,0},2]
Out[]=
{166676241,250000321,250000320,166655204}
Compute the running excess of 1s over 0s:
In[]:=
acc=Accumulate[2bits-1];
Find the extreme values:
In[]:=
MinMax[acc]
Out[]=
{-257,55551}
Plot the running excess:
In[]:=
ListLinePlot[ArrayResample[acc,{1000}]]
Out[]=