Question
Let X be a time series of 0's and 1's indicating the outcome of each trial (0 is failure, 1 is success). Write a function
Let X be a time series of 0's and 1's indicating the outcome of each trial (0 is failure, 1 is success). Write a function relative_freq(arr) where the input arr is a 1-d array of 0's and 1's. The function returns a 1-d array of the same size, of which each element is the relative frequency of success at the current time point. For example, X = [0,0,1,0,0,1,1,0,0,1] shows the result of 10 trials at time points 1,2,3,...,10. The function will find the relative frequency of success at each time point, i.e.p^=[0/1,0/2,1/3,1/4,1/5,2/6,3/7,3/8,3/9,4/10] (Hint: use cumsum.)
Write the code in Python and show output.
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