mggg / GerryChain

Use MCMC to analyze districting plans and gerrymanders
https://mggg.github.io/GerryChain/
Other
133 stars 74 forks source link

Uniformity through acceptance #304

Open drdeford opened 5 years ago

drdeford commented 5 years ago

Given that our collection of boundary flip proposals all lead to different non-uniform distributions, that can be salvaged in principle by using an accept function, weighted by metagraph degrees, we should probably write some documentation about the way to make these accept functions.

I don't necessarily think it is worth including these in accept.py (although I'm willing to do it if we decide it would be useful). But it would be useful to address this in our documentation somewhere to suggest how people could do it, if they wanted to.

maxhully commented 5 years ago

I think this would be a great way to show how to write/use acceptance functions too.

drdeford commented 5 years ago

I'll add a version of this to my notes for one of the easy ones.

drdeford commented 5 years ago

This actually leads to another subtler issue that if you want to do the weighting (and the corresponding waiting :) ) properly, you need to replace the validators with a separate check in the accept function:

if not any([val(partition) for val in Validator]): return 0

in order to get the correct distribution.

maxhully commented 5 years ago

Really?

drdeford commented 5 years ago

Yeah, it all comes down to which steps get binned (which is to say, this is a software decision - a place where the theory and practice don't come together neatly). The idea is that you need to replicate the uniformly choose a node to flip model and remain in place if the step would violate your constraints. However, the naive implementation leads to rejection rates that are too high, so you sample from only the boundary nodes in practice. This however, introduces several possible sources of non-uniformity and so the adding of actual steps to the chain has to be handled carefully.

drdeford commented 5 years ago

I have versions of this now that I built for Lorenzo and the VA 2.0 thing. We should decide if it is worth adding them here now that we aren't doing much flipping anymore.