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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started