Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, have posted this question multiple times, hopeuflly can be done this time. Need python code for question 2, please write your own unique code

Hello, have posted this question multiple times, hopeuflly can be done this time. Need python code for question 2, please write your own unique code and not copy/paste from my other question I have posted, I will downvote and report. If possible, doing it using while loops will be appreciated. Thank you.

for 1c, answer should be 3/8 and for 1d, it should be 37/16. Again, do not use the same code for the same question I posted yesterday. Needs to be new and unique, preferably using the hints given (numpy) if possible.

image text in transcribedimage text in transcribed

(10 points) (Without Python) Suppose that there are 4 songs on your professor's half marathon running playlist (e.g. Eastside; Better Now; Lucid Dreams; Harder, Better, Faster, Stronger) She sets it in shuffle mode which plavs songs uniformly at random, sampling with replacement (i.e. repeats are possible). Let Xn be the number of unique songs that have been heard after the nth song played with Xo = 0. (a) Briefly explain why (Xn)0 forms a stationary discrete time Markov chain. (b) Find the transition probability matrix (c) Suppose your professor has listened to 3 songs. Compute the probability that all the songs were unique. If you use the Markov property, please indicate where it is used. (d) After 3 songs have been played, what is the expected number of unique songs that your professor has listened to? (30 points) (With Python) In this Python exercise, you will be estimate some probabilities and the expected number of unique songs that your professor listens to. Be sure to annotate your code with short explanations of what you are doing (worth 10 points) Suppose (as above) that your professor's half marathon running playlist has 4 songs (e.g. Eastside; Better Now; Lucid Dreams; Harder, Better, Faster, Stronger). She sets it in shuffle mode which plays songs uniformly at random, sampling with replacement (i.e. repeats are ossible (a) Simulate your professor listening to 3 songs 10,000 times. (b) Using the outcome of the simulations in part (a), compute the probability that she listens to three unique songs when 3 songs are played. Print your results, making sure to be clear about what you are printing/outputting. For example, print("After 10,000 simulations, the probability that after 3 songs are played that your professor listens to three unique songs is %s ." %probThreeUniqueSongs) (c) Use the outcome of the simulations in part (a) and the Law of Large Numbers to compute the average number of unique songs that your professor listens to when 3 songs are played Print your results, making sure to be clear about what you are printing/outputting numpy.random . choice alist ) will randomly pick one element from the set alist . When Python indexes list, the index of the list starts at 0. That is, to access the first entry of a list like a (7, 8, 9], we need to write a0. alist = [1, 4, 7] alist.append( 3 ) will add 3 to the end of your list. So, alist 1, 4, 7, 3). * set() creates a set- an unordered collections of unique elements .aset addet (Bar ataron' ,Greyjoy, ) )Lann ist er ,, aSet.add ( 'Baratheon' will add Baratheon to the set aSet alist- [1, 4, 7, 1, 4, 4] alist.count 4) returns 3, the number of times 4 occurs in the list alist. len (alist) return the length (the number of items) of alist. alist can be a sequence (such as a list) or a collection (like a set)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions