Deming's funnel: Difference between revisions
Content deleted Content added
+ D entry |
→{{header|Python}}: refactor funnel so it only does one list |
||
Line 145: | Line 145: | ||
0.939, -0.411, 0.341, -0.411, 0.106, 0.224, -0.947, -1.424, -0.542, -1.032] |
0.939, -0.411, 0.341, -0.411, 0.106, 0.224, -0.947, -1.424, -0.542, -1.032] |
||
def funnel(dxs |
def funnel(dxs, rule): |
||
x |
x, rxs = 0, [] |
||
for dx |
for dx in dxs: |
||
rxs.append(x + dx) |
|||
x |
x = rule(x, dx) |
||
return rxs |
|||
rys.append(ry) |
|||
return rxs, rys |
|||
def mean(xs): return sum(xs) / len(xs) |
def mean(xs): return sum(xs) / len(xs) |
||
Line 161: | Line 159: | ||
def experiment(label, rule): |
def experiment(label, rule): |
||
rxs, rys = funnel(dxs, dys, rule) |
rxs, rys = funnel(dxs, rule), funnel(dys, rule) |
||
print label |
print label |
||
print 'Mean x, y : %.4f, %.4f' % (mean(rxs), mean(rys)) |
print 'Mean x, y : %.4f, %.4f' % (mean(rxs), mean(rys)) |