抛10万次硬币,连续出现10次正面的情况有多少次呢?貌似老师喜欢布置这样的作业呀
import numpy as np # numpy 基础数据包 需要安装 pip install numpy
from collections import Counter # collections 内建统计接口
result = [] #result 预设结果集
nsteps = 100000 + 1 #抛币次数如
# 用np.random模块一次性随机产生n+1个“掷硬币”结果(即两个数中任选一个),将其分别设置为1或-1 ,模拟抛硬币。
draws = np.random.randint(0,2,size