def _psturng(q, r, v):
 if (q < 0.0):
  raise ValueError('q should be >= 0')
 opt_func = (lambda p, r, v: abs((_qsturng(p, r, v) - q)))
 if (v == 1):
  if (q < _qsturng(0.9, r, 1)):
   return 0.1
  elif (q > _qsturng(0.999, r, 1)):
   return 0.001
  return (1.0 - fminbound(opt_func, 0.9, 0.999, args=(r, v)))
 else:
  if (q < _qsturng(0.1, r, v)):
   return 0.9
  elif (q > _qsturng(0.999, r, v)):
   return 0.001
  return (1.0 - fminbound(opt_func, 0.1, 0.999, args=(r, v)))

def _psturng ( q , r , v ) : if ( q < 0.0 ) : raise ValueError ( 'q should be >= 0' ) opt_func = ( lambda p , r , v : abs ( ( _qsturng ( p , r , v ) - q ) ) ) if ( v == 1 ) : if ( q < _qsturng ( 0.9 , r , 1 ) ) : return 0.1 elif ( q > _qsturng ( 0.999 , r , 1 ) ) : return 0.001 return ( 1.0 - fminbound ( opt_func , 0.9 , 0.999 , args = ( r , v ) ) ) else : if ( q < _qsturng ( 0.1 , r , v ) ) : return 0.9 elif ( q > _qsturng ( 0.999 , r , v ) ) : return 0.001 return ( 1.0 - fminbound ( opt_func , 0.1 , 0.999 , args = ( r , v ) ) )
scalar version of psturng .