arithmeticbilliard

Draw arithmetic billiards
git clone https://git.tronto.net/arithmeticbilliard
Download | Log | Files | Refs | README | LICENSE

multiplicity_stats.py (1537B)


      1 import billiard3d
      2 import sys
      3 
      4 def get_stats(i, j, k, mult):
      5 	for r1 in range(i+1):
      6 		for r2 in range(j+1):
      7 			for r3 in range(k+1):
      8 				d = billiard3d.get_multiplicities(3, [i, j, k], [r1, r2, r3])
      9 				for key in d:
     10 					mult[d[key]] += 1
     11 
     12 def print_stats(N):
     13 	mult = [0] * 10
     14 	for i in range(1, N+1):
     15 		for j in range(i, N+1):
     16 			for k in range(j, N+1):
     17 				get_stats(i, j, k, mult)
     18 
     19 	print("Statistics for paths with 0 < a <= b <= c <= {0}".format(N))
     20 	print("Considering all paths starting from any possible point")
     21 	for i in range(1, 10):
     22 		if mult[i] != 0:
     23 			print("Multiplicity {0}: {1} points".format(i, mult[i]))
     24 	print("There are no points of positive multiplicity different from those listed above")
     25 
     26 def print_stats_single(a, b, c):
     27 	mult = [0] * 10
     28 	get_stats(a, b, c, mult)
     29 
     30 	print("Statistics for paths with a={0}, b={1} and c={2}".format(a, b, c))
     31 	print("Considering all paths starting from any possible point")
     32 	for i in range(1, 10):
     33 		if mult[i] != 0:
     34 			print("Multiplicity {0}: {1} points".format(i, mult[i]))
     35 	print("There are no points of positive multiplicity different from those listed above")
     36 
     37 if len(sys.argv) == 2:
     38 	N = int(sys.argv[1])
     39 	print_stats(N)
     40 elif len(sys.argv) == 4:
     41 	a, b, c = int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3])
     42 	print_stats_single(a, b, c)
     43 else:	
     44 	print("Use one of the following options:")
     45 	print("\tpython multiplicity_stats.py N\t\t # For all possible sizes up to N")
     46 	print("\tpython multiplicity_stats.py a b c\t # For all starting points for the single 3d box (a,b,c)")