Question: please speed up the given program, the running time should be less than 10s, where the oringinal time is more than 100s. 1 Speeding up

1 Speeding up the program Please use broadcasting or other methods to speed up the following simulation codes. You need to roughly speed it up 5 times as the minimum requirement. (Generally speaking, there are no restrictions on how to speed up the program, as long as you are dealing with the same problem illustrated by the codes below). You may want to specify size in the function np. random. randint() to get an array of random integers. import numpy as np import time \#only one bullet in the gun for n in range(num_pos): if A[n]==1 if n in pos take: num_lose +=1 break print ("TheDprobabilityDofolosing is:" num_loseum_test) print ("Time:", time, time()-start_time) print ("NumberDofatests:", num_test)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
