Author: tlinnet Date: Sat May 10 08:43:20 2014 New Revision: 23143 URL: http://svn.gna.org/viewcvs/relax?rev=23143&view=rev Log: Reverted r23140 as this violated the license of http://code.activestate.com. The recipe, was a function to compute the percentile of range of values. This is because that numpy.percentile is first introduced in 1.6? The recipe was from: http://code.activestate.com/recipes/511478-finding-the-percentile-of-the-values/. The command used was: svn merge -r23140:23139 . ..... Added mathematics functions to lib/mathematics.py to calculate percentile. This is because percentile is only available in numpy 1.9. task #7792: (https://gna.org/task/?7792) Make the dx.map write suggest chi surface values. Modified: trunk/lib/mathematics.py ..... Modified: trunk/lib/mathematics.py Modified: trunk/lib/mathematics.py URL: http://svn.gna.org/viewcvs/relax/trunk/lib/mathematics.py?rev=23143&r1=23142&r2=23143&view=diff ============================================================================== --- trunk/lib/mathematics.py (original) +++ trunk/lib/mathematics.py Sat May 10 08:43:20 2014 @@ -23,7 +23,7 @@ """Module for basic mathematical operations.""" # Python module imports. -from math import ceil, floor, log10 +from math import ceil, log10 def order_of_magnitude(value): @@ -56,30 +56,3 @@ # Calculate and return the value. return 10**(order_of_magnitude(value)) - - -def percentile(N, percent, key=lambda x:x): - """ - Find the percentile of a list of values. - - @parameter N: Array of values. - @type N: numpy float array - @parameter percent: Float value from 0.0 to 1.0. - @type percent: float - @parameter key: Optional key function to compute value from each element of N. - @type key: lambda function - - @return: The percentile of the values - """ - - # Sort N. - N.sort() - - k = (len(N)-1) * percent - f = floor(k) - c = ceil(k) - if f == c: - return key(N[int(k)]) - d0 = key(N[int(f)]) * (c-k) - d1 = key(N[int(c)]) * (k-f) - return d0+d1