Question: Use the code given below to create a sequence of n Bernoulli trials with success probability p per trial. A string of consecutive successes is
Use the code given below to create a sequence of n Bernoulli trials with success probability p per trial. A string of consecutive successes is known as a success run. Write a function (named "count_runs" that takes the sequence of Bernoulli trials as its input and returns the counts for runs of length k for each k observed in a dictionary.(write in python program)
Example: n=13 Bernoulli trials [0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0] were simulated with p=0.5. There are 3 runs of length k=1, and 1 run of length k=2. Hence, your code should return {1:3, 2:1}.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
