7144CEM Principles of Data Science

Need Solution -> Download Solution Here


Plagfree Sale

7144CEM Assignment Help

Principles of Data Science Assignment help

Task 1. Markov Chains
Example: Flowers. Consider a particular variety of flower which can take one of three colours: red, white and pink. Suppose after each year, 40% of red flowers remain red but 60% of red flowers mutate to pink. For pink flowers, 30% mutate to red, 50% remain as pink, and 20% mutate to white. For white flowers, 90% remain as white and 10% mutate to pink. We can capture these probabilities in a transition matrix 𝑃 where the columns correspond to red, pink and white flowers in the current year and the rows correspond to red, pink and white flowers in the next year. 𝑃=[0.40.300.60.50.100.20.9]

If a certain garden initially has 80 of this variety of red flowers and 20 of this variety of white flowers then after one year: 𝑃[80020]=[325018]

so we would expect to see 32 red, 50 pink and 18 white flowers in the garden. If we look at the garden after 5 years: 𝑃𝑃𝑃𝑃𝑃[80020]=𝑃5[80020]=[20.8837.0842.04]

so we would expect to see approximately 21 red, 37 pink and 42 white flowers in the garden. This is an example of a system called a β€œMarkov chain”. The next state of the system depends only on its present state and does not depend on the earlier history of the system.
Car rental. Now consider a car rental agency that has offices in Paris, Berlin, Rome and Madrid. The agency allows one-way and two-way rentals so that cars in one city may end up in another. Statistics show that at the end of each week 70% of all rentals are two-way. As for one-way rentals: from Paris, 20% go to Berlin, 60% go to Rome, and the rest go to Madrid; from Berlin, 40% go to Madrid and 60% go to Rome; from Rome, 50% go to Madrid and the rest to Berlin; and from Madrid, 80% go to Rome, 10% go to Berlin, and 10% go to Paris.
(1) Construct a 4Γ—4 transition matrix 𝑃 (as a numpy array) to model this car rental agency as a Markov chain.
[10 marks]

(2) Suppose the agency starts the first week with 100 cars in each city (400 cars in total). Use numpy to calculate how many cars we would expect to see in each city at the end of each week for each of the following 15 weeks. Use Python to plot your results on a line graph showing one line for each city, together with a legend. Briefly comment on what you observe. You might find numpy.linalg.matrix_power() helpful.
[10 marks]

(3) Use numpy to find the eigenvectors of the transition matrix 𝑃 from part (1), and explain how one of these eigenvectors is related to the number of cars we would expect to see in each city in the β€œlong-run steady state”. Also, for each city 𝑗, find the expected number of weeks for a particular car initially located at city 𝑗 to first return to city 𝑗. Hint: if 𝑝𝑗 is the probability that the particular car is in city 𝑗 in the β€œlong-run steady state” then the expected first return time is given by 1/𝑝𝑗.

By |2023-01-17T08:38:34+00:00January 17th, 2023|Categories: Information Technology|Tags: |0 Comments

Leave A Comment