[SciPy-dev] percentileofscore

josef.pktd@gmai... josef.pktd@gmai...
Mon Nov 17 09:31:08 CST 2008


>> The proposed patch is pretty easy to adjust to any convention.
>> Maybe percentileofscore should get a weight parameter for ties:
>> 0 for strict inequality, 1 for weak inequality,
>> 0.5 (default?) for wikipedia and -1 for mean.
>
> I prefer strings, myself. 'strict', 'weak', 'mean'.
>


How about this?
for experimentation without string arguments, see attachment

    '''
    >>> percentileofscore_gen([1,2,3,4,5,6,7,8,9,10],4) #default weight=0.5
    35.0
    >>> percentileofscore_gen([1,2,3,4,5,6,7,8,9,10],4,weight=0)
    30.0
    >>> percentileofscore_gen([1,2,3,4,5,6,7,8,9,10],4,weight=1)
    40.0

    # multiple - 2
    >>> percentileofscore_gen([1,2,3,4,4,5,6,7,8,9],4,weight=0.0)
    30.0
    >>> percentileofscore_gen([1,2,3,4,4,5,6,7,8,9],4,weight=1)
    50.0
    >>> percentileofscore_gen([1,2,3,4,4,5,6,7,8,9],4,weight=0.5)
    40.0

    # multiple - 3
    >>> percentileofscore_gen([1,2,3,4,4,4,5,6,7,8],4,weight=0.5)
    45.0
    >>> percentileofscore_gen([1,2,3,4,4,4,5,6,7,8],4,weight=0)
    30.0
    >>> percentileofscore_gen([1,2,3,4,4,4,5,6,7,8],4,weight=1)
    60.0

    # missing
    >>> percentileofscore_gen([1,2,3,5,6,7,8,9,10,11],4)
    30.0
    >>> percentileofscore_gen([1,2,3,5,6,7,8,9,10,11],4,weight=0)
    30.0
    >>> percentileofscore_gen([1,2,3,5,6,7,8,9,10,11],4,weight=1)
    30.0

    #larger numbers
    >>> percentileofscore_gen([10,20,30,40,50,60,70,80,90,100],40)
    35.0
    >>> percentileofscore_gen([10,20,30,40,50,60,70,80,90,100],40,weight=0)
    30.0
    >>> percentileofscore_gen([10,20,30,40,50,60,70,80,90,100],40,weight=1)
    40.0
    >>> percentileofscore_gen([10,20,30,40,40,40,50,60,70,80],40,weight=0.5)
    45.0
    >>> percentileofscore_gen([10,20,30,40,40,40,50,60,70,80],40,weight=0)
    30.0
    >>> percentileofscore_gen([10,20,30,40,40,40,50,60,70,80],40,weight=1)
    60.0
    >>> percentileofscore_gen([ 10,20,30,50,60,70,80,90,100,110],40,weight=0.5)
    30.0
    >>> percentileofscore_gen([ 10,20,30,50,60,70,80,90,100,110],40,weight=0)
    30.0
    >>> percentileofscore_gen([ 10,20,30,50,60,70,80,90,100,110],40,weight=1)
    30.0

    >>> percentileofscore_gen([20,80,100],80)
    50.0
    >>> (1+0.5*1)/3.0*100
    50.0
    >>> percentileofscore_gen([20,80,100],80) == (1+0.5*1)/3.0*100
    True
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: percofscore_1.py
Url: http://projects.scipy.org/pipermail/scipy-dev/attachments/20081117/8dc751e5/attachment.pl 


More information about the Scipy-dev mailing list