I made a program for a chi square test, which works but was too slow, so I wanted to implement multiprossesing, but it didn't work for me (on a Windows machine). My CPU utilization goes to 100% and starts to fluctuate but i don't get further output. I tried it on a Linux machine and it worked without any problems. I found the problem online but not the solution.
def CalcMT(DIS):
pool = mp.Pool(4)
DIS = pool.map(CreateDistribution,[i for i in range(len(methods))])
return DIS
if __name__ == "__main__":
print("Start Computing")
DIS = CalcMT(DIS)
CHI=[ChiCalc(DIS[i]) for i in range(len(methods))]
Output(DIS,CHI)
Plot(DIS,CHI)
exit()
This is the relevant part of the code. CreateDistribution gives back an array and DIS should be a 2D array.
def CreateDistribution(type):
AA = [0 for i in range(runrange)]
if type==0:
for i in range(sampals):
x = rn.randint(0, len(AA)-1)
AA[x] = AA[x]+1
return AA
It's the same for the other types, just a different random number generator.