Complete the Redistricter code to perform the following functions.
Implement the MCMC process that iteratively produces candidate redistricting plans and accepts or rejects these candidates based on the Metropolis criterion.
Run this process at least 1,000 times and record each run’s resulting plan.
Visualize the results of this simulation in a plot that displays the number of nodes in each district (3 districts => 2 dimensions required) and also a histogram of this information.
Produce a number of plan visualizations that illustrate the results
The data file which is given includes the adjacency matrix that is the connectivity of node, coordinates of node, the number of the nodes, and the population of the party.
The report should be written in complete sentences and structured with an appropriate introduction and conclusion. Its intended audience and tone should match the redistricting paper. Make sure to write in the words and do not plagiarize the other paper. The best way to do this is to write in several stages and not reference the original wording of the other paper after the first stage.
Build off of the work in Project 2 according to the following items. Write up your results in a well structured and organized report, using a similar tone and audience to the redistricting paper.
Basic geographical and demographic information about the map and initial plan.
Underlying theory of the MCMC algorithm that you’ve implemented.
Practical details of the MCMC algorithm (e.g. how many trials, how many samples, estimated runtime).
Equal population constraint implemented via Gibbs distribution: include information on how you tuned the beta parameter in order to achieve an appropriate constraint. You are permitted to allow relatively high variation in district population (even ±25% is OK with me) in order to allow your algorithm the flexibility to really explore the search space. Just make a choice for yourself and explain how you tuned the beta parameter to achieve this.
Resampling 1000 times to simulate uniform distribution after obtaining a Gibbs stationary distribution.
Analysis of electoral competitiveness of your sampled plans compared to the initial plan, visualized with a scatter plot.
Plan diagrams for notable plans in your analysis, together with commentary about what makes them notable.
Overall assessment of whether the initial plan exhibits partisan gerrymandering. If so, explain how this is observed and offer less biased alternatives. If not, explain how this is observed and exhibit some alternatives with a higher level of bias for comparison.
Important: the code needs to work in order to do this project properly. The codes need to succeed in performing the MCMC algorithm with an appropriate depth and breadth. Therefore, make sure to prototype the code by running it at small scales and identify any errors that may appear. If the code is working, it should never end prematurely with a Traceback.