run_sim 함수를 nsim 번 실행하고 매개 변수 N, D, p로 실행하는 collect_sims (nsim, N, D, p = 0.5, nmax = 10000) 함수를 작성하고 길이가 nmax 인 numpy 배열을 반환합니다. 시뮬레이션이 지정된 수의 단계를 중단 한 횟수를 제공합니다. 예를 들어, nsim이 8이고 run_sim의 연속 실행이 3,4,4,3,6,5,4,4를 준다고 가정합니다. 당신은파이썬 주사위 결과 수
def collect_sims(nsim, N, D, p=0.5, nmax=10000):
run_sim(N=20, D=6, p=0.5, itmax=5000)
onecount = 0
twocount = 0
threecount = 0
fourcount = 0
fivecount = 0
sixcount = 0
for k in range (n):
if D == 1:
onecount += 1
if D == 2:
twocount += 1
if D == 3:
threecount += 1
if D == 4:
fourcount += 1
if D == 5:
fivecount += 1
if D == 6:
sixcount += 1
return(k)
print(onecount, "1",twocount,"2",threecount,"3",fourcount,"4",fivecount,"5",sixcount,"6")
그것은 내 6 개 변수 내가 어떻게 정의 할 수 있습니다, 정의되어 있지 않은 등, twocount, onecount 말한다 "... 두 3S, 네 4S, 일 5 일 6, 제로기를 제로 8S"로 이것을 표로 것 그들? 또한 코드를 수정하려면 어떻게해야합니까?