def METHOD_NAME(points, prior=None):
    """
    Fit an n-sphere to a set of points using least squares.
    Parameters
    ------------
    points : (n, d) float
      Points in space
    prior : (d,) float
      Best guess for center of nsphere
    Returns
    ---------
    center : (d,) float
      Location of center
    radius : float
      Mean radius across circle
    error : float
      Peak to peak value of deviation from mean radius
    """
    # make sure points are numpy array
    points = np.asanyarray(points, dtype=np.float64)
    # create ones so we can dot instead of using slower sum
    ones = np.ones(points.shape[1])
    def residuals(center):
        # do the axis sum with a dot
        # this gets called a LOT so worth optimizing
        radii_sq = np.dot((points - center) ** 2, ones)
        # residuals are difference between mean
        # use our sum mean vs .mean() as it is slightly faster
        return radii_sq - (radii_sq.sum() / len(radii_sq))
    if prior is None:
        guess = points.mean(axis=0)
    else:
        guess = np.asanyarray(prior)
    center_result, return_code = leastsq(residuals,
                                         guess,
                                         xtol=1e-8)
    if return_code not in [1, 2, 3, 4]:
        raise ValueError('Least square fit failed!')
    radii = util.row_norm(points - center_result)
    radius = radii.mean()
    error = radii.ptp()
    return center_result, radius, error