I'm working on a code that takes a list of points from a text file and an input m, to create a frequency distribution of points where m is the number of bins.
discret = open('testingdisc.txt','w+')
x = []
y = []
m = int(input("Input number of bins:"))
for line in open('xypoints.txt','r'):
lines = line.split(",")
x.append(float(lines[0]))
y.append(float(lines[1]))
H = np.histogram2d(x, y, bins= m)
list = re.sub('( \[|\[|\])', '', str(H[0].astype(int)))
print(list , file = discret)
The code gives me the output I'm looking for when m < 30:
1 0 0 1 0 0 0 0 0 1
0 1 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
1 0 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
1 0 1 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0
However, the number of bins that I'm after is going to be more than 40 which gives me the following output:
1 0 0 ... 0 0 1
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
...
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
Is there a limit to the number of bins that could be used?