

def _calc_g(cosang, stiffness=4, num_lterms=50):
    'Calculate spherical spline g function between points on a sphere.\n\n    Parameters\n    ----------\n    cosang : array-like of float, shape(n_channels, n_channels)\n        cosine of angles between pairs of points on a spherical surface. This\n        is equivalent to the dot product of unit vectors.\n    stiffness : float\n        stiffness of the spline.\n    num_lterms : int\n        number of Legendre terms to evaluate.\n\n    Returns\n    -------\n    G : np.ndrarray of float, shape(n_channels, n_channels)\n        The G matrix.\n    '
    factors = [(((2 * n) + 1) / ((((n ** stiffness) * ((n + 1) ** stiffness)) * 4) * np.pi)) for n in range(1, (num_lterms + 1))]
    return legval(cosang, ([0] + factors))

dataset/ETHPy150Open mne-tools/mne-python/mne/channels/interpolation.py _calc_g/original