@@ -11,9 +11,11 @@ def __init__(self):
1111 {"num_voters" : 1 , "num_candidates" : 6 , "phi" : 0.25 , "p" : 0.5 },
1212 {"num_voters" : 1 , "num_candidates" : 6 , "phi" : 0.5 , "p" : 0.5 },
1313 {"num_voters" : 1 , "num_candidates" : 6 , "phi" : 0.75 , "p" : 0.5 },
14+ {"num_voters" : 1 , "num_candidates" : 6 , "phi" : 1. , "p" : 0.5 },
1415 {"num_voters" : 1 , "num_candidates" : 6 , "phi" : 0.25 , "p" : 0.34 },
1516 {"num_voters" : 1 , "num_candidates" : 6 , "phi" : 0.5 , "p" : 0.34 },
1617 {"num_voters" : 1 , "num_candidates" : 6 , "phi" : 0.75 , "p" : 0.34 },
18+ {"num_voters" : 1 , "num_candidates" : 6 , "phi" : 1. , "p" : 0.34 },
1719 ]
1820 super (ApprovalResamplingValidator , self ).__init__ (
1921 parameters_list ,
@@ -53,3 +55,49 @@ def theoretical_distribution(self, sampler_parameters, all_outcomes) -> dict:
5355 def sample_cast (self , sample ):
5456 return str (sample [0 ])
5557
58+
59+ class ApprovalDisjointResamplingValidator (Validator ):
60+ def __init__ (self ):
61+ parameters_list = [
62+ {"num_voters" : 1 , "num_candidates" : 4 , "phi" : 0.5 , "p" : 0.25 , "g" : 2 },
63+ # {"num_voters": 1, "num_candidates": 6, "phi": 0.5, "p": 0.33, "g": 2},
64+ # {"num_voters": 1, "num_candidates": 6, "phi": 0.5, "p": 0.25, "g": 3},
65+ # {"num_voters": 1, "num_candidates": 6, "phi": 0.5, "p": 0.33, "g": 3},
66+ ]
67+ super (ApprovalDisjointResamplingValidator , self ).__init__ (
68+ parameters_list ,
69+ "Disjoint Resampling" ,
70+ "disjoint_resampling" ,
71+ True ,
72+ sampler_func = resampling ,
73+ constant_parameters = ("num_voters" , "num_candidates" , "phi" ),
74+ faceted_parameters = ("phi" , "p" ),
75+ )
76+
77+ def all_outcomes (self , sampler_parameters ):
78+ return get_all_subsets (sampler_parameters ["num_candidates" ])
79+
80+ def theoretical_distribution (self , sampler_parameters , all_outcomes ) -> dict :
81+ m = sampler_parameters ["num_candidates" ]
82+ p = sampler_parameters ["p" ]
83+ phi = sampler_parameters ["phi" ]
84+ k = math .floor (p * m )
85+ central_vote = {i for i in range (k )}
86+
87+ A = {}
88+ for outcome in all_outcomes :
89+ prob = 1
90+ for c in range (m ):
91+ if c in central_vote and c in outcome :
92+ prob *= (1 - phi ) + phi * p
93+ elif c in central_vote and c not in outcome :
94+ prob *= phi * (1 - p )
95+ elif c not in central_vote and c in outcome :
96+ prob *= phi * p
97+ else :
98+ prob *= (1 - phi ) + phi * (1 - p )
99+ A [str (outcome )] = prob
100+ return A
101+
102+ def sample_cast (self , sample ):
103+ return str (sample [0 ])
0 commit comments