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)
评论列表
文章目录