# biopython/biopython

Whitespace fixes (PEP8 E225, E231).

• Loading branch information...
1 parent 1087de6 commit 5ff0fe1075b19750f166a5de13dc5fe8d5b9559b cbrueffer committed Dec 6, 2012
Showing with 18 additions and 18 deletions.
1. +18 −18 Bio/Statistics/lowess.py
 @@ -31,7 +31,7 @@ from numpy import median -def lowess(x, y, f=2./3., iter=3): +def lowess(x, y, f=2. / 3., iter=3): """lowess(x, y, f=2./3., iter=3) -> yest Lowess smoother: Robust locally weighted regression. @@ -64,32 +64,32 @@ def lowess(x, y, f=2./3., iter=3): [4.85, ..., 84.98] """ n = len(x) - r = int(numpy.ceil(f*n)) - h = [numpy.sort(abs(x-x[i]))[r] for i in range(n)] - w = numpy.clip(abs(([x]-numpy.transpose([x]))/h),0.0,1.0) - w = 1-w*w*w - w = w*w*w + r = int(numpy.ceil(f * n)) + h = [numpy.sort(abs(x - x[i]))[r] for i in range(n)] + w = numpy.clip(abs(([x] - numpy.transpose([x])) / h), 0.0, 1.0) + w = 1 - w * w * w + w = w * w * w yest = numpy.zeros(n) delta = numpy.ones(n) for iteration in range(iter): for i in xrange(n): - weights = delta * w[:,i] + weights = delta * w[:, i] weights_mul_x = weights * x - b1 = numpy.dot(weights,y) - b2 = numpy.dot(weights_mul_x,y) + b1 = numpy.dot(weights, y) + b2 = numpy.dot(weights_mul_x, y) A11 = sum(weights) A12 = sum(weights_mul_x) A21 = A12 - A22 = numpy.dot(weights_mul_x,x) - determinant = A11*A22 - A12*A21 - beta1 = (A22*b1-A12*b2) / determinant - beta2 = (A11*b2-A21*b1) / determinant - yest[i] = beta1 + beta2*x[i] - residuals = y-yest + A22 = numpy.dot(weights_mul_x, x) + determinant = A11 * A22 - A12 * A21 + beta1 = (A22 * b1 - A12 * b2) / determinant + beta2 = (A11 * b2 - A21 * b1) / determinant + yest[i] = beta1 + beta2 * x[i] + residuals = y - yest s = median(abs(residuals)) - delta[:] = numpy.clip(residuals/(6*s),-1,1) - delta[:] = 1-delta*delta - delta[:] = delta*delta + delta[:] = numpy.clip(residuals / (6 * s), -1, 1) + delta[:] = 1 - delta * delta + delta[:] = delta * delta return yest

#### 0 comments on commit `5ff0fe1`

Please sign in to comment.