parameters: (networks, min_accuracy, max_accuracy)
return_statement: return (float(lat), float(lon), float(accuracy), float(score))
docstring: Calculate the aggregate position of the user inside the given
      cluster of networks.
  
      Return the position, an accuracy estimate and a combined score.
      The accuracy is bounded by the min_accuracy and max_accuracy.
docstring_summary: Calculate the aggregate position of the user inside the given
      cluster of networks.
docstring_tokens: Calculate the aggregate position of the user inside the given cluster of networks .
function: def aggregate_cell_position(networks, min_accuracy, max_accuracy):
      """
      Calculate the aggregate position of the user inside the given
      cluster of networks.
  
      Return the position, an accuracy estimate and a combined score.
      The accuracy is bounded by the min_accuracy and max_accuracy.
      """
      if len(networks) == 1:
          lat = networks[0]["lat"]
          lon = networks[0]["lon"]
          radius = min(max(networks[0]["radius"], min_accuracy), max_accuracy)
          score = networks[0]["score"]
          return (float(lat), float(lon), float(radius), float(score))
  
      points = numpy.array(
          [(net["lat"], net["lon"]) for net in networks], dtype=numpy.double
      )
  
      weights = numpy.array(
          [
              net["score"]
              * min(math.sqrt(2000.0 / net["age"]), 1.0)
              / math.pow(net["signalStrength"], 2)
              for net in networks
          ],
          dtype=numpy.double,
      )
  
      lat, lon = numpy.average(points, axis=0, weights=weights)
      score = networks["score"].sum()
  
      # Guess the accuracy as the 95th percentile of the distances
      # from the lat/lon to the positions of all networks.
      distances = numpy.array(
          [distance(lat, lon, net["lat"], net["lon"]) for net in networks],
          dtype=numpy.double,
      )
      accuracy = min(max(numpy.percentile(distances, 95), min_accuracy), max_accuracy)
  
      return (float(lat), float(lon), float(accuracy), float(score))
function_tokens: def aggregate_cell_position ( networks , min_accuracy , max_accuracy ) : if len ( networks ) == 1 : lat = networks [ 0 ] [ "lat" ] lon = networks [ 0 ] [ "lon" ] radius = min ( max ( networks [ 0 ] [ "radius" ] , min_accuracy ) , max_accuracy ) score = networks [ 0 ] [ "score" ] return ( float ( lat ) , float ( lon ) , float ( radius ) , float ( score ) ) points = numpy . array ( [ ( net [ "lat" ] , net [ "lon" ] ) for net in networks ] , dtype = numpy . double ) weights = numpy . array ( [ net [ "score" ] * min ( math . sqrt ( 2000.0 / net [ "age" ] ) , 1.0 ) / math . pow ( net [ "signalStrength" ] , 2 ) for net in networks ] , dtype = numpy . double , ) lat , lon = numpy . average ( points , axis = 0 , weights = weights ) score = networks [ "score" ] . sum ( ) # Guess the accuracy as the 95th percentile of the distances # from the lat/lon to the positions of all networks. distances = numpy . array ( [ distance ( lat , lon , net [ "lat" ] , net [ "lon" ] ) for net in networks ] , dtype = numpy . double , ) accuracy = min ( max ( numpy . percentile ( distances , 95 ) , min_accuracy ) , max_accuracy ) return ( float ( lat ) , float ( lon ) , float ( accuracy ) , float ( score ) )