sapor 0.1b1 → 0.2a1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Example-Catalonia.md +361 -0
- data/Example-Flanders.md +486 -0
- data/Example-Greece.md +25 -0
- data/Example-Oslo.md +678 -0
- data/Example-UnitedKingdom-Referendum.md +132 -0
- data/Examples.md +9 -355
- data/README.md +41 -8
- data/bin/create_installation_package.sh +2 -2
- data/bin/install.sh +1 -1
- data/bin/sapor.rb +4 -2
- data/bin/sapor.sh +10 -9
- data/data/hu/hungary-2014.txt +1680 -0
- data/data/hu/hungary_2014_screen_scraper.rb +48 -0
- data/data/hu/hungary_2014_to_psv.rb +80 -0
- data/data/hu/index-2014.txt +106 -0
- data/data/pl/2015-gl-lis-okr.csv +42 -0
- data/data/pl/poland_2015_to_psv.rb +79 -0
- data/data/pl/poland_2015_to_psv_with_ko_and_rsw.rb +94 -0
- data/data/pl/poland_2015_to_psv_with_ko_konf_kp_l_and_zp.rb +100 -0
- data/data/pl/poland_2015_to_psv_with_ko_sld_and_wi.rb +92 -0
- data/data/pl/poland_2015_to_psv_with_sld.rb +84 -0
- data/data/pl/poland_2015_to_psv_with_sld_and_wi.rb +85 -0
- data/data/uk/inject_ukip_2015_as_brexit_2019_in_2017.rb +54 -0
- data/data/uk/united_kingdom_2015.txt +651 -0
- data/data/uk/united_kingdom_2015_to_psv.rb +104 -0
- data/data/uk/united_kingdom_2017.txt +651 -0
- data/data/uk/united_kingdom_2017_to_psv.rb +104 -0
- data/data/uk/united_kingdom_2017_to_psv_with_brexit_and_chuk.rb +113 -0
- data/data/uk/united_kingdom_2017_to_psv_with_tig.rb +111 -0
- data/lib/sapor/binomials_cache.rb +1 -1
- data/lib/sapor/combinations_distribution.rb +43 -1
- data/lib/sapor/denominators.rb +67 -0
- data/lib/sapor/dichotomies.rb +41 -1
- data/lib/sapor/dichotomy.rb +31 -5
- data/lib/sapor/first_past_the_post.rb +6 -2
- data/lib/sapor/largest_remainder.rb +118 -0
- data/lib/sapor/log4r_logger.rb +1 -1
- data/lib/sapor/log_facade.rb +1 -1
- data/lib/sapor/{leveled_proportional.rb → multi_district_leveled_proportional.rb} +7 -7
- data/lib/sapor/{proportional.rb → multi_district_proportional.rb} +27 -32
- data/lib/sapor/multi_district_variable_threshold_proportional.rb +128 -0
- data/lib/sapor/number_formatter.rb +1 -1
- data/lib/sapor/options.rb +73 -0
- data/lib/sapor/poll.rb +178 -29
- data/lib/sapor/polychotomy.rb +100 -259
- data/lib/sapor/pseudorandom_multirange_enumerator.rb +1 -1
- data/lib/sapor/referendum_polychotomy.rb +165 -0
- data/lib/sapor/regional_data/area.rb +4 -2
- data/lib/sapor/regional_data/austria.rb +84 -0
- data/lib/sapor/regional_data/belgium-brussels-2014.psv +46 -0
- data/lib/sapor/regional_data/belgium-brussels-20190526.psv +33 -0
- data/lib/sapor/regional_data/belgium-flanders-2014.psv +80 -0
- data/lib/sapor/regional_data/belgium-flanders-20190526.psv +74 -0
- data/lib/sapor/regional_data/belgium-wallonia-2014.psv +114 -0
- data/lib/sapor/regional_data/belgium-wallonia-20190526.psv +93 -0
- data/lib/sapor/regional_data/belgium.rb +97 -0
- data/lib/sapor/regional_data/belgium_brussels.rb +62 -0
- data/lib/sapor/regional_data/belgium_flanders.rb +64 -0
- data/lib/sapor/regional_data/belgium_wallonia.rb +63 -0
- data/lib/sapor/regional_data/catalonia-2012-2015.psv +1 -1
- data/lib/sapor/regional_data/catalonia-2012.psv +1 -1
- data/lib/sapor/regional_data/catalonia-2015-jxcat.psv +68 -0
- data/lib/sapor/regional_data/catalonia-2015-no-jxsi.psv +68 -0
- data/lib/sapor/regional_data/catalonia-2015.psv +63 -0
- data/lib/sapor/regional_data/catalonia-jxcat.rb +109 -0
- data/lib/sapor/regional_data/catalonia-no-jxsi.rb +96 -0
- data/lib/sapor/regional_data/catalonia.rb +27 -21
- data/lib/sapor/regional_data/denmark-20150618-with-e-and-p.psv +164 -0
- data/lib/sapor/regional_data/denmark-20150618-with-e.psv +153 -0
- data/lib/sapor/regional_data/denmark-20150618-with-p.psv +153 -0
- data/lib/sapor/regional_data/denmark-20150618.psv +142 -0
- data/lib/sapor/regional_data/denmark.rb +128 -0
- data/lib/sapor/regional_data/denmark_with_e.rb +128 -0
- data/lib/sapor/regional_data/denmark_with_e_and_p.rb +128 -0
- data/lib/sapor/regional_data/denmark_with_p.rb +128 -0
- data/lib/sapor/regional_data/estonia.rb +88 -0
- data/lib/sapor/regional_data/european-union-great-britain-20140522-brexit-chuk.psv +172 -0
- data/lib/sapor/regional_data/european-union-great-britain-20140522.psv +146 -0
- data/lib/sapor/regional_data/european-union-great-britain-20190523.psv +141 -0
- data/lib/sapor/regional_data/european-union-ireland-2014-ia-ri-sd.psv +64 -0
- data/lib/sapor/regional_data/european-union-ireland-2014-ia-sd.psv +60 -0
- data/lib/sapor/regional_data/european-union-ireland-2014-ia.psv +56 -0
- data/lib/sapor/regional_data/european-union-ireland-2014-sd.psv +56 -0
- data/lib/sapor/regional_data/european-union-ireland-2014.psv +50 -0
- data/lib/sapor/regional_data/european-union-ireland-20190524-ia.psv +58 -0
- data/lib/sapor/regional_data/european-union-ireland-20190524.psv +52 -0
- data/lib/sapor/regional_data/european_union_27_austria.rb +76 -0
- data/lib/sapor/regional_data/european_union_27_croatia.rb +81 -0
- data/lib/sapor/regional_data/european_union_27_denmark.rb +77 -0
- data/lib/sapor/regional_data/european_union_27_estonia.rb +74 -0
- data/lib/sapor/regional_data/european_union_27_finland.rb +74 -0
- data/lib/sapor/regional_data/european_union_27_ireland.rb +96 -0
- data/lib/sapor/regional_data/european_union_27_ireland_with_ia.rb +97 -0
- data/lib/sapor/regional_data/european_union_27_italy.rb +83 -0
- data/lib/sapor/regional_data/european_union_27_netherlands.rb +81 -0
- data/lib/sapor/regional_data/european_union_27_poland.rb +79 -0
- data/lib/sapor/regional_data/european_union_27_romania.rb +78 -0
- data/lib/sapor/regional_data/european_union_27_slovakia.rb +80 -0
- data/lib/sapor/regional_data/european_union_27_spain.rb +82 -0
- data/lib/sapor/regional_data/european_union_27_sweden.rb +76 -0
- data/lib/sapor/regional_data/european_union_austria.rb +76 -0
- data/lib/sapor/regional_data/european_union_bulgaria.rb +81 -0
- data/lib/sapor/regional_data/european_union_croatia.rb +81 -0
- data/lib/sapor/regional_data/european_union_cyprus.rb +72 -0
- data/lib/sapor/regional_data/european_union_czech_republic.rb +82 -0
- data/lib/sapor/regional_data/european_union_denmark.rb +77 -0
- data/lib/sapor/regional_data/european_union_estonia.rb +74 -0
- data/lib/sapor/regional_data/european_union_finland.rb +74 -0
- data/lib/sapor/regional_data/european_union_flanders.rb +74 -0
- data/lib/sapor/regional_data/european_union_france.rb +84 -0
- data/lib/sapor/regional_data/european_union_france_2019.rb +84 -0
- data/lib/sapor/regional_data/european_union_french_community_of_belgium.rb +73 -0
- data/lib/sapor/regional_data/european_union_germany.rb +86 -0
- data/lib/sapor/regional_data/european_union_great_britain.rb +98 -0
- data/lib/sapor/regional_data/european_union_greece.rb +77 -0
- data/lib/sapor/regional_data/european_union_hungary.rb +76 -0
- data/lib/sapor/regional_data/european_union_ireland.rb +96 -0
- data/lib/sapor/regional_data/european_union_ireland_with_ia.rb +97 -0
- data/lib/sapor/regional_data/european_union_italy.rb +83 -0
- data/lib/sapor/regional_data/european_union_latvia.rb +81 -0
- data/lib/sapor/regional_data/european_union_lithuania.rb +80 -0
- data/lib/sapor/regional_data/european_union_luxembourg.rb +75 -0
- data/lib/sapor/regional_data/european_union_malta.rb +71 -0
- data/lib/sapor/regional_data/european_union_netherlands.rb +81 -0
- data/lib/sapor/regional_data/european_union_northern_ireland.rb +75 -0
- data/lib/sapor/regional_data/european_union_poland.rb +79 -0
- data/lib/sapor/regional_data/european_union_portugal.rb +75 -0
- data/lib/sapor/regional_data/european_union_romania.rb +78 -0
- data/lib/sapor/regional_data/european_union_slovakia.rb +81 -0
- data/lib/sapor/regional_data/european_union_slovenia.rb +85 -0
- data/lib/sapor/regional_data/european_union_spain.rb +82 -0
- data/lib/sapor/regional_data/european_union_sweden.rb +76 -0
- data/lib/sapor/regional_data/finland-20150419-with-sin.psv +224 -0
- data/lib/sapor/regional_data/finland-20150419.psv +212 -0
- data/lib/sapor/regional_data/finland.rb +107 -0
- data/lib/sapor/regional_data/finland_with_sin.rb +107 -0
- data/lib/sapor/regional_data/flanders-2014.psv +96 -0
- data/lib/sapor/regional_data/flanders-20190526.psv +87 -0
- data/lib/sapor/regional_data/flanders.rb +115 -0
- data/lib/sapor/regional_data/france.rb +38 -0
- data/lib/sapor/regional_data/greece.rb +92 -0
- data/lib/sapor/regional_data/hungary-2014.psv +2104 -0
- data/lib/sapor/regional_data/hungary.rb +116 -0
- data/lib/sapor/regional_data/iceland-20161029-midflokkurinn.psv +94 -0
- data/lib/sapor/regional_data/iceland-20161029.psv +88 -0
- data/lib/sapor/regional_data/iceland-20171028.psv +85 -0
- data/lib/sapor/regional_data/iceland.rb +133 -0
- data/lib/sapor/regional_data/latvia-20141004-kpv-p-par.psv +109 -0
- data/lib/sapor/regional_data/latvia-20141004-kpv-par.psv +103 -0
- data/lib/sapor/regional_data/latvia-20141004-kpv.psv +97 -0
- data/lib/sapor/regional_data/latvia-20141004.psv +89 -0
- data/lib/sapor/regional_data/latvia.rb +112 -0
- data/lib/sapor/regional_data/latvia_kpv.rb +112 -0
- data/lib/sapor/regional_data/latvia_kpv_p_par.rb +112 -0
- data/lib/sapor/regional_data/latvia_kpv_par.rb +112 -0
- data/lib/sapor/regional_data/luxembourg-20131020.psv +76 -0
- data/lib/sapor/regional_data/luxembourg.rb +82 -0
- data/lib/sapor/regional_data/netherlands.rb +108 -0
- data/lib/sapor/regional_data/norway.rb +85 -68
- data/lib/sapor/regional_data/norwegian_municipality.rb +68 -0
- data/lib/sapor/regional_data/poland-20151025-with-ko-and-l-without-n-po-r-and-zl.psv +321 -0
- data/lib/sapor/regional_data/poland-20151025-with-ko-konf-kp-l-and-zp-without-k-k15-n-pis-po-psl-r-and-zl.psv +280 -0
- data/lib/sapor/regional_data/poland-20151025-with-ko-sld-and-wi-without-n-po-and-zl.psv +403 -0
- data/lib/sapor/regional_data/poland-20151025-with-sld-and-wi-without-zl.psv +444 -0
- data/lib/sapor/regional_data/poland-20151025-with-sld-without-zl.psv +403 -0
- data/lib/sapor/regional_data/poland-20151025.psv +403 -0
- data/lib/sapor/regional_data/poland.rb +125 -0
- data/lib/sapor/regional_data/poland_with_ko_and_l_without_n_po_r_and_zl.rb +122 -0
- data/lib/sapor/regional_data/poland_with_ko_konf_kp_l_and_zp_without_k_k15_n_pis_po_psl_r_and_zl.rb +123 -0
- data/lib/sapor/regional_data/poland_with_ko_sld_and_wi_without_n_po_and_zl.rb +125 -0
- data/lib/sapor/regional_data/poland_with_sld_and_wi_without_zl.rb +126 -0
- data/lib/sapor/regional_data/poland_with_sld_without_zl.rb +126 -0
- data/lib/sapor/regional_data/portugal-20151004-with-a-and-ch-without-paf.psv +438 -0
- data/lib/sapor/regional_data/portugal-20151004-with-a-and-il-without-paf.psv +438 -0
- data/lib/sapor/regional_data/portugal-20151004-with-a-ch-and-il-without-paf.psv +461 -0
- data/lib/sapor/regional_data/portugal-20151004-with-a-without-paf.psv +415 -0
- data/lib/sapor/regional_data/portugal-20151004-with-ch-and-il-without-paf.psv +438 -0
- data/lib/sapor/regional_data/portugal-20151004-without-paf.psv +392 -0
- data/lib/sapor/regional_data/portugal-20151004.psv +370 -0
- data/lib/sapor/regional_data/portugal.rb +101 -0
- data/lib/sapor/regional_data/portugal_with_a_and_ch_without_paf.rb +92 -0
- data/lib/sapor/regional_data/portugal_with_a_and_il_without_paf.rb +92 -0
- data/lib/sapor/regional_data/portugal_with_a_ch_and_il_without_paf.rb +92 -0
- data/lib/sapor/regional_data/portugal_with_a_without_paf.rb +92 -0
- data/lib/sapor/regional_data/portugal_with_ch_and_il_without_paf.rb +92 -0
- data/lib/sapor/regional_data/portugal_without_paf.rb +92 -0
- data/lib/sapor/regional_data/slovakia.rb +81 -0
- data/lib/sapor/regional_data/slovenia.rb +114 -0
- data/lib/sapor/regional_data/spain-20160626.psv +619 -0
- data/lib/sapor/regional_data/spain.rb +136 -0
- data/lib/sapor/regional_data/sweden.rb +92 -0
- data/lib/sapor/regional_data/sweden_20140914.rb +89 -0
- data/lib/sapor/regional_data/united_kingdom-2015.psv +4358 -0
- data/lib/sapor/regional_data/united_kingdom-20170608-brexit-chuk.psv +5154 -0
- data/lib/sapor/regional_data/united_kingdom-20170608-brexit.psv +4521 -0
- data/lib/sapor/regional_data/united_kingdom-20170608-tig.psv +4529 -0
- data/lib/sapor/regional_data/united_kingdom-20170608.psv +3894 -0
- data/lib/sapor/regional_data/united_kingdom.rb +57 -1038
- data/lib/sapor/regional_data/united_kingdom_with_brexit.rb +110 -0
- data/lib/sapor/regional_data/united_kingdom_with_brexit_and_chuk.rb +111 -0
- data/lib/sapor/regional_data/united_kingdom_with_tig.rb +111 -0
- data/lib/sapor/regional_data/utopia.rb +2 -2
- data/lib/sapor/regional_data/wallonia-2014.psv +101 -0
- data/lib/sapor/regional_data/wallonia.rb +97 -0
- data/lib/sapor/representatives_polychotomy.rb +338 -0
- data/lib/sapor/single_district_proportional.rb +75 -0
- data/lib/sapor.rb +112 -6
- data/sapor.gemspec +2 -2
- data/spec/integration/area_spec.rb +2 -2
- data/spec/integration/poll_spec.rb +6 -1
- data/spec/integration/sample.poll +2 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/unit/area_spec.rb +12 -12
- data/spec/unit/austria_spec.rb +76 -0
- data/spec/unit/belgium_brussels_spec.rb +58 -0
- data/spec/unit/belgium_flanders_spec.rb +62 -0
- data/spec/unit/belgium_spec.rb +26 -0
- data/spec/unit/belgium_wallonia_spec.rb +65 -0
- data/spec/unit/binomials_cache_spec.rb +1 -1
- data/spec/unit/catalonia_spec.rb +21 -29
- data/spec/unit/combinations_distribution_spec.rb +1 -1
- data/spec/unit/denmark_spec.rb +56 -0
- data/spec/unit/denmark_with_e_and_p_spec.rb +58 -0
- data/spec/unit/denmark_with_e_spec.rb +57 -0
- data/spec/unit/denmark_with_p_spec.rb +57 -0
- data/spec/unit/denominators_spec.rb +8 -2
- data/spec/unit/dichotomies_spec.rb +1 -1
- data/spec/unit/dichotomy_spec.rb +1 -1
- data/spec/unit/estonia_spec.rb +65 -0
- data/spec/unit/european_union_27_austria_spec.rb +61 -0
- data/spec/unit/european_union_27_croatia_spec.rb +60 -0
- data/spec/unit/european_union_27_denmark_spec.rb +62 -0
- data/spec/unit/european_union_27_estonia_spec.rb +94 -0
- data/spec/unit/european_union_27_finland_spec.rb +75 -0
- data/spec/unit/european_union_27_ireland_spec.rb +72 -0
- data/spec/unit/european_union_27_ireland_with_ia_spec.rb +74 -0
- data/spec/unit/european_union_27_italy_spec.rb +69 -0
- data/spec/unit/european_union_27_netherlands_spec.rb +81 -0
- data/spec/unit/european_union_27_poland_spec.rb +69 -0
- data/spec/unit/european_union_27_romania_spec.rb +67 -0
- data/spec/unit/european_union_27_slovakia_spec.rb +111 -0
- data/spec/unit/european_union_27_spain_spec.rb +130 -0
- data/spec/unit/european_union_27_sweden_spec.rb +89 -0
- data/spec/unit/european_union_austria_spec.rb +61 -0
- data/spec/unit/european_union_bulgaria_spec.rb +97 -0
- data/spec/unit/european_union_croatia_spec.rb +59 -0
- data/spec/unit/european_union_cyprus_spec.rb +65 -0
- data/spec/unit/european_union_czech_republic_spec.rb +125 -0
- data/spec/unit/european_union_denmark_spec.rb +61 -0
- data/spec/unit/european_union_estonia_spec.rb +93 -0
- data/spec/unit/european_union_finland_spec.rb +75 -0
- data/spec/unit/european_union_flanders_spec.rb +56 -0
- data/spec/unit/european_union_france_2019_spec.rb +73 -0
- data/spec/unit/european_union_france_spec.rb +73 -0
- data/spec/unit/european_union_french_community_of_belgium_spec.rb +61 -0
- data/spec/unit/european_union_germany_spec.rb +90 -0
- data/spec/unit/european_union_great_britain_spec.rb +87 -0
- data/spec/unit/european_union_greece_spec.rb +148 -0
- data/spec/unit/european_union_hungary_spec.rb +57 -0
- data/spec/unit/european_union_ireland_spec.rb +72 -0
- data/spec/unit/european_union_ireland_with_ia_spec.rb +74 -0
- data/spec/unit/european_union_italy_spec.rb +69 -0
- data/spec/unit/european_union_latvia_spec.rb +76 -0
- data/spec/unit/european_union_lithuania_spec.rb +68 -0
- data/spec/unit/european_union_luxembourg_spec.rb +63 -0
- data/spec/unit/european_union_malta_spec.rb +60 -0
- data/spec/unit/european_union_netherlands_spec.rb +81 -0
- data/spec/unit/european_union_northern_ireland_spec.rb +66 -0
- data/spec/unit/european_union_poland_spec.rb +69 -0
- data/spec/unit/european_union_portugal_spec.rb +77 -0
- data/spec/unit/european_union_romania_spec.rb +67 -0
- data/spec/unit/european_union_slovakia_spec.rb +111 -0
- data/spec/unit/european_union_slovenia_spec.rb +77 -0
- data/spec/unit/european_union_spain_spec.rb +129 -0
- data/spec/unit/european_union_sweden_spec.rb +89 -0
- data/spec/unit/finland_spec.rb +65 -0
- data/spec/unit/finland_with_sin_spec.rb +67 -0
- data/spec/unit/first_past_the_post_spec.rb +6 -5
- data/spec/unit/flanders_spec.rb +70 -0
- data/spec/unit/france_spec.rb +32 -0
- data/spec/unit/greece_spec.rb +118 -0
- data/spec/unit/hungary_spec.rb +132 -0
- data/spec/unit/iceland_spec.rb +57 -0
- data/spec/unit/largest_remainder_spec.rb +79 -0
- data/spec/unit/latvia_kpv_p_par_spec.rb +38 -0
- data/spec/unit/latvia_kpv_par_spec.rb +38 -0
- data/spec/unit/latvia_kpv_spec.rb +38 -0
- data/spec/unit/latvia_spec.rb +60 -0
- data/spec/unit/luxembourg_spec.rb +54 -0
- data/spec/unit/{leveled_proportional_spec.rb → multi_district_leveled_proportional_spec.rb} +12 -14
- data/spec/unit/{proportional_spec.rb → multi_district_proportional_spec.rb} +11 -16
- data/spec/unit/netherlands_spec.rb +107 -0
- data/spec/unit/norway_spec.rb +23 -6
- data/spec/unit/norwegian_municipality_spec.rb +89 -0
- data/spec/unit/number_formatter_spec.rb +1 -1
- data/spec/unit/poland_spec.rb +62 -0
- data/spec/unit/poland_with_ko_and_l_without_n_po_r_and_zl_spec.rb +60 -0
- data/spec/unit/poland_with_ko_konf_kp_l_and_zp_without_k_k15_n_pis_po_psl_r_and_zl_spec.rb +59 -0
- data/spec/unit/poland_with_ko_sld_and_wi_without_n_po_and_zl_spec.rb +62 -0
- data/spec/unit/poland_with_sld_and_wi_without_zl_spec.rb +63 -0
- data/spec/unit/poland_with_sld_without_zl_spec.rb +62 -0
- data/spec/unit/poll_spec.rb +8 -3
- data/spec/unit/portugal_spec.rb +66 -0
- data/spec/unit/portugal_with_a_and_ch_without_paf_spec.rb +68 -0
- data/spec/unit/portugal_with_a_and_il_without_paf_spec.rb +68 -0
- data/spec/unit/portugal_with_a_ch_and_il_without_paf_spec.rb +69 -0
- data/spec/unit/portugal_with_a_without_paf_spec.rb +67 -0
- data/spec/unit/portugal_with_ch_and_il_without_paf_spec.rb +68 -0
- data/spec/unit/portugal_without_paf_spec.rb +66 -0
- data/spec/unit/pseudorandom_multirange_enumerator_spec.rb +1 -1
- data/spec/unit/referendum_polychotomy_spec.rb +289 -0
- data/spec/unit/{polychotomy_spec.rb → representatives_polychotomy_spec.rb} +26 -26
- data/spec/unit/slovakia_spec.rb +99 -0
- data/spec/unit/slovenia_spec.rb +80 -0
- data/spec/unit/spain_spec.rb +101 -0
- data/spec/unit/sweden_20140914_spec.rb +112 -0
- data/spec/unit/sweden_spec.rb +113 -0
- data/spec/unit/united_kingdom_spec.rb +65 -0
- data/spec/unit/united_kingdom_with_brexit_and_chuk_spec.rb +67 -0
- data/spec/unit/united_kingdom_with_brexit_spec.rb +66 -0
- data/spec/unit/united_kingdom_with_tig_spec.rb +66 -0
- data/spec/unit/wallonia_spec.rb +130 -0
- metadata +381 -11
@@ -0,0 +1,112 @@
|
|
1
|
+
#
|
2
|
+
# Statistical Analysis of Polling Results (SAPoR)
|
3
|
+
# Copyright (C) 2016 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
4
|
+
#
|
5
|
+
# This file is part of SAPoR.
|
6
|
+
#
|
7
|
+
# SAPoR is free software: you can redistribute it and/or modify it under the
|
8
|
+
# terms of the GNU General Public License as published by the Free Software
|
9
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
10
|
+
# version.
|
11
|
+
#
|
12
|
+
# SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
|
13
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
14
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You can find a copy of the GNU General Public License in /doc/gpl.txt
|
17
|
+
#
|
18
|
+
|
19
|
+
module Sapor
|
20
|
+
#
|
21
|
+
# The regional data for Latvia, extended for KPV and PAR.
|
22
|
+
#
|
23
|
+
class LatviaKpvPar < Area
|
24
|
+
include Singleton
|
25
|
+
def area_code
|
26
|
+
'LV∪{KPV,PAR}'
|
27
|
+
end
|
28
|
+
|
29
|
+
def coalitions
|
30
|
+
[['KPV LV', 'Sociāldemokrātiskā Partija “Saskaņa”'],
|
31
|
+
['KPV LV', 'Sociāldemokrātiskā Partija “Saskaņa”',
|
32
|
+
'Zaļo un Zemnieku savienība'],
|
33
|
+
['Kustība Par!',
|
34
|
+
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
35
|
+
'Vienotība', 'Zaļo un Zemnieku savienība'],
|
36
|
+
['Kustība Par!',
|
37
|
+
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
38
|
+
'Zaļo un Zemnieku savienība'],
|
39
|
+
['Kustība Par!', 'Jaunā konservatīvā partija',
|
40
|
+
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
41
|
+
'Vienotība'],
|
42
|
+
['Kustība Par!', 'Jaunā konservatīvā partija',
|
43
|
+
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
44
|
+
'Vienotība', 'Zaļo un Zemnieku savienība'],
|
45
|
+
['Kustība Par!', 'Jaunā konservatīvā partija',
|
46
|
+
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
47
|
+
'Zaļo un Zemnieku savienība'],
|
48
|
+
['Kustība Par!', 'Jaunā konservatīvā partija',
|
49
|
+
'Sociāldemokrātiskā Partija “Saskaņa”'],
|
50
|
+
['Kustība Par!', 'Sociāldemokrātiskā Partija “Saskaņa”'],
|
51
|
+
['Jaunā konservatīvā partija',
|
52
|
+
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
53
|
+
'Vienotība', 'Zaļo un Zemnieku savienība'],
|
54
|
+
['Jaunā konservatīvā partija',
|
55
|
+
'Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
56
|
+
'Zaļo un Zemnieku savienība'],
|
57
|
+
['Nacionālā apvienība „Visu Latvijai!”–„Tēvzemei un Brīvībai/LNNK”',
|
58
|
+
'Vienotība', 'Zaļo un Zemnieku savienība']]
|
59
|
+
end
|
60
|
+
|
61
|
+
def no_of_seats
|
62
|
+
SEAT_DISTRIBUTION.values.inject(:+)
|
63
|
+
end
|
64
|
+
|
65
|
+
def overall_election_results_of_2014
|
66
|
+
if @overall_election_results_of_2014.nil?
|
67
|
+
@overall_election_results_of_2014 = \
|
68
|
+
summarize_election_results(election_results_of_2014)
|
69
|
+
end
|
70
|
+
@overall_election_results_of_2014
|
71
|
+
end
|
72
|
+
|
73
|
+
def population_size
|
74
|
+
# Voter turnout on 4 October 2014
|
75
|
+
913_491
|
76
|
+
end
|
77
|
+
|
78
|
+
def seats(simulation)
|
79
|
+
electoral_system.project(simulation)
|
80
|
+
end
|
81
|
+
|
82
|
+
def threshold
|
83
|
+
THRESHOLD
|
84
|
+
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
SEAT_DISTRIBUTION = { 'Kurzeme' => 13, 'Latgale' => 15, 'Rīga' => 32,
|
89
|
+
'Vidzeme' => 26, 'Zemgale' => 14 }.freeze
|
90
|
+
|
91
|
+
THRESHOLD = 0.05
|
92
|
+
|
93
|
+
def election_results_of_2014
|
94
|
+
if @election_results_of_2014.nil?
|
95
|
+
@election_results_of_2014 = load_election_results(
|
96
|
+
'latvia-20141004-kpv-par.psv'
|
97
|
+
)
|
98
|
+
end
|
99
|
+
@election_results_of_2014
|
100
|
+
end
|
101
|
+
|
102
|
+
def electoral_system
|
103
|
+
if @electoral_system.nil?
|
104
|
+
@electoral_system = MultiDistrictProportional.new( \
|
105
|
+
overall_election_results_of_2014, election_results_of_2014,
|
106
|
+
SEAT_DISTRIBUTION, SainteLagueDenominators, 0, THRESHOLD
|
107
|
+
)
|
108
|
+
end
|
109
|
+
@electoral_system
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# Statistical Analysis of Polling Results (SAPoR)
|
2
|
+
# Copyright (C) 2016 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
3
|
+
#
|
4
|
+
# This file is part of SAPoR.
|
5
|
+
#
|
6
|
+
# SAPoR is free software: you can redistribute it and/or modify it under the
|
7
|
+
# terms of the GNU General Public License as published by the Free Software
|
8
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
9
|
+
# version.
|
10
|
+
#
|
11
|
+
# SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
|
12
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You can find a copy of the GNU General Public License in /doc/gpl.txt
|
16
|
+
#
|
17
|
+
|
18
|
+
# Source: "Résultats officieux — Site officiel des élections // Grand-Duché de
|
19
|
+
# Luxembourg". Retrieved on 20 September 2018.
|
20
|
+
# URL: https://elections.public.lu/fr/elections-legislatives/2013/resultats.html
|
21
|
+
|
22
|
+
Centre | Chrëschtlech-Sozial Vollekspartei | 385,390
|
23
|
+
Centre | Demokratesch Partei | 273,069
|
24
|
+
Centre | Lëtzebuerger Sozialistesch Aarbechterpartei | 159,905
|
25
|
+
Centre | déi gréng | 114,145
|
26
|
+
Centre | Alternativ Demokratesch Reformpartei | 54,709
|
27
|
+
Centre | Déi Lénk | 51,851
|
28
|
+
Centre | Piratepartei Lëtzebuerg | 29,633
|
29
|
+
Centre | Partei fir Integral Demokratie | 13,318
|
30
|
+
Centre | Kommunistesch Partei Lëtzebuerg | 9,425
|
31
|
+
|
32
|
+
Est | Chrëschtlech-Sozial Vollekspartei | 71,786
|
33
|
+
Est | Demokratesch Partei | 36,237
|
34
|
+
Est | Lëtzebuerger Sozialistesch Aarbechterpartei | 28,386
|
35
|
+
Est | déi gréng | 25,486
|
36
|
+
Est | Alternativ Demokratesch Reformpartei | 16,901
|
37
|
+
Est | Déi Lénk | 5,941
|
38
|
+
Est | Piratepartei Lëtzebuerg | 5,226
|
39
|
+
Est | Partei fir Integral Demokratie | 3,018
|
40
|
+
Est | Kommunistesch Partei Lëtzebuerg | 1,537
|
41
|
+
|
42
|
+
Nord | Chrëschtlech-Sozial Vollekspartei | 107,163
|
43
|
+
Nord | Demokratesch Partei | 75,426
|
44
|
+
Nord | Lëtzebuerger Sozialistesch Aarbechterpartei | 54,788
|
45
|
+
Nord | déi gréng | 28,646
|
46
|
+
Nord | Alternativ Demokratesch Reformpartei | 20,246
|
47
|
+
Nord | Piratepartei Lëtzebuerg | 10,733
|
48
|
+
Nord | Partei fir Integral Demokratie | 10,384
|
49
|
+
Nord | Déi Lénk | 8,138
|
50
|
+
Nord | Kommunistesch Partei Lëtzebuerg | 2,575
|
51
|
+
|
52
|
+
Sud | Chrëschtlech-Sozial Vollekspartei | 539,297
|
53
|
+
Sud | Lëtzebuerger Sozialistesch Aarbechterpartei | 421,507
|
54
|
+
Sud | Demokratesch Partei | 213,147
|
55
|
+
Sud | déi gréng | 163,643
|
56
|
+
Sud | Alternativ Demokratesch Reformpartei | 125,827
|
57
|
+
Sud | Déi Lénk | 95,829
|
58
|
+
Sud | Piratepartei Lëtzebuerg | 50,678
|
59
|
+
Sud | Kommunistesch Partei Lëtzebuerg | 40,132
|
60
|
+
Sud | Partei fir Integral Demokratie | 22,570
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
@@ -0,0 +1,82 @@
|
|
1
|
+
#
|
2
|
+
# Statistical Analysis of Polling Results (SAPoR)
|
3
|
+
# Copyright (C) 2016 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
4
|
+
#
|
5
|
+
# This file is part of SAPoR.
|
6
|
+
#
|
7
|
+
# SAPoR is free software: you can redistribute it and/or modify it under the
|
8
|
+
# terms of the GNU General Public License as published by the Free Software
|
9
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
10
|
+
# version.
|
11
|
+
#
|
12
|
+
# SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
|
13
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
14
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You can find a copy of the GNU General Public License in /doc/gpl.txt
|
17
|
+
#
|
18
|
+
|
19
|
+
module Sapor
|
20
|
+
#
|
21
|
+
# The regional data for Luxembourg.
|
22
|
+
#
|
23
|
+
class Luxembourg < Area
|
24
|
+
include Singleton
|
25
|
+
def area_code
|
26
|
+
'LU'
|
27
|
+
end
|
28
|
+
|
29
|
+
def coalitions
|
30
|
+
[['Chrëschtlech-Sozial Vollekspartei'],
|
31
|
+
['Chrëschtlech-Sozial Vollekspartei',
|
32
|
+
'Lëtzebuerger Sozialistesch Aarbechterpartei'],
|
33
|
+
['Chrëschtlech-Sozial Vollekspartei', 'Demokratesch Partei'],
|
34
|
+
['déi gréng', 'Demokratesch Partei',
|
35
|
+
'Lëtzebuerger Sozialistesch Aarbechterpartei']]
|
36
|
+
end
|
37
|
+
|
38
|
+
def no_of_seats
|
39
|
+
SEAT_DISTRIBUTION.values.inject(:+)
|
40
|
+
end
|
41
|
+
|
42
|
+
def overall_election_results_of_2013
|
43
|
+
if @overall_election_results_of_2013.nil?
|
44
|
+
@overall_election_results_of_2013 = \
|
45
|
+
summarize_election_results(election_results_of_2013)
|
46
|
+
end
|
47
|
+
@overall_election_results_of_2013
|
48
|
+
end
|
49
|
+
|
50
|
+
def population_size
|
51
|
+
# Voter turnout on 20 October 2013 (note: multiple votes per voter)
|
52
|
+
3_276_692
|
53
|
+
end
|
54
|
+
|
55
|
+
def seats(simulation)
|
56
|
+
electoral_system.project(simulation)
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
SEAT_DISTRIBUTION = { 'Centre' => 21, 'Est' => 7, 'Nord' => 9, 'Sud' => 23 }.freeze
|
62
|
+
|
63
|
+
def election_results_of_2013
|
64
|
+
if @election_results_of_2013.nil?
|
65
|
+
@election_results_of_2013 = load_election_results(
|
66
|
+
'luxembourg-20131020.psv'
|
67
|
+
)
|
68
|
+
end
|
69
|
+
@election_results_of_2013
|
70
|
+
end
|
71
|
+
|
72
|
+
def electoral_system
|
73
|
+
if @electoral_system.nil?
|
74
|
+
@electoral_system = MultiDistrictProportional.new( \
|
75
|
+
overall_election_results_of_2013, election_results_of_2013,
|
76
|
+
SEAT_DISTRIBUTION, DhondtDenominators
|
77
|
+
)
|
78
|
+
end
|
79
|
+
@electoral_system
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#
|
2
|
+
# Statistical Analysis of Polling Results (SAPoR)
|
3
|
+
# Copyright (C) 2016 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
4
|
+
#
|
5
|
+
# This file is part of SAPoR.
|
6
|
+
#
|
7
|
+
# SAPoR is free software: you can redistribute it and/or modify it under the
|
8
|
+
# terms of the GNU General Public License as published by the Free Software
|
9
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
10
|
+
# version.
|
11
|
+
#
|
12
|
+
# SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
|
13
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
14
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You can find a copy of the GNU General Public License in /doc/gpl.txt
|
17
|
+
#
|
18
|
+
|
19
|
+
module Sapor
|
20
|
+
#
|
21
|
+
# The regional data for Netherlands.
|
22
|
+
#
|
23
|
+
class Netherlands < Area
|
24
|
+
include Singleton
|
25
|
+
|
26
|
+
def area_code
|
27
|
+
'NL'
|
28
|
+
end
|
29
|
+
|
30
|
+
def coalitions
|
31
|
+
COALITIONS
|
32
|
+
end
|
33
|
+
|
34
|
+
def no_of_seats
|
35
|
+
NO_OF_SEATS
|
36
|
+
end
|
37
|
+
|
38
|
+
def population_size
|
39
|
+
POPULATION_SIZE
|
40
|
+
end
|
41
|
+
|
42
|
+
def seats(simulation)
|
43
|
+
electoral_system.project(simulation)
|
44
|
+
end
|
45
|
+
|
46
|
+
def threshold
|
47
|
+
THRESHOLD
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
CDA_PARTY = 'Christen-Democratisch Appèl'.freeze
|
53
|
+
CU_PARTY = 'ChristenUnie'.freeze
|
54
|
+
D66_PARTY = 'Democraten 66'.freeze
|
55
|
+
FIFTY_PARTY = '50Plus'.freeze
|
56
|
+
FVD_PARTY = 'Forum voor Democratie'.freeze
|
57
|
+
GL_PARTY = 'GroenLinks'.freeze
|
58
|
+
PVDA_PARTY = 'Partij van de Arbeid'.freeze
|
59
|
+
PVV_PARTY = 'Partij voor de Vrijheid'.freeze
|
60
|
+
SGP_PARTY = 'Staatkundig Gereformeerde Partij'.freeze
|
61
|
+
SP_PARTY = 'Socialistische Partij'.freeze
|
62
|
+
VVD_PARTY = 'Volkspartij voor Vrijheid en Democratie'.freeze
|
63
|
+
|
64
|
+
COALITIONS = [[CDA_PARTY, CU_PARTY, D66_PARTY, GL_PARTY, PVDA_PARTY],
|
65
|
+
[CDA_PARTY, CU_PARTY, D66_PARTY, GL_PARTY, PVDA_PARTY,
|
66
|
+
SP_PARTY],
|
67
|
+
[CDA_PARTY, CU_PARTY, D66_PARTY, GL_PARTY, VVD_PARTY],
|
68
|
+
[CDA_PARTY, CU_PARTY, D66_PARTY, PVDA_PARTY, VVD_PARTY],
|
69
|
+
[CDA_PARTY, CU_PARTY, D66_PARTY, VVD_PARTY],
|
70
|
+
[CDA_PARTY, CU_PARTY, PVDA_PARTY],
|
71
|
+
[CDA_PARTY, D66_PARTY],
|
72
|
+
[CDA_PARTY, D66_PARTY, PVDA_PARTY],
|
73
|
+
[CDA_PARTY, D66_PARTY, VVD_PARTY],
|
74
|
+
[CDA_PARTY, FIFTY_PARTY, FVD_PARTY, VVD_PARTY],
|
75
|
+
[CDA_PARTY, FIFTY_PARTY, FVD_PARTY, VVD_PARTY, SGP_PARTY],
|
76
|
+
[CDA_PARTY, FVD_PARTY, PVV_PARTY, SGP_PARTY, VVD_PARTY],
|
77
|
+
[CDA_PARTY, FVD_PARTY, PVV_PARTY, VVD_PARTY],
|
78
|
+
[CDA_PARTY, FVD_PARTY, SGP_PARTY, VVD_PARTY],
|
79
|
+
[CDA_PARTY, FVD_PARTY, VVD_PARTY],
|
80
|
+
[CDA_PARTY, PVDA_PARTY],
|
81
|
+
[CDA_PARTY, PVDA_PARTY, VVD_PARTY],
|
82
|
+
[CDA_PARTY, PVV_PARTY, VVD_PARTY],
|
83
|
+
[CDA_PARTY, VVD_PARTY],
|
84
|
+
[D66_PARTY, PVDA_PARTY, VVD_PARTY],
|
85
|
+
[PVDA_PARTY, VVD_PARTY]].freeze
|
86
|
+
|
87
|
+
NO_OF_SEATS = 150
|
88
|
+
|
89
|
+
# Voter turnout on 21 March 2017
|
90
|
+
# Source: Web page with the official results of the elections of 21 March
|
91
|
+
# 2017, downloaded on 10 August 2019,
|
92
|
+
# https://nl.wikipedia.org/wiki/Tweede_Kamerverkiezingen_2017
|
93
|
+
POPULATION_SIZE = 10_516_041
|
94
|
+
|
95
|
+
THRESHOLD = 1 / NO_OF_SEATS.to_f
|
96
|
+
|
97
|
+
def electoral_system
|
98
|
+
if @electoral_system.nil?
|
99
|
+
@electoral_system = SingleDistrictProportional.new(
|
100
|
+
NO_OF_SEATS,
|
101
|
+
DhondtDenominators,
|
102
|
+
THRESHOLD
|
103
|
+
)
|
104
|
+
end
|
105
|
+
@electoral_system
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
3
|
# Statistical Analysis of Polling Results (SAPoR)
|
4
|
-
# Copyright (C)
|
4
|
+
# Copyright (C) 2016 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
5
5
|
#
|
6
6
|
# This file is part of SAPoR.
|
7
7
|
#
|
@@ -21,35 +21,9 @@ module Sapor
|
|
21
21
|
#
|
22
22
|
# The regional data for Norway.
|
23
23
|
#
|
24
|
-
class Norway
|
24
|
+
class Norway < Area
|
25
25
|
include Singleton
|
26
26
|
|
27
|
-
# Source: NSD European Election Database, Parliamentary election of 2013,\
|
28
|
-
# retrieved on 14 April 2015.
|
29
|
-
# URL: http://eed.nsd.uib.no/webview/index.jsp?stubs=nuts_id&study=http%3A%2F%2F129.177.90.166%3A80%2Fobj%2FfStudy%2Fnopa2013&virtualslice=pv_p_value&measuretype=4&headers=party_name_org&mode=cube&v=2&party_name_orgsubset=1+-+9&cube=http%3A%2F%2F129.177.90.166%3A80%2Fobj%2FfCube%2Fnopa2013_C1&nuts_idsubset=NO%2CNO011+-+NO073&virtualsubset=pv_p_value&layers=virtual&measure=common&top=yes
|
30
|
-
LAST_ELECTION_RESULT = { 'Arbeiderpartiet' => 874_769,
|
31
|
-
'Høyre' => 760_232,
|
32
|
-
'Fremskrittspartiet' => 463_560,
|
33
|
-
'Kristelig Folkeparti' => 158_475,
|
34
|
-
'Senterpartiet' => 155_357,
|
35
|
-
'Venstre' => 148_275,
|
36
|
-
'Sosialistisk Venstreparti' => 116_021,
|
37
|
-
'Miljøpartiet de Grønne' => 79_152,
|
38
|
-
'Rødt' => 30_751,
|
39
|
-
'De Kristne' => 17_731,
|
40
|
-
'Pensjonistpartiet' => 11_865,
|
41
|
-
'Piratpartiet' => 9_869,
|
42
|
-
'Kystpartiet' => 3_311,
|
43
|
-
'Demokratene i Norge' => 2_214,
|
44
|
-
'Kristent Samlingsparti' => 1_722,
|
45
|
-
'Det Liberale Folkepartiet' => 909,
|
46
|
-
'Norges Kommunistiske Parti' => 611,
|
47
|
-
'Sykehus til Alta' => 467,
|
48
|
-
'Samfunnspartiet' => 295,
|
49
|
-
'Folkeliste mot oljeboring i Lofoten, Vesterålen' \
|
50
|
-
' og Senja' => 268,
|
51
|
-
'Folkemakten' => 175 }
|
52
|
-
|
53
27
|
# Source: NSD European Election Database, Parliamentary election of 2013,
|
54
28
|
# retrieved on 14 April 2015.
|
55
29
|
# URL: http://eed.nsd.uib.no/webview/index.jsp?stubs=nuts_id&study=http%3A%2F%2F129.177.90.166%3A80%2Fobj%2FfStudy%2Fnopa2013&virtualslice=pv_p_value&measuretype=4&headers=party_name_org&mode=cube&v=2&party_name_orgsubset=1+-+9&cube=http%3A%2F%2F129.177.90.166%3A80%2Fobj%2FfCube%2Fnopa2013_C1&nuts_idsubset=NO%2CNO011+-+NO073&virtualsubset=pv_p_value&layers=virtual&measure=common&top=yes
|
@@ -345,45 +319,27 @@ module Sapor
|
|
345
319
|
'Piratpartiet' => 516,
|
346
320
|
'Kystpartiet' => 68,
|
347
321
|
'Demokratene i Norge' => 99,
|
348
|
-
'Kristent Samlingsparti' => 145 }
|
322
|
+
'Kristent Samlingsparti' => 145 }
|
323
|
+
}.freeze
|
349
324
|
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
'Aust-Agder' => 3,
|
354
|
-
'Buskerud' => 8,
|
355
|
-
'Finnmark' => 4,
|
356
|
-
'Hedmark' => 6,
|
357
|
-
'Hordaland' => 15,
|
358
|
-
'Møre og Romsdal' => 8,
|
359
|
-
'Nord-Trøndelag' => 4,
|
360
|
-
'Nordland' => 8,
|
361
|
-
'Oppland' => 6,
|
362
|
-
'Oslo' => 18,
|
363
|
-
'Rogaland' => 13,
|
364
|
-
'Sogn og Fjordane' => 3,
|
365
|
-
'Sør-Trøndelag' => 9,
|
366
|
-
'Telemark' => 5,
|
367
|
-
'Troms' => 5,
|
368
|
-
'Vest-Agder' => 5,
|
369
|
-
'Vestfold' => 6,
|
370
|
-
'Østfold' => 8 }
|
371
|
-
|
372
|
-
# Source: Valg i Norge, Valgkretser, Wikipedia, retrieved on 16 April 2015.
|
373
|
-
# URL: http://no.wikipedia.org/wiki/Valg_i_Norge#Valgkretser
|
374
|
-
NO_OF_LEVELING_SEATS = 19
|
325
|
+
def area_code
|
326
|
+
'NO'
|
327
|
+
end
|
375
328
|
|
376
|
-
|
329
|
+
def coalitions
|
330
|
+
COALITIONS
|
331
|
+
end
|
377
332
|
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
NO_OF_LEVELING_SEATS,
|
382
|
-
LEVELING_THRESHOLD,
|
383
|
-
SainteLague14Denominators)
|
333
|
+
def no_of_seats
|
334
|
+
NO_OF_SEATS
|
335
|
+
end
|
384
336
|
|
385
|
-
def
|
386
|
-
|
337
|
+
def overall_election_results_of_2015
|
338
|
+
if @overall_election_results_of_2015.nil?
|
339
|
+
@overall_election_results_of_2015 = \
|
340
|
+
summarize_election_results(election_results_of_2015)
|
341
|
+
end
|
342
|
+
@overall_election_results_of_2015
|
387
343
|
end
|
388
344
|
|
389
345
|
def population_size
|
@@ -393,16 +349,77 @@ module Sapor
|
|
393
349
|
2_836_029
|
394
350
|
end
|
395
351
|
|
396
|
-
def
|
397
|
-
|
352
|
+
def seats(simulation)
|
353
|
+
electoral_system.project(simulation)
|
398
354
|
end
|
399
355
|
|
400
356
|
def threshold
|
401
|
-
|
357
|
+
LEVELING_THRESHOLD
|
402
358
|
end
|
403
359
|
|
404
|
-
|
405
|
-
|
360
|
+
private
|
361
|
+
|
362
|
+
COALITIONS = [['Arbeiderpartiet', 'Kristelig Folkeparti', 'Senterpartiet'],
|
363
|
+
['Arbeiderpartiet', 'Kristelig Folkeparti',
|
364
|
+
'Miljøpartiet de Grønne', 'Senterpartiet',
|
365
|
+
'Sosialistisk Venstreparti'],
|
366
|
+
['Arbeiderpartiet', 'Miljøpartiet de Grønne', 'Rødt',
|
367
|
+
'Senterpartiet', 'Sosialistisk Venstreparti'],
|
368
|
+
['Arbeiderpartiet', 'Miljøpartiet de Grønne', 'Senterpartiet',
|
369
|
+
'Sosialistisk Venstreparti'],
|
370
|
+
['Arbeiderpartiet', 'Rødt', 'Senterpartiet',
|
371
|
+
'Sosialistisk Venstreparti'],
|
372
|
+
['Arbeiderpartiet', 'Senterpartiet',
|
373
|
+
'Sosialistisk Venstreparti'],
|
374
|
+
%w(Arbeiderpartiet Senterpartiet),
|
375
|
+
['Arbeiderpartiet', 'Sosialistisk Venstreparti'],
|
376
|
+
%w(Fremskrittspartiet Høyre),
|
377
|
+
['Fremskrittspartiet', 'Høyre', 'Kristelig Folkeparti',
|
378
|
+
'Miljøpartiet de Grønne', 'Venstre'],
|
379
|
+
['Fremskrittspartiet', 'Høyre', 'Kristelig Folkeparti',
|
380
|
+
'Senterpartiet', 'Venstre'],
|
381
|
+
['Fremskrittspartiet', 'Høyre', 'Kristelig Folkeparti',
|
382
|
+
'Venstre'],
|
383
|
+
['Høyre', 'Kristelig Folkeparti', 'Venstre'],
|
384
|
+
['Kristelig Folkeparti', 'Senterpartiet', 'Venstre']].freeze
|
385
|
+
|
386
|
+
# Source: Valg i Norge, Valgkretser, Wikipedia, retrieved on 1 May 2015.
|
387
|
+
# URL: http://no.wikipedia.org/wiki/Valg_i_Norge#Valgkretser
|
388
|
+
DIRECT_SEAT_DISTRIBUTION = { 'Akershus' => 16, 'Aust-Agder' => 3,
|
389
|
+
'Buskerud' => 8, 'Finnmark' => 4,
|
390
|
+
'Hedmark' => 6, 'Hordaland' => 15,
|
391
|
+
'Møre og Romsdal' => 8, 'Nord-Trøndelag' => 4,
|
392
|
+
'Nordland' => 8, 'Oppland' => 6, 'Oslo' => 18,
|
393
|
+
'Rogaland' => 13, 'Sogn og Fjordane' => 3,
|
394
|
+
'Sør-Trøndelag' => 9, 'Telemark' => 5,
|
395
|
+
'Troms' => 5, 'Vest-Agder' => 5,
|
396
|
+
'Vestfold' => 6, 'Østfold' => 8 }.freeze
|
397
|
+
|
398
|
+
LEVELING_THRESHOLD = 0.04
|
399
|
+
|
400
|
+
# Source: Valg i Norge, Valgkretser, Wikipedia, retrieved on 16 April 2015.
|
401
|
+
# URL: http://no.wikipedia.org/wiki/Valg_i_Norge#Valgkretser
|
402
|
+
NO_OF_LEVELING_SEATS = 19
|
403
|
+
|
404
|
+
NO_OF_SEATS = NO_OF_LEVELING_SEATS + \
|
405
|
+
DIRECT_SEAT_DISTRIBUTION.values.inject(:+)
|
406
|
+
|
407
|
+
def election_results_of_2015
|
408
|
+
if @election_results_of_2015.nil?
|
409
|
+
@election_results_of_2015 = LAST_DETAILED_ELECTION_RESULT
|
410
|
+
end
|
411
|
+
@election_results_of_2015
|
412
|
+
end
|
413
|
+
|
414
|
+
def electoral_system
|
415
|
+
if @electoral_system.nil?
|
416
|
+
@electoral_system = MultiDistrictLeveledProportional.new(
|
417
|
+
overall_election_results_of_2015, election_results_of_2015,
|
418
|
+
DIRECT_SEAT_DISTRIBUTION, NO_OF_LEVELING_SEATS, LEVELING_THRESHOLD,
|
419
|
+
SainteLague14Denominators
|
420
|
+
)
|
421
|
+
end
|
422
|
+
@electoral_system
|
406
423
|
end
|
407
424
|
end
|
408
425
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Statistical Analysis of Polling Results (SAPoR)
|
4
|
+
# Copyright (C) 2016 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
5
|
+
#
|
6
|
+
# This file is part of SAPoR.
|
7
|
+
#
|
8
|
+
# SAPoR is free software: you can redistribute it and/or modify it under the
|
9
|
+
# terms of the GNU General Public License as published by the Free Software
|
10
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
11
|
+
# version.
|
12
|
+
#
|
13
|
+
# SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
|
14
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
15
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You can find a copy of the GNU General Public License in /doc/gpl.txt
|
18
|
+
#
|
19
|
+
|
20
|
+
module Sapor
|
21
|
+
#
|
22
|
+
# The regional data for Oslo.
|
23
|
+
#
|
24
|
+
class NorwegianMunicipality < Area
|
25
|
+
attr_reader :area_code, :no_of_seats, :population_size
|
26
|
+
|
27
|
+
def initialize(municipality_key, population_size, no_of_seats)
|
28
|
+
@area_code = 'NO-' + municipality_key
|
29
|
+
@population_size = population_size
|
30
|
+
@no_of_seats = no_of_seats
|
31
|
+
@electoral_system = SingleDistrictProportional.new( \
|
32
|
+
no_of_seats, SainteLague14Denominators)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Population sizes are equal to the electorate of 2013.
|
36
|
+
# Source: https://www.regjeringen.no/html/kmd/valgresultat/2013/bss.html
|
37
|
+
# Exception: Oslo, for which there is a projection for 2015.
|
38
|
+
# Source:
|
39
|
+
# https://www.ssb.no/valg/statistikker/stemmerettkomm/hvert-4-aar-forelopige/2015-04-13?fane=tabell&sort=nummer&tabell=223755
|
40
|
+
BERGEN = NorwegianMunicipality.new('1201', 193_348, 67)
|
41
|
+
OSLO = NorwegianMunicipality.new('0301', 511_400, 59)
|
42
|
+
TRONDHEIM = NorwegianMunicipality.new('1601', 131_524, 67)
|
43
|
+
|
44
|
+
def coalitions
|
45
|
+
[['Høyre', 'Kristelig Folkeparti', 'Venstre'],
|
46
|
+
%w(Fremskrittspartiet Høyre),
|
47
|
+
['Fremskrittspartiet', 'Høyre', 'Kristelig Folkeparti', 'Venstre'],
|
48
|
+
['Fremskrittspartiet', 'Høyre', 'Kristelig Folkeparti',
|
49
|
+
'Miljøpartiet de Grønne', 'Venstre'],
|
50
|
+
['Fremskrittspartiet', 'Høyre', 'Kristelig Folkeparti', 'Senterpartiet',
|
51
|
+
'Venstre'],
|
52
|
+
['Arbeiderpartiet', 'Senterpartiet', 'Sosialistisk Venstreparti'],
|
53
|
+
['Arbeiderpartiet', 'Miljøpartiet de Grønne', 'Rødt', 'Senterpartiet',
|
54
|
+
'Sosialistisk Venstreparti'],
|
55
|
+
['Arbeiderpartiet', 'Kristelig Folkeparti', 'Miljøpartiet de Grønne',
|
56
|
+
'Senterpartiet', 'Sosialistisk Venstreparti'],
|
57
|
+
['Arbeiderpartiet', 'Miljøpartiet de Grønne', 'Senterpartiet',
|
58
|
+
'Sosialistisk Venstreparti'],
|
59
|
+
['Arbeiderpartiet', 'Rødt', 'Senterpartiet',
|
60
|
+
'Sosialistisk Venstreparti'],
|
61
|
+
['Kristelig Folkeparti', 'Senterpartiet', 'Venstre']]
|
62
|
+
end
|
63
|
+
|
64
|
+
def seats(simulation)
|
65
|
+
@electoral_system.project(simulation)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|