def percentiles_to_weights(qs, vals, length):
 if (length == 0):
  return ()
 diff = np.ediff1d(qs, 0.0, 0.0)
 weights = ((0.5 * length) * (diff[1:] + diff[:(-1)]))
 return (vals.tolist(), weights.tolist())

def percentiles_to_weights ( qs , vals , length ) : if ( length == 0 ) : return ( ) diff = np . ediff1d ( qs , 0.0 , 0.0 ) weights = ( ( 0.5 * length ) * ( diff [ 1 : ] + diff [ : ( - 1 ) ] ) ) return ( vals . tolist ( ) , weights . tolist ( ) )
weigh percentile values by length and the difference between percentiles .