Assignment 2 Markov Chains - 2-3
Assignment 2 Markov Chains - 2-3
Due Date
Due Date:2022/3/22 (Wednesday) 10 am.
: 2024/03/20(Wednesday) 10Please submit sumit
am. Please the electronic file (PPT)file (PPT)
the electronic
and codes
and codes onon
eeclass. One One
eeclass. groupgroup
only submits one file. one file.
only submits
A politician is campaigning in 7 districts, one adjacent to the other. She wants to spend
time in each district, but due to financial constraints, would like to spend time in each
district proportional to the number of likely
⽂字voters in that district. The only information
available is the number of voters in the district she is currently in, and in those that are
directly adjacent to it on either side. Each day, she must decide whether to campaign in
the same district, move to the adjacent eastern district, or move to the adjacent western.
On any given day, here’s how the decision is made whether to move or not:
Suppose that every day, the politician makes her travel plans according to the following
algorithm.
⚫ Flip a coin. Heads to move east, tails to move west.
⚫ If the proposed district has more voters than the present district, move there.
⚫ If the proposed district has less voters than the present district, then:
◼ She computes 𝑎, the ratio of the number of voters of the proposed district to
the present district.
◼ She travels to the proposed district with probability 𝑎.
◼ And with probability 1 − 𝑎, she spends another day on the present district.
Suppose there are 7 districts, labeled 1,…,7 from west to east, and that the number of
voters of district 𝜃 is 𝜃 (thousand), and that she starts at district 3 on day 1. She
proposes a move to either district 2 or district 4. If the proposed move is to district 4,
it is accepted and she moves to district 4. If the proposed move is to district 2, it is
accepted with probability 2/3. If it is accepted, she moves to district 2; otherwise, she
stays at district 3 for another day. Here is an example plot for 30 days.
1. Please write code to simulate the politician’s movements for many days. Plot the
district path and the simulated relative frequencies of days in each of the 7 districts.
2. Discuss whether the algorithm produces a reasonable approximation.
3. Suppose again that the number of districts (it can be set by yourselves) and their
number of voters is unknown, but that the number of voters for district 𝜃 is
proportional to 𝜃 2 𝑒 −0.5𝜃 , where the districts are labeled from west to east 1, 2, ….
Please plot the district path and the simulated relative frequencies of days as
Problem 1.
4. According to the simulation result, please discuss the following questions:
(1) Why doesn’t the politician just always travel to or stay on the district with
more voters?
(2) Is the next district visited dependent on the present district?
(3) Is the next district visited dependent on how she got to the present district?
When you turn in your assignment, make sure you include codes, explanation for
your process, computation results and conclusion.