no_numba.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:dc_stat_think 作者: justinbois 项目源码 文件源码
def draw_bs_pairs_linreg(x, y, size=1):
    """
    Perform pairs bootstrap for linear regression.

    Parameters
    ----------
    x : array_like
        x-values of data.
    y : array_like
        y-values of data.
    size : int, default 1
        Number of pairs bootstrap replicates to draw.

    Returns
    -------
    slope_reps : ndarray
        Pairs bootstrap replicates of the slope.
    intercept_reps : ndarray
        Pairs bootstrap replicates of the intercept.

    Notes
    -----
    .. Entries where either `x` or `y` has a nan are ignored.
    .. It is possible that a pairs bootstrap sample has the
       same pair over and over again. In this case, a linear
       regression cannot be computed. The pairs bootstrap
       replicate in this instance is NaN.
    """
    x, y = _convert_two_data(x, y, inf_ok=False, min_len=2)

    if np.isclose(x, y).all():
        raise RuntimeError('All x and y values are equal, cannot do regression')

    return _draw_bs_pairs_linreg(x, y, size=size)


# @numba.jit(nopython=True)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号