code: def mean_rotor_in_chordal_metric(R, t=None):
      
      if not t:
          return np.quaternion(*(np.sum(as_float_array(R)))).normalized()
      mean = np.empty((4,), dtype=float)
      definite_integral(as_float_array(R), t, mean)
      return np.quaternion(*mean).normalized()
docs: Return rotor that is closest to all R in the least-squares sense
  
      This can be done (quasi-)analytically because of the simplicity of
      the chordal metric function.  The only approximation is the simple
      2nd-order discrete formula for the definite integral of the input
      rotor function.
  
      Note that the `t` argument is optional.  If it is present, the
      times are used to weight the corresponding integral.  If it is not
      present, a simple sum is used instead (which may be slightly
      faster).