Hi,

Could you revert this?  Because of licencing, we unfortunately cannot
use this code from
http://code.activestate.com/recipes/511478-finding-the-percentile-of-the-values/.
 Also, a percentile() function would go into lib.statistics rather
than lib.mathematics.

Cheers,

Edward


On 9 May 2014 18:57,  <[email protected]> wrote:
> Author: tlinnet
> Date: Fri May  9 18:57:38 2014
> New Revision: 23140
>
> URL: http://svn.gna.org/viewcvs/relax?rev=23140&view=rev
> Log:
> 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
> URL: 
> http://svn.gna.org/viewcvs/relax/trunk/lib/mathematics.py?rev=23140&r1=23139&r2=23140&view=diff
> ==============================================================================
> --- trunk/lib/mathematics.py    (original)
> +++ trunk/lib/mathematics.py    Fri May  9 18:57:38 2014
> @@ -23,7 +23,7 @@
>  """Module for basic mathematical operations."""
>
>  # Python module imports.
> -from math import ceil, log10
> +from math import ceil, floor, log10
>
>
>  def order_of_magnitude(value):
> @@ -56,3 +56,30 @@
>
>      # 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
>
>
> _______________________________________________
> relax (http://www.nmr-relax.com)
>
> This is the relax-commits mailing list
> [email protected]
>
> To unsubscribe from this list, get a password
> reminder, or change your subscription options,
> visit the list information page at
> https://mail.gna.org/listinfo/relax-commits

_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-devel mailing list
[email protected]

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-devel

Reply via email to