I use this function to calculate percentile from here:
import numpy as np
a = [12, 3, 45, 0, 45, 47, 109, 1, 0, 3]
np.percentile(a, 25)
But I get this error :
AttributeError: 'module' object has no attribute 'percentile'
I also tried
import numpy.percentile as np
but it didn't I got the same error.
my numpy version is 1.3.0 I tried to upgrade but it seems like it won't I used : [sudo pip install --upgrade scipy][2]
but I found that there's no upgrade.
my ubuntu version 9.10
my python version is : 2.6.4
i also tried to go arround the numpy.percentile module and I found this here:
>>> def percentile(N, P):
... n = int(round(P * len(N) + 0.5))
... if n > 1:
... return N[n-2]
... else:
... return 0
...
>>> a = [1, 23, 5, 45, 676, 2, 0, 4,3]
>>> a = sorted(a)
>>> a
[0, 1, 2, 3, 5, 4, 23, 45, 676]
#When I call the function using
>>> percentile(a,0.5)
3
but when I tried to find 0.5 percentile
manually I found 5
Can anyone help explain to me why this is happening in any of those cases?