Return vectors uniformly picked on the unit sphere.
    Vectors are in a polar representation.

    Parameters
    ----------
    d: float
        The number of dimensions of the space in which the sphere lives.
    n: integer
        Number of samples to pick.

    Returns
    -------
    r: array, shape (n, d)
        Sample vectors.

def sphere_pick_polar(d, n=1, rng=None):
    """Return vectors uniformly picked on the unit sphere.
    Vectors are in a polar representation.

    Parameters
    ----------
    d: float
        The number of dimensions of the space in which the sphere lives.
    n: integer
        Number of samples to pick.

    Returns
    -------
    r: array, shape (n, d)
        Sample vectors.
    """
    if rng is None:
        rng = np.random
    a = np.empty([n, d])
    if d == 1:
        a[:, 0] = rng.randint(2, size=n) * 2 - 1
    elif d == 2:
        a[:, 0] = 1.0
        a[:, 1] = rng.uniform(-np.pi, +np.pi, n)
    elif d == 3:
        u, v = rng.uniform(0.0, 1.0, (2, n))
        a[:, 0] = 1.0
        a[:, 1] = np.arccos(2.0 * v - 1.0)
        a[:, 2] = 2.0 * np.pi * u
    else:
        raise Exception('Invalid vector for polar representation')
    return a