ultimately_periodic

178 days ago by lgstaub

import numpy as np def calc_period_entire(matt): if matt.shape[0]==0: return -1 for divi in divisors(matt.shape[0])[:-1]: this_one = True for i in range(1,matt.shape[0]/divi): if not np.all(matt[0:divi]==matt[i*divi:(i+1)*divi]): this_one = False break if this_one: return divi return -1 def calc_period(matt): periodicities = [] for i in range(1,matt.shape[0]/2): still_checking = True check_dist = 1 while still_checking: if matt.shape[0]-1-i-i*check_dist<0: return i still_checking = False periodicities.append([i,check_dist]) else: if np.all(matt[matt.shape[0]-1-i:matt.shape[0]-1]==matt[matt.shape[0]-1-i-i*check_dist:matt.shape[0]-1-i*check_dist]): check_dist += 1 else: if i*check_dist>matt.shape[0]/2: return i still_checking = False periodicities.append([i,check_dist]) return -1 print(periodicities) 
       
def generate_sum_free(initial,pattern,length): decision = format(initial,"b")[1:] repetition = format(pattern,"b")[1:] if "1" in repetition: num = 1 i = 0 list_g = [] unavailable = [] difference_counts = np.zeros((length)) while num < length: if num not in unavailable: include = False if len(decision)<=i: if repetition[(i+len(repetition)*10-len(decision))%len(repetition)]=='1': include = True else: if decision[i%len(decision)]=='1': include = True if include: list_g.append(num) for j in list_g: difference_counts[num-j] += 1 unavailable.append(j+num) i+=1 num += 1 matt = np.zeros((length)) for a in range(length): if a in list_g: matt[a] = 1 return matt,difference_counts else: return np.zeros((length)),np.zeros((length)) 
       
period = [20,10] periods_a = [] periods_b = [] difference_count_list = np.zeros((1000,period[0]*period[1])) aperiodic_i = [] for i in range(10): #print(format(i,"b")[1:]+" "+str(calc_period_entire( np.array([int(a) for a in format(i,"b")[1:]]) ))) if calc_period_entire( np.array([int(a) for a in format(i,"b")[1:]]) ) == -1: sum_free,difference_count_list[i,:] = generate_sum_free(0,i,period[0]*period[1]) print(format(i,"b")[1:]+" "+str(calc_period(sum_free))) periods_a.append([i,calc_period(sum_free)]) if periods_a[len(periods_a)-1][1] == -1: aperiodic_i.append(i) periods_b.append([i,calc_period_entire(sum_free)]) A = scatter_plot(periods_a, strokecolor='red', facecolor='red') B = scatter_plot(periods_b, strokecolor='blue', facecolor='blue') show(A) 
       
 1
 1
0 1
1 2
01 3
10 3
001 4
verbose 0 (163: primitive.py, options) WARNING: Ignoring option
'strokecolor'=red
verbose 0 (163: primitive.py, options) 
The allowed options for Scatter plot graphics primitive on 7 data points
are:
    alpha          How transparent the marker border is.                

    clip           Whether or not to clip.                              

    edgecolor      The color of the marker border.                      

    facecolor      The color of the marker face.                        

    hue            The color given as a hue.                            

    marker         What shape to plot the points. See the documentation
of plot() for the full list of markers.
    markersize     the size of the markers.                             

    rgbcolor       The color as an RGB tuple.                           

    zorder         The layer level in which to draw.                    


verbose 0 (163: primitive.py, options) WARNING: Ignoring option
'strokecolor'=red
verbose 0 (163: primitive.py, options) 
The allowed options for Scatter plot graphics primitive on 7 data points
are:
    alpha          How transparent the marker border is.                

    clip           Whether or not to clip.                              

    edgecolor      The color of the marker border.                      

    facecolor      The color of the marker face.                        

    hue            The color given as a hue.                            

    marker         What shape to plot the points. See the documentation
of plot() for the full list of markers.
    markersize     the size of the markers.                             

    rgbcolor       The color as an RGB tuple.                           

    zorder         The layer level in which to draw.                    


verbose 0 (163: primitive.py, options) WARNING: Ignoring option
'strokecolor'=red
verbose 0 (163: primitive.py, options) 
The allowed options for Scatter plot graphics primitive on 7 data points
are:
    alpha          How transparent the marker border is.                

    clip           Whether or not to clip.                              

    edgecolor      The color of the marker border.                      

    facecolor      The color of the marker face.                        

    hue            The color given as a hue.                            

    marker         What shape to plot the points. See the documentation
of plot() for the full list of markers.
    markersize     the size of the markers.                             

    rgbcolor       The color as an RGB tuple.                           

    zorder         The layer level in which to draw.                    
 1
 1
0 1
1 2
01 3
10 3
001 4
verbose 0 (163: primitive.py, options) WARNING: Ignoring option 'strokecolor'=red
verbose 0 (163: primitive.py, options) 
The allowed options for Scatter plot graphics primitive on 7 data points are:
    alpha          How transparent the marker border is.                       
    clip           Whether or not to clip.                                     
    edgecolor      The color of the marker border.                             
    facecolor      The color of the marker face.                               
    hue            The color given as a hue.                                   
    marker         What shape to plot the points. See the documentation of plot() for the full list of markers.
    markersize     the size of the markers.                                    
    rgbcolor       The color as an RGB tuple.                                  
    zorder         The layer level in which to draw.                           

verbose 0 (163: primitive.py, options) WARNING: Ignoring option 'strokecolor'=red
verbose 0 (163: primitive.py, options) 
The allowed options for Scatter plot graphics primitive on 7 data points are:
    alpha          How transparent the marker border is.                       
    clip           Whether or not to clip.                                     
    edgecolor      The color of the marker border.                             
    facecolor      The color of the marker face.                               
    hue            The color given as a hue.                                   
    marker         What shape to plot the points. See the documentation of plot() for the full list of markers.
    markersize     the size of the markers.                                    
    rgbcolor       The color as an RGB tuple.                                  
    zorder         The layer level in which to draw.                           

verbose 0 (163: primitive.py, options) WARNING: Ignoring option 'strokecolor'=red
verbose 0 (163: primitive.py, options) 
The allowed options for Scatter plot graphics primitive on 7 data points are:
    alpha          How transparent the marker border is.                       
    clip           Whether or not to clip.                                     
    edgecolor      The color of the marker border.                             
    facecolor      The color of the marker face.                               
    hue            The color given as a hue.                                   
    marker         What shape to plot the points. See the documentation of plot() for the full list of markers.
    markersize     the size of the markers.                                    
    rgbcolor       The color as an RGB tuple.                                  
    zorder         The layer level in which to draw.                           
print(aperiodic_i) 
       
[]
[]
import colorsys color_i = 0 A = list_plot([], color='black') pattern_i = 107 sum_free,difference_count = generate_sum_free(0,pattern_i,4000) 
       
lumpy = 4 A = list_plot([], color='black') color_i = 0 for eee in range(lumpy): rgb = colorsys.hsv_to_rgb(1/lumpy*eee, 1, 0.8) color_i += 1 plotty = [[i,difference_count[i]*(1.0/(1.0-float(i)/difference_count.shape[0]))] for i in range(eee,difference_count.shape[0]/2,lumpy)] list_plot(plotty, color=rgb) A = A+list_plot(plotty, color=rgb) 
       



show(A) 
       
format(107,"b")[1:] 
       
'101011'
'101011'