caluclating median distance

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Oct 29 04:52:30 CET 2007


En Sun, 28 Oct 2007 11:13:39 -0300, Beema shafreen  
<beema.shafreen at gmail.com> escribi�:

> 10000175    10000234    43    A_16_P03652190
> 10000277    10000336    387    A_16_P41582022
> 10000723    10000782    98    A_16_P03652191
>
> how to calculate the median spacing of an data in the file basically
> focusing on the third column of an file. say for example the median  
> spacing
> is to be 635. how do we programtically calculate the median spacing and  
> sort
> the file according to the third column's median spacing.
> hope median we calculate  using (N+1)/2

I don't understand exactly what you want. To compute the median, the  
easiest and obvious way is to sort the data first and choose the middle  
element. For large sets, there are more efficient ways; see this recipe in  
the Python Cookbook:  
<http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/269554>

-- 
Gabriel Genellina




More information about the Python-list mailing list