i'm a data scientist and python noob, but I seem to have found a bug with scipy.stats.percentileofscore. it may be "by design" but please bear with me.
if you have an array, you will get an upper bound of 100, but never a lower bound of 0. The lowest percentile you will get is 100/len so if I have an array of 30 items the lowest percentile I'll get is 100/30 ==> (3)
so I have a workaround to allow a zero percentile result. is my workaround valid? is there something I"m doing wrong? please suggest.
also note the following i put the numbers in the 0.0 to 1.0 range (I don't like using 0 to 100 for percentages)
stochState.kSlopePercentile = scipy.stats.percentileofscore([stochHist.kSlope for stochHist in stochState.history],stochState.kSlope) / 100.0 invHistLen= 1.0/len(stochState.history) if(stochState.kSlopePercentile < 1.0): stochState.kSlopePercentile -= invHistLen * (1-stochState.kSlopePercentile+invHistLen)
the above code subtracts up to 1/len from the percentile (more the closer the percentile is to zero)