def scoreatpercentile(data,per,axis=<NUM_LIT:0>):
a = np.sort(data,axis=axis)<EOL>idx = per/<NUM_LIT> * (data.shape[axis]-<NUM_LIT:1>)<EOL>if (idx % <NUM_LIT:1> == <NUM_LIT:0>):<EOL><INDENT>return a[[slice(None) if ii != axis else idx for ii in range(a.ndim)]]<EOL><DEDENT>else:<EOL><INDENT>lowerweight = <NUM_LIT:1>-(idx % <NUM_LIT:1>)<EOL>upperweight = (idx % <NUM_LIT:1>)<EOL>idx = int(np.floor(idx))<EOL>return lowerweight * a[[slice(None) if ii != axis else idx for ii in range(a.ndim)]]+ upperweight * a[[slice(None) if ii != axis else idx+<NUM_LIT:1> for ii in range(a.ndim)]]<EOL><DEDENT>
like the function in scipy.stats but with an axis argument and works on arrays