draw_bs_pairs.py 文件源码

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

项目:Python-Scripts-Repo-on-Data-Science 作者: qalhata 项目源码 文件源码
def draw_bs_pairs(x, y, func, size=1):
    """Perform pairs bootstrap for linear regression."""

    # Set up array of indices to sample from: inds
    inds = np.arange(len(x))
    # Initialize replicates
    bs_replicates = np.empty(size)
    # bs_intercept_reps = ____

    # Generate replicates
    for i in range(size):
        bs_inds = np.random.choice(inds, len(inds))
        bs_x, bs_y = x[bs_inds], y[bs_inds]
        bs_replicates[i] = func(bs_x, bs_y)
        # bs_slope_reps[i], bs_intercept_reps[i] = np.polyfit(bs_x, bs_y, 1)

    return bs_replicates
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号