code: def radius_of_gyration(positions, user):
      
      d = Counter(p._get_location(user) for p in positions
                  if p._get_location(user) is not None)
      sum_weights = sum(d.values())
      positions = list(d.keys())  # Unique positions
  
      if len(positions) == 0:
          return None
  
      barycenter = [0, 0]
      for pos, t in d.items():
          barycenter[0] += pos[0] * t
          barycenter[1] += pos[1] * t
  
      barycenter[0] /= sum_weights
      barycenter[1] /= sum_weights
  
      r = 0.
      for pos, t in d.items():
          r += float(t) / sum_weights * \
              great_circle_distance(barycenter, pos) ** 2
      return math.sqrt(r)
docs: Returns the radius of gyration, the *equivalent distance* of the mass from
      the center of gravity, for all visited places. [GON2008]_
  
      References
      ----------
      .. [GON2008] Gonzalez, M. C., Hidalgo, C. A., & Barabasi, A. L. (2008).
          Understanding individual human mobility patterns. Nature, 453(7196),
          779-782.