comparison pymedcouple @ 12:c81f6d263897

Spaces around plus and minus
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Fri, 16 Jan 2015 09:25:59 -0500
parents 4c7d7ff28a0e
children 077261db7a58
comparison
equal deleted inserted replaced
11:4c7d7ff28a0e 12:c81f6d263897
151 L = [0]*n_plus 151 L = [0]*n_plus
152 R = [n_minus - 1]*n_plus 152 R = [n_minus - 1]*n_plus
153 153
154 Ltot = 0 154 Ltot = 0
155 Rtot = n_minus*n_plus 155 Rtot = n_minus*n_plus
156 medc_idx = (Rtot-1)//2 156 medc_idx = (Rtot - 1)//2
157 157
158 # kth pair algorithm (Johnson & Mizoguchi) 158 # kth pair algorithm (Johnson & Mizoguchi)
159 while Rtot - Ltot > n_plus: 159 while Rtot - Ltot > n_plus:
160 160
161 # First, compute the median inside the given bounds 161 # First, compute the median inside the given bounds
175 175
176 j = 0 176 j = 0
177 for i in xrange(n_plus - 1, -1, -1): 177 for i in xrange(n_plus - 1, -1, -1):
178 while j < n_minus - 1 and h_kern(i, j) - Am > Am_eps: 178 while j < n_minus - 1 and h_kern(i, j) - Am > Am_eps:
179 j += 1 179 j += 1
180 P.append(j-1) 180 P.append(j - 1)
181 181
182 P.reverse() 182 P.reverse()
183 183
184 j = n_minus - 1 184 j = n_minus - 1
185 for i in xrange(0, n_plus): 185 for i in xrange(0, n_plus):
186 while j >= 0 and h_kern(i, j) - Am < -Am_eps: 186 while j >= 0 and h_kern(i, j) - Am < -Am_eps:
187 j -= 1 187 j -= 1
188 Q.append(j+1) 188 Q.append(j + 1)
189 189
190 # Check on which side of those bounds the desired median of 190 # Check on which side of those bounds the desired median of
191 # the whole matrix may be. 191 # the whole matrix may be.
192 sumP = sum(P) + len(P) 192 sumP = sum(P) + len(P)
193 sumQ = sum(Q) 193 sumQ = sum(Q)