-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpluralvoting.m
96 lines (83 loc) · 2.74 KB
/
pluralvoting.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
% effect of plural voting
% 2015
% Awbrey Hughlett
% setup block of voters
voters = rand(100, 100);
% run plurality vote first
% random numbers denote voting preference
% extremes dictate where on the spectrum people will vote
% 0 - conservative
% 1 - liberal
% ccccclllll
liberal = 0;
conservative = 0;
for i = 1:columns(voters)
for j = 1:rows(voters)
temp = round(voters(i, j));
if(temp == 0)
conservative = conservative + 1;
else
liberal = liberal + 1;
endif
endfor
endfor
disp("Under a typical plurality voting system, assuming a 50/50 split in voting preference, a vote should yield a result similar to this:")
disp("---------------------")
disp("liberal votes: "), disp(sprintf("%5.2f", liberal))
disp(" ")
disp("conservative votes: "), disp(sprintf("%5.2f", conservative))
disp(" ")
disp("[-------------------------------]")
% run plural vote next
% same random voters
% middle ground randomly votes for second candidate
% c - conservative
% m - moderate
% l - liberal
% ccmmmmmmll
liberal_p = 0;
moderate_p = 0;
conservative_p = 0;
plural_vote_chance = 0.75;
extreme_magnitude = 0.2;
moderate_for_third = 0.05;
for i = 1:columns(voters)
for j = 1:rows(voters)
temp = voters(i, j);
% if top or bottom 20 percent, cast single vote
if(temp > 1*(1-extreme_magnitude) || temp < 1*extreme_magnitude)
temp = round(temp);
if(temp == 0)
conservative_p = conservative_p + 1;
else
liberal_p = liberal_p + 1;
endif
else
if(temp >= 1*(0.5-moderate_for_third) && temp <= 1*(0.5+moderate_for_third))
% devout votes for third party
moderate_p = moderate_p + 1;
else
% divide votes on midpoint
if(temp < 0.5)
conservative_p = conservative_p + 1;
else
liberal_p = liberal_p + 1;
endif
% chance that a moderate voter will cast a plural vote
if(rand(1) < plural_vote_chance)
moderate_p = moderate_p + 1;
endif
endif
endif
endfor
endfor
disp(" ")
disp("If any voter were allowed to vote for multiple candidates, the voting becomes a bit more complicated. Assuming that some voters within a certain range of")
disp("extremes would only vote for a single candidate, median voters would have a certain statistic for chosing a supplemental candidate within their spectrum.")
disp("This system has a chance of reducing the impact of voters choosing the candidate most likely to win in favor of voting for the candidate they actually desire.")
disp("---------------------")
disp("liberal votes: "), disp(sprintf("%5.2f", liberal_p))
disp(" ")
disp("conservative votes: "), disp(sprintf("%5.2f", conservative_p))
disp(" ")
disp("moderate votes: "), disp(sprintf("%5.2f", moderate_p))