(popul, data, minBase = 5, maxBase = 100, stepBase = 0.1, minMult = 0.01, maxMult = 1, stepMult = 0.01)
| 52 | return dist / float(len(data)) |
| 53 | |
| 54 | def findBest(popul, data, minBase = 5, maxBase = 100, stepBase = 0.1, minMult = 0.01, maxMult = 1, stepMult = 0.01): |
| 55 | |
| 56 | # try to find best parameters |
| 57 | base = minBase |
| 58 | |
| 59 | minDist = -1 |
| 60 | bestMult = minMult |
| 61 | bestBase = base |
| 62 | |
| 63 | while base <= maxBase: |
| 64 | print "%.02f%% best mult: %f, best base: %f, best dist: %f" % (100 * (base - minBase) / (maxBase - minBase), bestMult, bestBase, minDist) |
| 65 | mult = minMult |
| 66 | |
| 67 | while mult <= maxMult: |
| 68 | approx = [] |
| 69 | |
| 70 | for p in popul: |
| 71 | approx.append(formula(p, base, mult)) |
| 72 | |
| 73 | dist = avgDistance(approx, data) |
| 74 | |
| 75 | if minDist < 0 or minDist > dist: |
| 76 | minDist = dist |
| 77 | bestBase = base |
| 78 | bestMult = mult |
| 79 | |
| 80 | mult += stepMult |
| 81 | |
| 82 | base += stepBase |
| 83 | |
| 84 | return (bestBase, bestMult) |
| 85 | |
| 86 | def process_data(steps_count, base, mult, bestFind = False, dataFlag = 0): |
| 87 | avgData = [] |
no test coverage detected