dc_stat_think.py 文件源码

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

项目:dc_stat_think 作者: justinbois 项目源码 文件源码
def frac_yay_dems(dems, reps):
    """
    Compute fraction of yay votes from Democrats. This function is
    specific to exercises in Statistical Thinking in Python Part I.
    It is only included here for completeness.

    Parameters
    ----------
    dems : array_like, dtype bool
        Votes for democrats, True for yay vote, False for nay.
    reps : ignored
        Ignored; was only needed to specific application in permutation
        test in Statistical Thinking I.

    Returns
    -------
    output : float
        Fraction of Democrates who voted yay.
    """
    if dems.dtype != bool:
        raise RuntimeError('`dems` must be array of bools.')

    return np.sum(dems) / len(dems)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号