Skip to content

Commit

Permalink
update filters
Browse files Browse the repository at this point in the history
  • Loading branch information
szufix committed Feb 7, 2024
1 parent e61ac00 commit 5d01fa9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions prefsampling/filters/approval_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def rename_approval_candidates(


def resampling_filter(
votes: list[set[int]], phi: float, seed: int = None
votes: list[set[int]], num_candidates, phi: float, p, seed: int = None
) -> list[set[int]]:
"""
Returns votes with added resampling filter.
Expand All @@ -65,8 +65,12 @@ def resampling_filter(
----------
votes : list[set[int]]
Approval votes.
num_candidates : int
Number of Candidates.
phi : float
Noise parameter.
p : float
Resampling model parameter, denoting the average vote length.
seed : int
Seed for numpy random number generator.
Expand All @@ -76,8 +80,8 @@ def resampling_filter(
Approval votes.
"""

return [_resampling_filter_vote(votes[i], phi, seed) for i in range(len(votes))]
return [_resampling_filter_vote(votes[i], num_candidates, phi, p, seed) for i in range(len(votes))]


def _resampling_filter_vote(vote, phi: float, seed: int = None):
return resampling(1, len(vote), phi, seed, central_vote=vote)[0]
def _resampling_filter_vote(vote, num_candidates, phi: float, p, seed: int = None):
return resampling(1, num_candidates, phi, p, seed, central_vote=vote)[0]

0 comments on commit 5d01fa9

Please sign in to comment.