crstn / CISC

Population projection code.
0 stars 0 forks source link

Improve random selection of cells to put population into #30

Closed crstn closed 7 years ago

crstn commented 7 years ago

When we add population, there is currently an equal chance for any cell to receive population. To make the assignment more realistic, the chance should be higher for cells which cover a larger area than for cells covering a smaller area. The chance should be proportional to the area covered by the cell. The same applies when we remove population.

pmarcotullio commented 7 years ago

Agreed! How to allocate based upon different weights (area) & population and still be fast?

P

Sent from my iPhone

On Jun 15, 2017, at 12:21 PM, Carsten Keßler notifications@github.com<mailto:notifications@github.com> wrote:

When we add population, there is currently an equal chance for any cell to receive population. To make the assignment more realistic, the chance should be higher for cells which cover a larger area than for cells covering a smaller area. The chance should be proportional to the area covered by the cell. The same applies when we remove population.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/crstn/CISC/issues/30, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ANnqdXKOAfSoj8Mngxbb_xuh1VKqXz-Eks5sEVJZgaJpZM4N7Z6p.

crstn commented 7 years ago

The np.random.choice method we use can actually be called with an array that provides the probability for the selection of each element. We can just feed the areas array into that and should be done.

crstn commented 7 years ago

Done. The only trick was that the weights need to add up to 1, but that was easy enough to achieve.