Question: Using Python Consider a sequence of Os and 1s where each number in the sequence is generated inde- pendently from a distribution p, 1-p (pick

Using Python

Using Python Consider a sequence of Os and 1s where each number

Consider a sequence of Os and 1s where each number in the sequence is generated inde- pendently from a distribution p, 1-p (pick your p). Let the length of sequence be N. AEP tells us that as N oo, there will be a set of 2NhG) sequences whose collective probability 1 . Write a python script to (semi) verify this by doing the following: 1. Vary N form 1 to 1000 2. For each N, arrange the sequences in decreasing order of probability, and count the first AN number of sequences it takes to reach a probability of 0.9 3. For each AN, compute hN = (1/N) log2 AN- If AEP is correct, then hN should converge to a value slight below h (p) and N oo (since we are only looking at a probability of 0.9) 4. Generate a plot with N on the x axis and h on the y axis. See instructions below to save the plot 5. Hint: Since it is virtually impossible to generate all the possible sequences, try to count them without actually generating them. For example, if you are computing for N = 50, you know how many sequences occur which have, say 10 0s and 40 1s, and you know the probability for each of those sequences. Consider a sequence of Os and 1s where each number in the sequence is generated inde- pendently from a distribution p, 1-p (pick your p). Let the length of sequence be N. AEP tells us that as N oo, there will be a set of 2NhG) sequences whose collective probability 1 . Write a python script to (semi) verify this by doing the following: 1. Vary N form 1 to 1000 2. For each N, arrange the sequences in decreasing order of probability, and count the first AN number of sequences it takes to reach a probability of 0.9 3. For each AN, compute hN = (1/N) log2 AN- If AEP is correct, then hN should converge to a value slight below h (p) and N oo (since we are only looking at a probability of 0.9) 4. Generate a plot with N on the x axis and h on the y axis. See instructions below to save the plot 5. Hint: Since it is virtually impossible to generate all the possible sequences, try to count them without actually generating them. For example, if you are computing for N = 50, you know how many sequences occur which have, say 10 0s and 40 1s, and you know the probability for each of those sequences

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!