Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In [ 8 5 ] : import math import random import numpy as n p from scipy.stats import binom from scipy.stats import norm from random

In [85]: import math
import random
import numpy as np
from scipy.stats import binom
from scipy.stats import norm
from random import shuffle
success_count =0
num_simulations =10000
for i in range(num_simulations):
boxes = random. sample(range(1,11),10)
found_count =0
for j in range (10):
current_box = boxes j
if current_box ==j+1 :
found_count +=1
else:
for k in range (4):
current_box = boxes [ current_box-1]
if current_box ==j+1 :
found count +=1
break
if found_count ==10 :
success_count +=1
break
prob_of_success = success_count / num_simulations
print (prob of success)
Code gives assertion error, what can be fixed? Thank you
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Domain Transfer Learning With 3q Data Processing

Authors: Ahmed Atif Hussain

1st Edition

B0CQS1NSHF, 979-8869061805

More Books

Students also viewed these Databases questions