Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def calculateHistogram(nbins,data):
- step = 1/float(nbins)
- hist = [0 for i in range(0,nbins)]
- for sample in data:
- for i in range(0,nbins):
- left = i*step
- right = (i+1)*step
- if i == nbins-1:
- if sample >= left and sample <= right:
- hist[i] = hist[i]+1
- else:
- if sample >= left and sample < right:
- hist[i] = hist[i]+1
- for i in range(0,len(hist)):
- hist[i] = hist[i] / float(len(data))
- return hist
- def calculateSTA2(wormPatches,nbins2):
- out = open("d:\out.txt","w")
- rows = len(wormPatches)
- cols = len(wormPatches[0])
- sta2 = [[] for i in range(0,rows)]
- for j in range(0,cols):
- data = []
- for i in range(0,rows):
- data.append(wormPatches[i][j])
- hist = calculateHistogram(nbins2,data)
- sta2[i].extend(hist)
- for l in sta2:
- line = ""
- for e in l:
- line = line + ", " + str(e)
- line = line + "\n"
- out.write(line)
- out.flush()
- out.close()
Add Comment
Please, Sign In to add comment