def stdev(values):
 if ((not values) or (len(values) < 2)):
  return None
 key = (values[0], values[(-1)], len(values))
 if (kb.get('cache') and (key in kb.cache.stdev)):
  retVal = kb.cache.stdev[key]
 else:
  avg = average(values)
  _ = reduce((lambda x, y: (x + pow(((y or 0) - avg), 2))), values, 0.0)
  retVal = sqrt((_ / (len(values) - 1)))
  if kb.get('cache'):
   kb.cache.stdev[key] = retVal
 return retVal

def stdev ( values ) : if ( ( not values ) or ( len ( values ) < 2 ) ) : return None key = ( values [ 0 ] , values [ ( - 1 ) ] , len ( values ) ) if ( kb . get ( 'cache' ) and ( key in kb . cache . stdev ) ) : retVal = kb . cache . stdev [ key ] else : avg = average ( values ) _ = reduce ( ( lambda x , y : ( x + pow ( ( ( y or 0 ) - avg ) , 2 ) ) ) , values , 0.0 ) retVal = sqrt ( ( _ / ( len ( values ) - 1 ) ) ) if kb . get ( 'cache' ) : kb . cache . stdev [ key ] = retVal return retVal
return the square root of the sample variance .