[Scipy-tickets] [SciPy] #724: distance function, som and co

SciPy scipy-tickets@scipy....
Sun Aug 24 01:29:27 CDT 2008


#724: distance function, som and co
---------------------------+------------------------------------------------
 Reporter:  cdavid         |        Owner:  somebody
     Type:  task           |       Status:  new     
 Priority:  high           |    Milestone:  0.7.0   
Component:  scipy.cluster  |      Version:          
 Severity:  normal         |   Resolution:          
 Keywords:                 |  
---------------------------+------------------------------------------------
Comment (by ryip):

 4. Single-pass in python (don't create all codebook-v up-front)
 {{{
 def euclid(u, v):
     return sum((u-v)**2, axis=-1)

 def vq(obs, cbook, norm = euclid):
     matches = []
     for v in obs:
         mindex = 0; min = norm(cbook[0],v)
         for i,u in enumerate(cbook):
             d=norm(u, v)
             if d < min:
                 mindex = i; min = d
         matches.append(mindex)
     return matches
 }}}

 Using the same Macbook Pro hardware, I get the below timings:[[BR]]
     2. 10 loops, best of 3: 4.76 s per loop[[BR]]
     3. 10 loops, best of 3: 3.89 s per loop[[BR]]
     4. 10 loops, best of 3: 2.54 s per loop (16 times slower than C)
 I still have yet to time test 1 myself.

-- 
Ticket URL: <http://scipy.org/scipy/scipy/ticket/724#comment:2>
SciPy <http://www.scipy.org/>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list