Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is a Python problem. Please solve it without using list. Problem 5 - streaks.py: Winning streaks? The debate on whether the random walk model
This is a Python problem.
Please solve it without using list.
Problem 5 - streaks.py: Winning streaks? The debate on whether the random walk model for stock prices is appropriate has been going on for a long time . Some of it's opponents argue that "all those patterns we observe must be evidence of non-randomness". However, fairly complex patterns can arise through purely random processes In this problem, you will study a simple pattern that may arise in a simple random process. Consider a sequence of coin tosses where the probability of landing heads is p. A streak is a contiguous sub-sequence of tosses that landed the same way (i.e., either all heads or all tails). For example, in the sequence of N 14 tosses, H, H, T, T, T. H, T. H. H, H, T, T. T. T we have six streaks, Therefore, the maximum streak length is 4 (corresponding to the last streak) Problem 5a - streaks.py: Maximum streak length [30 points] Write a function max_streak that accepts the number of coin tosses N (positive integer), and the probability of heads p (float, between 0 and 1), as arguments. Your function should generate one random sequence of N coin tosses and return the maximum streak length in that sequence. Please use the provided toss () function to generate the random coin tosses Hint: Consider the previous example. If you had the streak sequence. 2x H. 3T. 1 H. 1 T. 3x H, 4T. instead of the original sequence, the problem would be trivial: it would reduce to what you did in Problem 2. Therefore can you first write a function that prints out the streak sequence? As you examine each element think about how to keep track of the "current streak" (consisting of "length so far" and the kind of streak, heads or tails). When you see a new element, you need to decide whether the "current streak" becomes longer by one, or whether it ends (hence https: //en.wikipedia.org/wiki/Technical-analysis#Random-walk-hypothesis Those interested in how human intuition can fail when confronting randomness may find "Thinking Fast and Slow" by Daniel Kahneman nteresting We have not covered lists yet, which would allow you to represent that sequence as a Python value, but printing it out is sufficient for our purposes hereStep 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