Thanks to visit codestin.com
Credit goes to github.com

Skip to content

scoreatprecentile return wrong values when used on array with NaNs (Trac #1653) #2178

@scipy-gitbot

Description

@scipy-gitbot

Original ticket http://projects.scipy.org/scipy/ticket/1653 on 2012-05-02 by trac user imrisofer, assigned to unknown.

the output of scoreatprecentile changed according to the number of Not-a-Numbers in the array

#create arrays
#all of the arrays have the same precentiles
a1 = array([1,2,3,4])
a2 = array([1,2,3,4,nan])
a3 = array([1,2,3,4,nan,nan])

#put all arrays in one list
l = [a1, a2, a3]

#check precentiles of each array
for i in range(3):
    print "array with %d NaNs" %(i)
    print "q25: ", scoreatpercentile(l[i], 25)
    print "q50: ", scoreatpercentile(l[i], 50)
    print "q75: ", scoreatpercentile(l[i], 75)
    print

output:

array with 0 NaNs
q25:  1.75
q50:  2.5
q75:  3.25

array with 1 NaNs
q25:  2.0
q50:  3.0
q75:  4.0

array with 2 NaNs
q25:  2.25
q50:  3.5
q75:  nan

Metadata

Metadata

Assignees

No one assigned

    Labels

    Migrated from TracdefectA clear bug or issue that prevents SciPy from being installed or used as expectedscipy.stats

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions