Voter mobility simulation To run this simulation, load this file and then run a gradient plot over S1 (see gradplot.kg).

Using the statistics and plotter modules.

.l("nstat.kg") .l("plot.kg")

Mobility is the fraction of voters who are ready to vote for a larger party with lower satisfaction. Hardcore is the percentage of voters who will never abandon their favorite party.

mobility::0.1 hardcore::1.0

Original voter distribution is a normal distribution. There are ten parties, values accumulate to 100%.

S0::5+dist(ndf;10;[-2.4 2.4])

If the party to the left/right has more voters, transfer voters to that party. The 'left' and 'right' functions compute difference vectors between the old and new vote distribution (for voters moving left and voters moving right, respectively). 'move' computes the new distribution given the current one.

step::{x{:[x<hardcore;0:|x<y;x*mobility;0]}'y} left::{(-step(x;1:+x))+(-1):+step(x;1:+x)} right::{(-step(x;(-1):+x))+1:+step(x;(-1):+x)} move::{x+left(x)+right(x)}

S1 is the result of taking a sample every W'th voting period while computing P periods in total. (W = window size)

S1::*'W:#P{move(x)}\*S0

Sn contains the final distribution after P voting periods.

Sn::*|S1