diff --git a/docs-source/source/quickstart.rst b/docs-source/source/quickstart.rst index 304f0ee..c269793 100644 --- a/docs-source/source/quickstart.rst +++ b/docs-source/source/quickstart.rst @@ -123,6 +123,9 @@ Reference: :py:mod:`prefsampling.approval` * - :py:func:`~prefsampling.approval.impartial` - :code:`p` - --- + * - :py:func:`~prefsampling.approval.impartial_constant_size` + - :code:`num_approvals` + - --- * - :py:func:`~prefsampling.approval.resampling` - | :code:`p` | :code:`phi` diff --git a/docs/_modules/prefsampling/approval/euclidean.html b/docs/_modules/prefsampling/approval/euclidean.html index b0e03ae..c459e88 100644 --- a/docs/_modules/prefsampling/approval/euclidean.html +++ b/docs/_modules/prefsampling/approval/euclidean.html @@ -279,7 +279,9 @@

Source code for prefsampling.approval.euclidean

-import numpy as np
+from __future__ import annotations
+
+import numpy as np
 
 from prefsampling.core.euclidean import election_positions, EuclideanSpace
 from prefsampling.inputvalidators import validate_num_voters_candidates
diff --git a/docs/_modules/prefsampling/approval/identity.html b/docs/_modules/prefsampling/approval/identity.html
index 1b1a21a..a284b76 100644
--- a/docs/_modules/prefsampling/approval/identity.html
+++ b/docs/_modules/prefsampling/approval/identity.html
@@ -279,7 +279,9 @@ 

Source code for prefsampling.approval.identity

-from prefsampling.inputvalidators import validate_num_voters_candidates
+from __future__ import annotations
+
+from prefsampling.inputvalidators import validate_num_voters_candidates
 
 
 
diff --git a/docs/_modules/prefsampling/approval/impartial.html b/docs/_modules/prefsampling/approval/impartial.html index 1171630..acbd2fa 100644 --- a/docs/_modules/prefsampling/approval/impartial.html +++ b/docs/_modules/prefsampling/approval/impartial.html @@ -279,9 +279,11 @@

Source code for prefsampling.approval.impartial

-import numpy as np
+from __future__ import annotations
 
-from prefsampling.inputvalidators import validate_num_voters_candidates
+import numpy as np
+
+from prefsampling.inputvalidators import validate_num_voters_candidates, validate_int
 
 
 
@@ -297,6 +299,9 @@

Source code for prefsampling.approval.impartial

< probability :code:`p` of being approved. This models ensures that the average number of approved candidate per voter is `p * num_candidate`. + A collection of `num_voters` vote is generated independently and identically following the + process described above. + Parameters ---------- num_voters : int @@ -320,7 +325,7 @@

Source code for prefsampling.approval.impartial

< """ if p < 0 or 1 < p: - raise ValueError(f"Incorrect value of p: {p}. Value should be in [0,1]") + raise ValueError(f"Incorrect value of p: {p}. Value should be in [0, 1]") rng = np.random.default_rng(seed) @@ -331,6 +336,61 @@

Source code for prefsampling.approval.impartial

< return votes
+ + +
+[docs] +@validate_num_voters_candidates +def impartial_constant_size( + num_voters: int, num_candidates: int, num_approvals: int, seed: int = None +) -> list[set]: + """ + Generates approval votes from impartial culture with constant size. + + Under this culture, all ballots are of size :code:`num_approvals`. The ballot is selected + uniformly at random over all ballots of size :code:`num_approvals`. + + A collection of `num_voters` vote is generated independently and identically following the + process described above. + + Parameters + ---------- + num_voters : int + Number of Voters. + num_candidates : int + Number of Candidates. + num_approvals : int + Number of approvals per ballot, i.e., size of the approval ballot. + seed : int + Seed for numpy random number generator. + + Returns + ------- + list[set] + Approval votes. + + Raises + ------ + TypeError + When `num_approvals` is not an int. + ValueError + When `num_approvals` is not in [0, num_candidates] interval. + """ + + validate_int(num_approvals, "number of approvals", lower_bound=0) + if num_approvals > num_candidates: + raise ValueError("The number of approval is higher than the number of candidates:" + f" {num_approvals} > {num_candidates}.") + + rng = np.random.default_rng(seed) + candidate_range = range(num_candidates) + votes = [ + set(rng.choice(candidate_range, size=num_approvals, replace=False)) + for _ in range(num_voters) + ] + + return votes
+
diff --git a/docs/_modules/prefsampling/approval/noise.html b/docs/_modules/prefsampling/approval/noise.html index 8bd35cb..67d16d2 100644 --- a/docs/_modules/prefsampling/approval/noise.html +++ b/docs/_modules/prefsampling/approval/noise.html @@ -279,12 +279,15 @@

Source code for prefsampling.approval.noise

-import math
+from __future__ import annotations
+
+import math
 from enum import Enum
 
 import numpy as np
 
 from prefsampling.inputvalidators import validate_num_voters_candidates
+from prefsampling.utils import comb
 
 
 
@@ -330,6 +333,9 @@

Source code for prefsampling.approval.noise

     """
     Generates approval votes under the noise model.
 
+    A collection of `num_voters` vote is generated independently and identically following the
+    process described above.
+
     Parameters
     ----------
         num_voters : int
@@ -375,9 +381,9 @@ 

Source code for prefsampling.approval.noise

 
     # Prepare buckets
     for x in range(len(A) + 1):
-        num_options_in = math.comb(len(A), x)
+        num_options_in = comb(len(A), x)
         for y in range(len(B) + 1):
-            num_options_out = math.comb(len(B), y)
+            num_options_out = comb(len(B), y)
 
             if noise_type == NoiseType.HAMMING:
                 factor = phi ** (len(A) - x + y)
diff --git a/docs/_modules/prefsampling/approval/resampling.html b/docs/_modules/prefsampling/approval/resampling.html
index 731ddaf..57dc02e 100644
--- a/docs/_modules/prefsampling/approval/resampling.html
+++ b/docs/_modules/prefsampling/approval/resampling.html
@@ -279,7 +279,9 @@ 

Source code for prefsampling.approval.resampling

-import copy
+from __future__ import annotations
+
+import copy
 
 import math
 import numpy as np
diff --git a/docs/_modules/prefsampling/approval/truncated_ordinal.html b/docs/_modules/prefsampling/approval/truncated_ordinal.html
index ce5b211..5e1b3d0 100644
--- a/docs/_modules/prefsampling/approval/truncated_ordinal.html
+++ b/docs/_modules/prefsampling/approval/truncated_ordinal.html
@@ -279,7 +279,9 @@ 

Source code for prefsampling.approval.truncated_ordinal

-from collections.abc import Callable
+from __future__ import annotations
+
+from collections.abc import Callable
 
 from prefsampling.inputvalidators import validate_num_voters_candidates
 
diff --git a/docs/_modules/prefsampling/core/composition.html b/docs/_modules/prefsampling/core/composition.html
index 566d363..5786a45 100644
--- a/docs/_modules/prefsampling/core/composition.html
+++ b/docs/_modules/prefsampling/core/composition.html
@@ -279,7 +279,9 @@ 

Source code for prefsampling.core.composition

-from collections.abc import Callable
+from __future__ import annotations
+
+from collections.abc import Callable
 
 import numpy as np
 
diff --git a/docs/_modules/prefsampling/core/euclidean.html b/docs/_modules/prefsampling/core/euclidean.html
index cca4ab4..522b698 100644
--- a/docs/_modules/prefsampling/core/euclidean.html
+++ b/docs/_modules/prefsampling/core/euclidean.html
@@ -279,7 +279,9 @@ 

Source code for prefsampling.core.euclidean

-from enum import Enum
+from __future__ import annotations
+
+from enum import Enum
 
 import numpy as np
 
diff --git a/docs/_modules/prefsampling/core/filters.html b/docs/_modules/prefsampling/core/filters.html
index 38fc43e..a366069 100644
--- a/docs/_modules/prefsampling/core/filters.html
+++ b/docs/_modules/prefsampling/core/filters.html
@@ -282,6 +282,7 @@ 

Source code for prefsampling.core.filters

 """
 Filters are functions that operate on collections of votes and apply some random operation to them.
 """
+
 from __future__ import annotations
 
 from collections.abc import MutableSequence, Callable
diff --git a/docs/_modules/prefsampling/ordinal/didi.html b/docs/_modules/prefsampling/ordinal/didi.html
index d84e6ae..b5b8b88 100644
--- a/docs/_modules/prefsampling/ordinal/didi.html
+++ b/docs/_modules/prefsampling/ordinal/didi.html
@@ -279,7 +279,9 @@ 

Source code for prefsampling.ordinal.didi

-import numpy as np
+from __future__ import annotations
+
+import numpy as np
 
 from prefsampling.inputvalidators import validate_num_voters_candidates
 
@@ -331,8 +333,8 @@ 

Source code for prefsampling.ordinal.didi

             "Incorrect length of alphas vector. Should be equal to num_candidates."
         )
 
-    if not all(a >= 0 for a in alphas):
-        raise ValueError("The values of the alpha vector should all be positive.")
+    if not all(a > 0 for a in alphas):
+        raise ValueError("The values of the alpha vector should all be strictly positive.")
 
     rng = np.random.default_rng(seed)
 
diff --git a/docs/_modules/prefsampling/ordinal/euclidean.html b/docs/_modules/prefsampling/ordinal/euclidean.html
index cdbccc0..2939649 100644
--- a/docs/_modules/prefsampling/ordinal/euclidean.html
+++ b/docs/_modules/prefsampling/ordinal/euclidean.html
@@ -279,7 +279,9 @@ 

Source code for prefsampling.ordinal.euclidean

-import numpy as np
+from __future__ import annotations
+
+import numpy as np
 from numpy import linalg
 
 from prefsampling.core.euclidean import election_positions, EuclideanSpace
diff --git a/docs/_modules/prefsampling/ordinal/groupseparable.html b/docs/_modules/prefsampling/ordinal/groupseparable.html
index da1b004..6d07ffd 100644
--- a/docs/_modules/prefsampling/ordinal/groupseparable.html
+++ b/docs/_modules/prefsampling/ordinal/groupseparable.html
@@ -279,7 +279,9 @@ 

Source code for prefsampling.ordinal.groupseparable

-import math
+from __future__ import annotations
+
+import math
 from enum import Enum
 from itertools import chain
 
@@ -293,6 +295,7 @@ 

Source code for prefsampling.ordinal.groupseparable

from prefsampling.tree.caterpillar import caterpillar_tree from prefsampling.tree.balanced import balanced_tree from prefsampling.inputvalidators import validate_num_voters_candidates +from prefsampling.utils import comb
@@ -446,7 +449,7 @@

Source code for prefsampling.ordinal.groupseparable

of internal nodes `r` based on the formula from `Karpov (2019) <https://link.springer.com/article/10.1007/s10726-019-09621-w>`_ """ - return math.comb(m - 1, r) * math.comb(m - 1 + r, m) * (2 ** (n - 1) - 1) ** (r - 1) + return comb(m - 1, r) * comb(m - 1 + r, m) * (2 ** (n - 1) - 1) ** (r - 1) def _sample_a_vote(node, reverse=False): diff --git a/docs/_modules/prefsampling/ordinal/identity.html b/docs/_modules/prefsampling/ordinal/identity.html index f4fef25..732d002 100644 --- a/docs/_modules/prefsampling/ordinal/identity.html +++ b/docs/_modules/prefsampling/ordinal/identity.html @@ -279,7 +279,9 @@

Source code for prefsampling.ordinal.identity

-import numpy as np
+from __future__ import annotations
+
+import numpy as np
 
 from prefsampling.inputvalidators import validate_num_voters_candidates
 
diff --git a/docs/_modules/prefsampling/ordinal/impartial.html b/docs/_modules/prefsampling/ordinal/impartial.html
index 4aec30b..3005fde 100644
--- a/docs/_modules/prefsampling/ordinal/impartial.html
+++ b/docs/_modules/prefsampling/ordinal/impartial.html
@@ -279,7 +279,9 @@ 

Source code for prefsampling.ordinal.impartial

-import math
+from __future__ import annotations
+
+import math
 
 import numpy as np
 
diff --git a/docs/_modules/prefsampling/ordinal/mallows.html b/docs/_modules/prefsampling/ordinal/mallows.html
index f3f0016..17be8e9 100644
--- a/docs/_modules/prefsampling/ordinal/mallows.html
+++ b/docs/_modules/prefsampling/ordinal/mallows.html
@@ -279,7 +279,9 @@ 

Source code for prefsampling.ordinal.mallows

-import numpy as np
+from __future__ import annotations
+
+import numpy as np
 
 from prefsampling.inputvalidators import validate_num_voters_candidates
 from prefsampling.ordinal import impartial
diff --git a/docs/_modules/prefsampling/ordinal/plackettluce.html b/docs/_modules/prefsampling/ordinal/plackettluce.html
index f184a49..51e16fe 100644
--- a/docs/_modules/prefsampling/ordinal/plackettluce.html
+++ b/docs/_modules/prefsampling/ordinal/plackettluce.html
@@ -279,7 +279,7 @@ 

Source code for prefsampling.ordinal.plackettluce

-import copy
+from __future__ import annotations
 
 import numpy as np
 
diff --git a/docs/_modules/prefsampling/ordinal/singlecrossing.html b/docs/_modules/prefsampling/ordinal/singlecrossing.html
index 4e11d6b..15fb24f 100644
--- a/docs/_modules/prefsampling/ordinal/singlecrossing.html
+++ b/docs/_modules/prefsampling/ordinal/singlecrossing.html
@@ -279,7 +279,9 @@ 

Source code for prefsampling.ordinal.singlecrossing

-import numpy as np
+from __future__ import annotations
+
+import numpy as np
 
 from prefsampling.inputvalidators import validate_num_voters_candidates
 
diff --git a/docs/_modules/prefsampling/ordinal/singlepeaked.html b/docs/_modules/prefsampling/ordinal/singlepeaked.html
index 3cfbe22..4f21e4f 100644
--- a/docs/_modules/prefsampling/ordinal/singlepeaked.html
+++ b/docs/_modules/prefsampling/ordinal/singlepeaked.html
@@ -279,7 +279,9 @@ 

Source code for prefsampling.ordinal.singlepeaked

-import numpy as np
+from __future__ import annotations
+
+import numpy as np
 
 from prefsampling.inputvalidators import validate_num_voters_candidates
 
diff --git a/docs/_modules/prefsampling/ordinal/urn.html b/docs/_modules/prefsampling/ordinal/urn.html
index 74eb502..511e857 100644
--- a/docs/_modules/prefsampling/ordinal/urn.html
+++ b/docs/_modules/prefsampling/ordinal/urn.html
@@ -279,7 +279,9 @@ 

Source code for prefsampling.ordinal.urn

-import numpy as np
+from __future__ import annotations
+
+import numpy as np
 
 from prefsampling.inputvalidators import validate_num_voters_candidates
 
diff --git a/docs/_modules/prefsampling/tree/caterpillar.html b/docs/_modules/prefsampling/tree/caterpillar.html
index 48092a8..9fc7a4c 100644
--- a/docs/_modules/prefsampling/tree/caterpillar.html
+++ b/docs/_modules/prefsampling/tree/caterpillar.html
@@ -279,7 +279,9 @@ 

Source code for prefsampling.tree.caterpillar

-from prefsampling.inputvalidators import validate_int
+from __future__ import annotations
+
+from prefsampling.inputvalidators import validate_int
 from prefsampling.tree.node import Node
 
 
diff --git a/docs/_modules/prefsampling/tree/schroeder.html b/docs/_modules/prefsampling/tree/schroeder.html
index bf9d054..72f0085 100644
--- a/docs/_modules/prefsampling/tree/schroeder.html
+++ b/docs/_modules/prefsampling/tree/schroeder.html
@@ -288,6 +288,7 @@ 

Source code for prefsampling.tree.schroeder

 
 from prefsampling.inputvalidators import validate_int
 from prefsampling.tree.node import Node
+from prefsampling.utils import comb
 
 
 def validate_num_leaves_nodes(num_leaves: int, num_internal_nodes: int | None):
@@ -333,8 +334,8 @@ 

Source code for prefsampling.tree.schroeder

 
 def _num_schroeder_tree(num_internal_nodes, num_leaves):
     return (
-        math.comb(num_leaves - 1, num_internal_nodes)
-        * math.comb(num_leaves - 1 + num_internal_nodes, num_leaves)
+        comb(num_leaves - 1, num_internal_nodes)
+        * comb(num_leaves - 1 + num_internal_nodes, num_leaves)
         / (num_leaves - 1)
     )
 
diff --git a/docs/_sources/quickstart.rst b/docs/_sources/quickstart.rst
index 304f0ee..c269793 100644
--- a/docs/_sources/quickstart.rst
+++ b/docs/_sources/quickstart.rst
@@ -123,6 +123,9 @@ Reference: :py:mod:`prefsampling.approval`
    * - :py:func:`~prefsampling.approval.impartial`
      - :code:`p`
      - ---
+   * - :py:func:`~prefsampling.approval.impartial_constant_size`
+     - :code:`num_approvals`
+     - ---
    * - :py:func:`~prefsampling.approval.resampling`
      - | :code:`p`
        | :code:`phi`
diff --git a/docs/genindex.html b/docs/genindex.html
index dd8a0f0..2652136 100644
--- a/docs/genindex.html
+++ b/docs/genindex.html
@@ -407,15 +407,17 @@ 

I

  • (in module prefsampling.ordinal)
  • - - + diff --git a/docs/objects.inv b/docs/objects.inv index ba6f5d6..a4510b2 100644 Binary files a/docs/objects.inv and b/docs/objects.inv differ diff --git a/docs/quickstart.html b/docs/quickstart.html index a408caf..b0a3100 100644 --- a/docs/quickstart.html +++ b/docs/quickstart.html @@ -497,7 +497,11 @@

    Approval Samplersp

    -

    resampling()

    +

    impartial_constant_size()

    +

    num_approvals

    +

    + +

    resampling()

    p
    phi
    @@ -509,7 +513,7 @@

    Approval Samplers

    disjoint_resampling()

    +

    disjoint_resampling()

    p
    phi
    @@ -517,7 +521,7 @@

    Approval Samplersg (defaults to 2)

    -

    moving_resampling()

    +

    moving_resampling()

    p
    phi
    @@ -525,7 +529,7 @@

    Approval Samplersnum_legs (defaults to 1)

    -

    euclidean()

    +

    euclidean()

    radius (defaults to 0.5)
    @@ -534,7 +538,7 @@

    Approval Samplers

    noise()

    +

    noise()

    p
    phi
    @@ -542,7 +546,7 @@

    Approval Samplersnoise_type (defaults to HAMMING)

    -

    truncated_ordinal()

    +

    truncated_ordinal()

    p
    ordinal_sampler
    @@ -551,7 +555,7 @@

    Approval Samplers

    urn_partylist()

    +

    urn_partylist()

    alpha
    parties
    diff --git a/docs/reference/approval/index.html b/docs/reference/approval/index.html index b67dfa7..b9b4149 100644 --- a/docs/reference/approval/index.html +++ b/docs/reference/approval/index.html @@ -338,6 +338,7 @@

    Contents

  • full()
  • identity()
  • impartial()
  • +
  • impartial_constant_size()
  • moving_resampling()
  • noise()
  • resampling()
  • @@ -524,6 +525,8 @@

    Contents

    Under the approval culture, when generating a single vote, each candidate has the same probability p of being approved. This models ensures that the average number of approved candidate per voter is p * num_candidate.

    +

    A collection of num_voters vote is generated independently and identically following the +process described above.

    Parameters:
      @@ -545,6 +548,38 @@

      Contents

    +
    +
    +impartial_constant_size(num_voters: int, num_candidates: int, num_approvals: int, seed: int = None) list[set][source]#
    +

    Generates approval votes from impartial culture with constant size.

    +

    Under this culture, all ballots are of size num_approvals. The ballot is selected +uniformly at random over all ballots of size num_approvals.

    +

    A collection of num_voters vote is generated independently and identically following the +process described above.

    +
    +
    Parameters:
    +
      +
    • num_voters (int) – Number of Voters.

    • +
    • num_candidates (int) – Number of Candidates.

    • +
    • num_approvals (int) – Number of approvals per ballot, i.e., size of the approval ballot.

    • +
    • seed (int) – Seed for numpy random number generator.

    • +
    +
    +
    Returns:
    +

    Approval votes.

    +
    +
    Return type:
    +

    list[set]

    +
    +
    Raises:
    +
      +
    • TypeError – When num_approvals is not an int.

    • +
    • ValueError – When num_approvals is not in [0, num_candidates] interval.

    • +
    +
    +
    +
    +
    moving_resampling(num_voters: int, num_candidates: int, phi: float, p: float, num_legs: int = 1, seed: int = None) list[set[int]][source]#
    @@ -577,6 +612,8 @@

    Contents

    noise(num_voters: int, num_candidates: int, p: float, phi: float, noise_type: NoiseType = NoiseType.HAMMING, seed: int = None) list[set][source]#

    Generates approval votes under the noise model.

    +

    A collection of num_voters vote is generated independently and identically following the +process described above.

    Parameters:
      @@ -741,6 +778,7 @@

      Contents

    • full()
    • identity()
    • impartial()
    • +
    • impartial_constant_size()
    • moving_resampling()
    • noise()
    • resampling()
    • diff --git a/docs/reference/core/index.html b/docs/reference/core/index.html index 80063d4..eee92ed 100644 --- a/docs/reference/core/index.html +++ b/docs/reference/core/index.html @@ -529,7 +529,7 @@

      Contents

      -election_positions(num_voters: int, num_candidates: int, space: ~prefsampling.core.euclidean.EuclideanSpace, dimension: int, rng: ~numpy.random._generator.Generator) -> (<class 'numpy.ndarray'>, <class 'numpy.ndarray'>)[source]#
      +election_positions(num_voters: int, num_candidates: int, space: EuclideanSpace, dimension: int, rng: np.random.Generator)[source]#

      Returns the position of the voters and the candidates in a Euclidean space.

      Parameters:
      diff --git a/docs/reference/index.html b/docs/reference/index.html index 650b58c..bdb5af0 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -358,6 +358,7 @@

      Referencefull()
    • identity()
    • impartial()
    • +
    • impartial_constant_size()
    • moving_resampling()
    • noise()
    • resampling()
    • diff --git a/docs/searchindex.js b/docs/searchindex.js index 5cb32fe..b45a292 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({"docnames": ["index", "installation", "quickstart", "reference/approval/index", "reference/core/index", "reference/index", "reference/ordinal/index", "reference/tree/index", "validation/approval", "validation/index", "validation/ordinal", "validation/tree"], "filenames": ["index.rst", "installation.rst", "quickstart.rst", "reference/approval/index.rst", "reference/core/index.rst", "reference/index.rst", "reference/ordinal/index.rst", "reference/tree/index.rst", "validation/approval.rst", "validation/index.rst", "validation/ordinal.rst", "validation/tree.rst"], "titles": ["PrefSampling", "Installation", "Quick Start", "Approval", "Core", "Reference", "Ordinal", "Tree", "Approval Samplers", "Validation", "Ordinal Samplers", "Tree Samplers"], "terms": {"i": [0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11], "lightweight": 0, "python": [0, 2, 9], "librari": 0, "provid": [0, 2, 4, 7, 9], "prefer": [0, 2, 3, 6], "sampler": [0, 3, 5, 6, 7], "These": [0, 2, 3], "ar": [0, 2, 3, 4, 6, 7, 9, 10], "algorithm": [0, 6, 7], "gener": [0, 3, 4, 6, 7, 8, 9, 10], "random": [0, 2, 3, 4, 6, 7], "base": [0, 2, 4, 8], "precis": 0, "defin": [0, 2, 3, 4, 6], "statist": 0, "cultur": [0, 3, 6, 10], "we": [0, 2, 4, 6, 8, 9, 10, 11], "consid": [0, 2, 3, 4, 6], "differ": [0, 2, 3, 4, 6, 10], "type": [0, 3, 4, 6, 7], "ordin": [0, 3, 4, 5, 9], "express": 0, "rank": [0, 2, 6, 10], "candid": [0, 2, 3, 4, 6, 8, 10], "approv": [0, 4, 5, 9], "indic": [0, 6], "set": [0, 2, 3, 4, 6], "prefsampl": [1, 2, 4, 8, 10, 11], "host": 1, "pypi": 1, "you": [1, 2, 3, 4, 6], "can": [1, 2, 3, 4, 6, 10], "thu": [1, 8, 10, 11], "easili": 1, "us": [1, 2, 3, 4, 6, 10], "pip3": 1, "The": [1, 2, 3, 4, 6, 7, 8, 10], "sourc": [1, 3, 4, 6, 7], "code": [1, 4], "github": [1, 7], "repositori": [1, 7], "well": [1, 10], "format": [2, 4], "thei": [2, 10], "produc": [2, 10, 11], "modul": [2, 3, 5, 6], "contain": [2, 6], "ones": [2, 3], "To": [2, 6, 9], "make": [2, 9], "easi": 2, "emb": 2, "all": [2, 3, 4, 6, 7, 10, 11], "kind": 2, "tool": 2, "basic": 2, "return": [2, 3, 4, 6, 7], "collect": [2, 3, 4, 6], "np": [2, 4, 6], "ndarrai": [2, 4, 6], "numpi": [2, 3, 4, 6, 7], "arrai": 2, "where": [2, 3, 6, 10], "most": [2, 6], "posit": [2, 3, 4, 6], "0": [2, 3, 6, 10], "next": [2, 6], "one": [2, 4, 6, 7, 10], "1": [2, 3, 4, 6, 10], "so": [2, 6], "forth": 2, "each": [2, 3, 4, 6, 7, 9], "In": [2, 3, 6, 8, 10], "case": [2, 4, 6, 10], "name": [2, 3, 4, 6], "2": [2, 3, 4, 6, 10], "have": [2, 6, 10], "same": [2, 3, 4, 8, 10], "signatur": 2, "num_vot": [2, 3, 4, 6], "num_candid": [2, 3, 4, 6], "arg": 2, "seed": [2, 3, 4, 6, 7], "none": [2, 3, 4, 6, 7], "kwarg": 2, "paramet": [2, 3, 4, 6, 7, 8], "repres": [2, 3, 4, 6], "number": [2, 3, 4, 6, 7, 10, 11], "pass": [2, 3, 4], "give": [2, 7], "more": [2, 6, 8, 9, 10], "control": [2, 6], "need": [2, 4], "replic": 2, "instanc": [2, 4, 6, 10], "other": [2, 3, 4, 6, 10], "specif": [2, 4, 6, 7], "refer": 2, "ident": [2, 3, 5, 6, 9], "imparti": [2, 3, 5, 6, 9], "impartial_anonym": [2, 5, 6, 10], "mallow": [2, 5, 6, 9], "phi": [2, 3, 6, 10], "central_vot": [2, 3, 4, 6], "default": [2, 3, 6, 7], "normalise_phi": [2, 6], "fals": [2, 3, 6], "norm_mallow": [2, 5, 6], "norm_phi": [2, 6], "euclidean": [2, 3, 5, 6, 9], "space": [2, 3, 4, 6], "uniform": [2, 3, 4, 6, 7, 9, 10], "dimens": [2, 3, 4, 6], "plackett_luc": [2, 5, 6, 10], "alpha": [2, 3, 6, 10], "didi": [2, 5, 6, 9], "urn": [2, 3, 5, 6, 9], "stratif": [2, 5, 6, 9], "weight": [2, 4, 6, 10], "single_peaked_conitz": [2, 5, 6, 10], "single_peaked_walsh": [2, 5, 6, 10], "single_peaked_circl": [2, 5, 6, 10], "single_cross": [2, 5, 6, 10], "group_separ": [2, 5, 6, 10], "tree_sampl": [2, 6], "schroeder": [2, 6], "p": [2, 3, 8], "empti": [2, 3, 5, 6], "full": [2, 3, 5], "resampl": [2, 3, 4, 5, 9], "disjoint_resampl": [2, 3, 5, 8], "g": [2, 3, 4], "moving_resampl": [2, 3, 5], "num_leg": [2, 3], "radiu": [2, 3], "5": [2, 3, 6], "nois": [2, 3, 5, 9], "noise_typ": [2, 3], "ham": [2, 3, 8], "truncated_ordin": [2, 3, 5], "ordinal_sampl": [2, 3], "ordinal_sampler_paramet": [2, 3], "urn_partylist": [2, 3, 5], "parti": [2, 3], "It": [2, 4], "often": 2, "abl": 2, "compos": 2, "mixtur": [2, 4], "function": [2, 3, 4, 6], "concaten": [2, 4], "do": [2, 6], "being": [2, 3, 4, 6, 8], "given": [2, 3, 4, 6, 7, 10], "probabl": [2, 3, 4, 6, 7, 8, 10, 11], "from": [2, 3, 4, 6, 7, 9, 10], "core": [2, 5], "import": [2, 4], "creat": 2, "100": 2, "voter": [2, 3, 4, 6, 10], "10": 2, "singl": [2, 3, 6, 8, 9], "peak": [2, 6, 9], "conitz": [2, 6, 10], "6": 2, "walsh": [2, 6, 10], "4": [2, 3, 4, 6], "list": [2, 3, 4, 6, 7], "model": [2, 3, 6, 8, 10], "3": [2, 3, 4, 6], "9": 2, "23": 2, "simpli": 2, "vote": [2, 3, 4, 6, 10], "60": 2, "40": 2, "per": [2, 3, 6], "oper": [2, 4], "appli": [2, 3, 4, 6], "some": [2, 4], "them": [2, 4, 6, 7], "implement": [2, 6, 9], "effect": 2, "permute_vot": [2, 4], "randomli": [2, 4, 6], "permut": [2, 4, 6], "rename_candid": [2, 4], "renam": [2, 4], "resample_as_central_vot": [2, 4], "central": [2, 3, 4, 6], "whose": 2, "definit": [2, 6], "includ": [2, 6], "e": [2, 4, 6, 10], "below": [2, 8, 10, 11], "an": [2, 4, 6, 8, 10], "exampl": [2, 10], "how": 2, "initial_vot": 2, "855": 2, "argument": [2, 3, 4], "sampl": [3, 4, 6, 7, 8, 9], "which": [3, 4, 6], "either": [3, 6], "disapprov": 3, "class": [3, 4, 6, 10], "noisetyp": [3, 5], "valu": [3, 4, 6, 10], "qualnam": [3, 4, 6], "start": [3, 4, 6], "boundari": [3, 4, 6], "constant": [3, 4, 6], "bunke_shear": 3, "bunk": 3, "shearer": 3, "jaccard": 3, "zelinka": 3, "int": [3, 4, 6, 7], "float": [3, 4, 6], "disjoint": [3, 9], "denot": 3, "length": [3, 8, 10], "group": [3, 6, 9], "rais": [3, 6], "valueerror": [3, 6], "when": [3, 6, 10], "interv": 3, "euclideanspac": [3, 4, 6], "accord": [3, 6], "assign": [3, 6], "A": [3, 6], "within": [3, 4, 6], "certain": 3, "word": 3, "distanc": [3, 6, 8, 10], "sever": [3, 6], "possibl": [3, 6, 7], "enumer": [3, 6, 7, 11], "also": [3, 6, 9, 10], "chang": [3, 6], "independ": [3, 4, 6], "follow": [3, 4, 6, 7, 8], "process": [3, 4, 6], "describ": [3, 6, 10], "abov": [3, 6], "should": [3, 4, 6], "simpl": 3, "onli": [3, 4, 6, 8, 10], "proport": [3, 6, 7], "under": [3, 6, 10], "ha": [3, 4, 8, 10, 11], "thi": [3, 4, 6, 7, 8, 9, 10, 11], "ensur": [3, 6, 7, 9, 10], "averag": 3, "ani": [3, 4, 6], "move": 3, "leg": 3, "callabl": [3, 4], "dict": [3, 4], "truncat": 3, "wai": 3, "consist": 3, "first": [3, 6, 9], "ratio": 3, "ot": 3, "overriden": 3, "those": 3, "partylist": 3, "fraction": 3, "size": [3, 6], "ballot": [4, 8], "num_voters_per_sampl": 4, "sampler_paramet": 4, "togeth": [4, 6, 9], "form": 4, "final": [4, 6], "note": [4, 6, 10], "after": [4, 6], "onc": [4, 10], "assum": 4, "about": [4, 10], "If": [3, 4, 6, 7], "don": 4, "t": 4, "fail": 4, "dictionari": 4, "keyword": 4, "taken": [4, 7], "account": 4, "work": [4, 6, 8], "distribut": [4, 6, 8, 9, 10, 11], "correspond": [4, 6, 7], "over": [4, 6, 10], "k": [4, 6, 8], "want": [4, 9], "particular": 4, "mutablesequ": 4, "order": [4, 6], "incomplet": 4, "input": 4, "largest": 4, "integ": 4, "appear": [4, 10], "accept": 4, "copi": [4, 6], "befor": [4, 6], "avoid": 4, "loss": 4, "data": 4, "ball": 4, "gaussian": 4, "sphere": 4, "spheric": 4, "election_posit": 4, "rng": 4, "_gener": 4, "respect": [4, 6], "treesampl": [5, 6], "tree": [5, 6, 9, 10], "all_schroeder_tre": [5, 7], "caterpillar_tre": [5, 7], "schroeder_tre": [5, 7, 11], "schroeder_tree_brute_forc": [5, 7, 11], "schroeder_tree_lescann": [5, 7, 11], "composit": 5, "filter": 5, "unanim": 6, "equal": [6, 10], "like": [6, 10], "occur": [6, 10], "get": 6, "anonym": [6, 9], "everi": [6, 8, 10], "multi": 6, "For": [6, 10], "observ": [6, 8, 10], "b": 6, "wa": [6, 7], "8": 6, "see": [6, 8, 10], "lepellei": 6, "valogn": 6, "2003": 6, "here": [6, 8, 10], "bool": [3, 6], "1957": 6, "parameteris": 6, "decreas": 6, "exponenti": 6, "between": [6, 9], "dispers": 6, "coeffici": 6, "kendal": 6, "tau": 6, "consider": 6, "close": 6, "render": 6, "far": 6, "awai": 6, "unlik": 6, "opposit": 6, "depend": 6, "applic": 6, "advis": 6, "normalis": 6, "especi": 6, "compar": 6, "boehmer": 6, "faliszewski": 6, "kraiczi": 6, "2023": 6, "detail": [6, 8], "true": [3, 6], "option": [], "whether": 6, "arrang": 6, "shortcut": 6, "increas": 6, "closest": 6, "etc": 6, "plackett": [6, 9], "luce": [6, 9], "vector": 6, "intuit": 6, "qualiti": [6, 10], "m": [6, 10], "step": 6, "fill": 6, "up": 6, "least": 6, "initi": 6, "draw": 6, "select": [6, 7], "its": 6, "Then": 6, "remov": 6, "re": 6, "similar": 6, "dirichlet": 6, "moreov": 6, "higher": 6, "sum": 6, "correl": 6, "concentr": 6, "point": 6, "veri": 6, "spirit": 6, "param": 6, "len": 6, "p\u00f3lya": 6, "eggenberg": 6, "turn": 6, "happen": 6, "With": [6, 10], "urn_siz": 6, "uniformli": [6, 7], "both": 6, "put": 6, "back": [6, 10], "must": 6, "non": [6, 10], "neg": 6, "split": 6, "two": [6, 9], "second": 6, "rel": 6, "upper": 6, "2009": [6, 10], "axi": [6, 10], "left": 6, "right": 6, "come": 6, "method": 6, "iter": 6, "oppos": 6, "dist_peak_to_end": [6, 10], "minimum": [6, 10], "end": [6, 10], "2015": [6, 10], "leftmost": 6, "rightmost": 6, "yet": 6, "been": [6, 10], "circl": [6, 10], "inspir": 6, "peaked": 6, "line": 6, "determin": 6, "done": 6, "subsequ": 6, "take": 6, "avail": [6, 7], "term": 6, "circular": 6, "cross": [6, 9], "elkind": 6, "lackner": 6, "peter": 6, "2022": [6, 7, 8, 9], "domain": 6, "alwai": 6, "valid": [6, 8, 10, 11], "swap": 6, "consecut": 6, "had": 6, "alreadi": 6, "previou": 6, "One": 6, "perform": 6, "admit": 6, "importantli": [6, 9], "success": 6, "further": 6, "down": 6, "than": 6, "previous": 6, "latter": 6, "neutral": 6, "mean": 6, "lexicograph": 6, "obtain": [6, 10], "szufa": [6, 8], "skowron": 6, "slinko": 6, "talmon": 6, "2020": 6, "profil": [6, 10], "yield": [6, 10, 11], "procedur": [6, 7], "unknown": [6, 10, 11], "outcom": [6, 10], "single_crossing_imparti": 6, "becom": 6, "slow": [6, 11], "difficulti": 6, "li": 6, "comput": 6, "instead": 6, "separ": [6, 9], "seprabl": 6, "present": [6, 7, 8, 10, 11], "karpov": 6, "obraztsova": 6, "decomposit": 6, "intern": [6, 7], "node": [6, 7], "children": 6, "revers": 6, "label": 6, "leav": [6, 7, 11], "read": 6, "meant": 6, "howev": [6, 10], "our": 6, "analysi": 6, "impact": 6, "balanc": 6, "caterpillar": [6, 7], "schr\u00f6der": [6, 7, 9], "alonso": [6, 7, 9], "r\u00e9my": [6, 7, 9], "schott": [6, 7, 9], "1997": [6, 9], "schroeder_lescann": 6, "lescann": [6, 7, 9], "schroeder_uniform": 6, "via": 6, "complet": 6, "num_leav": 7, "num_internal_nod": 7, "rerun": 7, "root": 7, "sch\u00f6der": 7, "suitabl": 7, "1997a": 7, "build": 7, "1997b": 7, "schro\u00f6der": 7, "particularli": 7, "ineffici": 7, "directcli": 7, "licenc": 7, "until": 7, "requir": 7, "achiev": 7, "reject": 7, "test": [8, 9, 10, 11], "ran": [8, 10, 11], "binomi": 8, "et": 8, "al": 8, "what": [8, 9], "correct": 9, "packag": 9, "variou": 9, "typic": 9, "sure": 9, "develop": 9, "featur": 9, "program": 9, "perspect": 9, "But": 9, "actual": 9, "displai": 9, "theoret": 9, "allow": 9, "u": 9, "ass": 9, "adequ": 9, "multiset": 10, "discuss": 10, "stratifi": 10, "fall": 10, "interest": 10, "govern": 10, "document": 10, "http": 10, "www": 10, "jstor": 10, "org": 10, "stabl": 10, "30024551": 10, "again": 10, "known": 10, "jmlr": 10, "paper": 10, "v15": 10, "lu14a": 10, "html": 10, "properti": 10, "proceed": 10, "mlr": 10, "press": 10, "v48": 10, "zhaob16": 10, "otherwis": 10, "know": 10, "littl": 10, "propos": 10, "design": 10, "isomorph": 10, "effici": [10, 11], "suppos": [10, 11], "doe": [10, 11], "practic": 11, "larg": 11, "impartial_central_vot": [2, 3, 6], "ignor": [3, 6], "partial": []}, "objects": {"prefsampling": [[3, 0, 0, "-", "approval"], [4, 0, 0, "-", "core"], [6, 0, 0, "-", "ordinal"], [7, 0, 0, "-", "tree"]], "prefsampling.approval": [[3, 1, 1, "", "NoiseType"], [3, 3, 1, "", "disjoint_resampling"], [3, 3, 1, "", "empty"], [3, 3, 1, "", "euclidean"], [3, 3, 1, "", "full"], [3, 3, 1, "", "identity"], [3, 3, 1, "", "impartial"], [3, 3, 1, "", "moving_resampling"], [3, 3, 1, "", "noise"], [3, 3, 1, "", "resampling"], [3, 3, 1, "", "truncated_ordinal"], [3, 3, 1, "", "urn_partylist"]], "prefsampling.approval.NoiseType": [[3, 2, 1, "", "BUNKE_SHEARER"], [3, 2, 1, "", "HAMMING"], [3, 2, 1, "", "JACCARD"], [3, 2, 1, "", "ZELINKA"]], "prefsampling.core": [[4, 0, 0, "-", "composition"], [4, 0, 0, "-", "euclidean"], [4, 0, 0, "-", "filters"]], "prefsampling.core.composition": [[4, 3, 1, "", "concatenation"], [4, 3, 1, "", "mixture"]], "prefsampling.core.euclidean": [[4, 1, 1, "", "EuclideanSpace"], [4, 3, 1, "", "election_positions"]], "prefsampling.core.euclidean.EuclideanSpace": [[4, 2, 1, "", "BALL"], [4, 2, 1, "", "GAUSSIAN"], [4, 2, 1, "", "SPHERE"], [4, 2, 1, "", "UNIFORM"]], "prefsampling.core.filters": [[4, 3, 1, "", "permute_voters"], [4, 3, 1, "", "rename_candidates"], [4, 3, 1, "", "resample_as_central_vote"]], "prefsampling.ordinal": [[6, 1, 1, "", "TreeSampler"], [6, 3, 1, "", "didi"], [6, 3, 1, "", "euclidean"], [6, 3, 1, "", "group_separable"], [6, 3, 1, "", "identity"], [6, 3, 1, "", "impartial"], [6, 3, 1, "", "impartial_anonymous"], [6, 3, 1, "", "mallows"], [6, 3, 1, "", "norm_mallows"], [6, 3, 1, "", "plackett_luce"], [6, 3, 1, "", "single_crossing"], [6, 3, 1, "", "single_peaked_circle"], [6, 3, 1, "", "single_peaked_conitzer"], [6, 3, 1, "", "single_peaked_walsh"], [6, 3, 1, "", "stratification"], [6, 3, 1, "", "urn"]], "prefsampling.ordinal.TreeSampler": [[6, 2, 1, "", "BALANCED"], [6, 2, 1, "", "CATERPILLAR"], [6, 2, 1, "", "SCHROEDER"], [6, 2, 1, "", "SCHROEDER_LESCANNE"], [6, 2, 1, "", "SCHROEDER_UNIFORM"]], "prefsampling.tree": [[7, 3, 1, "", "all_schroeder_tree"], [7, 3, 1, "", "caterpillar_tree"], [7, 3, 1, "", "schroeder_tree"], [7, 3, 1, "", "schroeder_tree_brute_force"], [7, 3, 1, "", "schroeder_tree_lescanne"]]}, "objtypes": {"0": "py:module", "1": "py:class", "2": "py:attribute", "3": "py:function"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "class", "Python class"], "2": ["py", "attribute", "Python attribute"], "3": ["py", "function", "Python function"]}, "titleterms": {"prefsampl": 0, "instal": 1, "quick": 2, "start": 2, "organis": 2, "packag": 2, "sampl": 2, "type": 2, "gener": 2, "syntax": 2, "ordin": [2, 6, 10], "sampler": [2, 4, 8, 9, 10, 11], "approv": [2, 3, 8], "composit": [2, 4], "filter": [2, 4], "core": 4, "modul": 4, "euclidean": [4, 10], "refer": 5, "tree": [7, 11], "imparti": [8, 10], "resampl": 8, "disjoint": 8, "nois": 8, "ident": 8, "valid": 9, "procedur": 9, "anonym": 10, "stratif": 10, "urn": 10, "mallow": 10, "plackett": 10, "luce": 10, "didi": 10, "singl": 10, "peak": 10, "cross": 10, "group": 10, "separ": 10, "schr\u00f6der": 11, "alonso": 11, "r\u00e9my": 11, "schott": 11, "1997": 11, "lescann": 11, "2022": 11, "uniform": 11}, "envversion": {"sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.viewcode": 1, "sphinx": 60}, "alltitles": {"PrefSampling": [[0, "prefsampling"]], "Installation": [[1, "installation"]], "Reference": [[5, "reference"]], "Tree": [[7, "module-prefsampling.tree"]], "Approval Samplers": [[8, "approval-samplers"], [2, "approval-samplers"]], "Impartial": [[8, "impartial"], [10, "impartial"]], "Resampling": [[8, "resampling"]], "Disjoint Resampling": [[8, "disjoint-resampling"]], "Noise": [[8, "noise"]], "Identity": [[8, "identity"]], "Validation": [[9, "validation"]], "Procedure": [[9, "procedure"]], "Validated Samplers": [[9, "validated-samplers"]], "Ordinal Samplers": [[10, "ordinal-samplers"], [2, "ordinal-samplers"]], "Impartial Anonymous": [[10, "impartial-anonymous"]], "Stratification": [[10, "stratification"]], "Urn": [[10, "urn"]], "Mallows": [[10, "mallows"]], "Plackett-Luce": [[10, "plackett-luce"]], "Didi": [[10, "didi"]], "Euclidean": [[10, "euclidean"]], "Single-Peaked": [[10, "single-peaked"]], "Single-Crossing": [[10, "single-crossing"]], "Group-Separable": [[10, "group-separable"]], "Tree Samplers": [[11, "tree-samplers"]], "Schr\u00f6der Trees by Alonso, R\u00e9my, Schott (1997)": [[11, "schroder-trees-by-alonso-remy-schott-1997"]], "Schr\u00f6der Trees by Lescanne (2022)": [[11, "schroder-trees-by-lescanne-2022"]], "Uniform Schr\u00f6der Trees": [[11, "uniform-schroder-trees"]], "Quick Start": [[2, "quick-start"]], "Organisation of the package": [[2, "organisation-of-the-package"]], "Sample Types": [[2, "sample-types"]], "General Syntax": [[2, "general-syntax"]], "Composition of Samplers": [[2, "composition-of-samplers"], [4, "module-prefsampling.core.composition"]], "Filters": [[2, "filters"], [4, "module-prefsampling.core.filters"]], "Core": [[4, "module-prefsampling.core"]], "Module core.euclidean": [[4, "module-prefsampling.core.euclidean"]], "Approval": [[3, "module-prefsampling.approval"]], "Ordinal": [[6, "module-prefsampling.ordinal"]]}, "indexentries": {"bunke_shearer (noisetype attribute)": [[3, "prefsampling.approval.NoiseType.BUNKE_SHEARER"]], "hamming (noisetype attribute)": [[3, "prefsampling.approval.NoiseType.HAMMING"]], "jaccard (noisetype attribute)": [[3, "prefsampling.approval.NoiseType.JACCARD"]], "noisetype (class in prefsampling.approval)": [[3, "prefsampling.approval.NoiseType"]], "zelinka (noisetype attribute)": [[3, "prefsampling.approval.NoiseType.ZELINKA"]], "disjoint_resampling() (in module prefsampling.approval)": [[3, "prefsampling.approval.disjoint_resampling"]], "empty() (in module prefsampling.approval)": [[3, "prefsampling.approval.empty"]], "euclidean() (in module prefsampling.approval)": [[3, "prefsampling.approval.euclidean"]], "full() (in module prefsampling.approval)": [[3, "prefsampling.approval.full"]], "identity() (in module prefsampling.approval)": [[3, "prefsampling.approval.identity"]], "impartial() (in module prefsampling.approval)": [[3, "prefsampling.approval.impartial"]], "module": [[3, "module-prefsampling.approval"], [6, "module-prefsampling.ordinal"]], "moving_resampling() (in module prefsampling.approval)": [[3, "prefsampling.approval.moving_resampling"]], "noise() (in module prefsampling.approval)": [[3, "prefsampling.approval.noise"]], "prefsampling.approval": [[3, "module-prefsampling.approval"]], "resampling() (in module prefsampling.approval)": [[3, "prefsampling.approval.resampling"]], "truncated_ordinal() (in module prefsampling.approval)": [[3, "prefsampling.approval.truncated_ordinal"]], "urn_partylist() (in module prefsampling.approval)": [[3, "prefsampling.approval.urn_partylist"]], "balanced (treesampler attribute)": [[6, "prefsampling.ordinal.TreeSampler.BALANCED"]], "caterpillar (treesampler attribute)": [[6, "prefsampling.ordinal.TreeSampler.CATERPILLAR"]], "schroeder (treesampler attribute)": [[6, "prefsampling.ordinal.TreeSampler.SCHROEDER"]], "schroeder_lescanne (treesampler attribute)": [[6, "prefsampling.ordinal.TreeSampler.SCHROEDER_LESCANNE"]], "schroeder_uniform (treesampler attribute)": [[6, "prefsampling.ordinal.TreeSampler.SCHROEDER_UNIFORM"]], "treesampler (class in prefsampling.ordinal)": [[6, "prefsampling.ordinal.TreeSampler"]], "didi() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.didi"]], "euclidean() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.euclidean"]], "group_separable() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.group_separable"]], "identity() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.identity"]], "impartial() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.impartial"]], "impartial_anonymous() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.impartial_anonymous"]], "mallows() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.mallows"]], "norm_mallows() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.norm_mallows"]], "plackett_luce() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.plackett_luce"]], "prefsampling.ordinal": [[6, "module-prefsampling.ordinal"]], "single_crossing() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.single_crossing"]], "single_peaked_circle() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.single_peaked_circle"]], "single_peaked_conitzer() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.single_peaked_conitzer"]], "single_peaked_walsh() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.single_peaked_walsh"]], "stratification() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.stratification"]], "urn() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.urn"]]}}) \ No newline at end of file +Search.setIndex({"docnames": ["index", "installation", "quickstart", "reference/approval/index", "reference/core/index", "reference/index", "reference/ordinal/index", "reference/tree/index", "validation/approval", "validation/index", "validation/ordinal", "validation/tree"], "filenames": ["index.rst", "installation.rst", "quickstart.rst", "reference/approval/index.rst", "reference/core/index.rst", "reference/index.rst", "reference/ordinal/index.rst", "reference/tree/index.rst", "validation/approval.rst", "validation/index.rst", "validation/ordinal.rst", "validation/tree.rst"], "titles": ["PrefSampling", "Installation", "Quick Start", "Approval", "Core", "Reference", "Ordinal", "Tree", "Approval Samplers", "Validation", "Ordinal Samplers", "Tree Samplers"], "terms": {"i": [0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11], "lightweight": 0, "python": [0, 2, 9], "librari": 0, "provid": [0, 2, 4, 7, 9], "prefer": [0, 2, 3, 6], "sampler": [0, 3, 5, 6, 7], "These": [0, 2, 3], "ar": [0, 2, 3, 4, 6, 7, 9, 10], "algorithm": [0, 6, 7], "gener": [0, 3, 4, 6, 7, 8, 9, 10], "random": [0, 2, 3, 4, 6, 7], "base": [0, 2, 4, 8], "precis": 0, "defin": [0, 2, 3, 4, 6], "statist": 0, "cultur": [0, 3, 6, 10], "we": [0, 2, 4, 6, 8, 9, 10, 11], "consid": [0, 2, 3, 4, 6], "differ": [0, 2, 3, 4, 6, 10], "type": [0, 3, 4, 6, 7], "ordin": [0, 3, 4, 5, 9], "express": 0, "rank": [0, 2, 6, 10], "candid": [0, 2, 3, 4, 6, 8, 10], "approv": [0, 4, 5, 9], "indic": [0, 6], "set": [0, 2, 3, 4, 6], "prefsampl": [1, 2, 8, 10, 11], "host": 1, "pypi": 1, "you": [1, 2, 3, 4, 6], "can": [1, 2, 3, 4, 6, 10], "thu": [1, 8, 10, 11], "easili": 1, "us": [1, 2, 3, 4, 6, 10], "pip3": 1, "The": [1, 2, 3, 4, 6, 7, 8, 10], "sourc": [1, 3, 4, 6, 7], "code": [1, 4], "github": [1, 7], "repositori": [1, 7], "well": [1, 10], "format": [2, 4], "thei": [2, 10], "produc": [2, 10, 11], "modul": [2, 3, 5, 6], "contain": [2, 6], "ones": [2, 3], "To": [2, 6, 9], "make": [2, 9], "easi": 2, "emb": 2, "all": [2, 3, 4, 6, 7, 10, 11], "kind": 2, "tool": 2, "basic": 2, "return": [2, 3, 4, 6, 7], "collect": [2, 3, 4, 6], "np": [2, 4, 6], "ndarrai": [2, 4, 6], "numpi": [2, 3, 4, 6, 7], "arrai": 2, "where": [2, 3, 6, 10], "most": [2, 6], "posit": [2, 3, 4, 6], "0": [2, 3, 6, 10], "next": [2, 6], "one": [2, 4, 6, 7, 10], "1": [2, 3, 4, 6, 10], "so": [2, 6], "forth": 2, "each": [2, 3, 4, 6, 7, 9], "In": [2, 3, 6, 8, 10], "case": [2, 4, 6, 10], "name": [2, 3, 4, 6], "2": [2, 3, 4, 6, 10], "have": [2, 6, 10], "same": [2, 3, 4, 8, 10], "signatur": 2, "num_vot": [2, 3, 4, 6], "num_candid": [2, 3, 4, 6], "arg": 2, "seed": [2, 3, 4, 6, 7], "none": [2, 3, 4, 6, 7], "kwarg": 2, "paramet": [2, 3, 4, 6, 7, 8], "repres": [2, 3, 4, 6], "number": [2, 3, 4, 6, 7, 10, 11], "pass": [2, 3, 4], "give": [2, 7], "more": [2, 6, 8, 9, 10], "control": [2, 6], "need": [2, 4], "replic": 2, "instanc": [2, 4, 6, 10], "other": [2, 3, 4, 6, 10], "specif": [2, 4, 6, 7], "refer": 2, "ident": [2, 3, 5, 6, 9], "imparti": [2, 3, 5, 6, 9], "impartial_anonym": [2, 5, 6, 10], "mallow": [2, 5, 6, 9], "phi": [2, 3, 6, 10], "central_vot": [2, 3, 4, 6], "default": [2, 3, 6, 7], "normalise_phi": [2, 6], "fals": [2, 3, 6], "norm_mallow": [2, 5, 6], "norm_phi": [2, 6], "euclidean": [2, 3, 5, 6, 9], "space": [2, 3, 4, 6], "uniform": [2, 3, 4, 6, 7, 9, 10], "dimens": [2, 3, 4, 6], "plackett_luc": [2, 5, 6, 10], "alpha": [2, 3, 6, 10], "didi": [2, 5, 6, 9], "urn": [2, 3, 5, 6, 9], "stratif": [2, 5, 6, 9], "weight": [2, 4, 6, 10], "single_peaked_conitz": [2, 5, 6, 10], "single_peaked_walsh": [2, 5, 6, 10], "single_peaked_circl": [2, 5, 6, 10], "single_cross": [2, 5, 6, 10], "group_separ": [2, 5, 6, 10], "tree_sampl": [2, 6], "schroeder": [2, 6], "p": [2, 3, 8], "empti": [2, 3, 5, 6], "full": [2, 3, 5], "resampl": [2, 3, 4, 5, 9], "disjoint_resampl": [2, 3, 5, 8], "g": [2, 3, 4], "moving_resampl": [2, 3, 5], "num_leg": [2, 3], "radiu": [2, 3], "5": [2, 3, 6], "nois": [2, 3, 5, 9], "noise_typ": [2, 3], "ham": [2, 3, 8], "truncated_ordin": [2, 3, 5], "ordinal_sampl": [2, 3], "ordinal_sampler_paramet": [2, 3], "urn_partylist": [2, 3, 5], "parti": [2, 3], "It": [2, 4], "often": 2, "abl": 2, "compos": 2, "mixtur": [2, 4], "function": [2, 3, 4, 6], "concaten": [2, 4], "do": [2, 6], "being": [2, 3, 4, 6, 8], "given": [2, 3, 4, 6, 7, 10], "probabl": [2, 3, 4, 6, 7, 8, 10, 11], "from": [2, 3, 4, 6, 7, 9, 10], "core": [2, 5], "import": [2, 4], "creat": 2, "100": 2, "voter": [2, 3, 4, 6, 10], "10": 2, "singl": [2, 3, 6, 8, 9], "peak": [2, 6, 9], "conitz": [2, 6, 10], "6": 2, "walsh": [2, 6, 10], "4": [2, 3, 4, 6], "list": [2, 3, 4, 6, 7], "model": [2, 3, 6, 8, 10], "3": [2, 3, 4, 6], "9": 2, "23": 2, "simpli": 2, "vote": [2, 3, 4, 6, 10], "60": 2, "40": 2, "per": [2, 3, 6], "oper": [2, 4], "appli": [2, 3, 4, 6], "some": [2, 4], "them": [2, 4, 6, 7], "implement": [2, 6, 9], "effect": 2, "permute_vot": [2, 4], "randomli": [2, 4, 6], "permut": [2, 4, 6], "rename_candid": [2, 4], "renam": [2, 4], "resample_as_central_vot": [2, 4], "central": [2, 3, 4, 6], "whose": 2, "definit": [2, 6], "includ": [2, 6], "e": [2, 3, 4, 6, 10], "below": [2, 8, 10, 11], "an": [2, 3, 4, 6, 8, 10], "exampl": [2, 10], "how": 2, "initial_vot": 2, "855": 2, "argument": [2, 3, 4], "sampl": [3, 4, 6, 7, 8, 9], "which": [3, 4, 6], "either": [3, 6], "disapprov": 3, "class": [3, 4, 6, 10], "noisetyp": [3, 5], "valu": [3, 4, 6, 10], "qualnam": [3, 4, 6], "start": [3, 4, 6], "boundari": [3, 4, 6], "constant": [3, 4, 6], "bunke_shear": 3, "bunk": 3, "shearer": 3, "jaccard": 3, "zelinka": 3, "int": [3, 4, 6, 7], "float": [3, 4, 6], "disjoint": [3, 9], "denot": 3, "length": [3, 8, 10], "group": [3, 6, 9], "rais": [3, 6], "valueerror": [3, 6], "when": [3, 6, 10], "interv": 3, "euclideanspac": [3, 4, 6], "accord": [3, 6], "assign": [3, 6], "A": [3, 6], "within": [3, 4, 6], "certain": 3, "word": 3, "distanc": [3, 6, 8, 10], "sever": [3, 6], "possibl": [3, 6, 7], "enumer": [3, 6, 7, 11], "also": [3, 6, 9, 10], "chang": [3, 6], "independ": [3, 4, 6], "follow": [3, 4, 6, 7, 8], "process": [3, 4, 6], "describ": [3, 6, 10], "abov": [3, 6], "should": [3, 4, 6], "simpl": 3, "onli": [3, 4, 6, 8, 10], "proport": [3, 6, 7], "under": [3, 6, 10], "ha": [3, 4, 8, 10, 11], "thi": [3, 4, 6, 7, 8, 9, 10, 11], "ensur": [3, 6, 7, 9, 10], "averag": 3, "ani": [3, 4, 6], "move": 3, "leg": 3, "callabl": [3, 4], "dict": [3, 4], "truncat": 3, "wai": 3, "consist": 3, "first": [3, 6, 9], "ratio": 3, "ot": 3, "overriden": 3, "those": 3, "partylist": 3, "fraction": 3, "size": [3, 6], "ballot": [3, 4, 8], "num_voters_per_sampl": 4, "sampler_paramet": 4, "togeth": [4, 6, 9], "form": 4, "final": [4, 6], "note": [4, 6, 10], "after": [4, 6], "onc": [4, 10], "assum": 4, "about": [4, 10], "If": [3, 4, 6, 7], "don": 4, "t": 4, "fail": 4, "dictionari": 4, "keyword": 4, "taken": [4, 7], "account": 4, "work": [4, 6, 8], "distribut": [4, 6, 8, 9, 10, 11], "correspond": [4, 6, 7], "over": [3, 4, 6, 10], "k": [4, 6, 8], "want": [4, 9], "particular": 4, "mutablesequ": 4, "order": [4, 6], "incomplet": 4, "input": 4, "largest": 4, "integ": 4, "appear": [4, 10], "accept": 4, "copi": [4, 6], "befor": [4, 6], "avoid": 4, "loss": 4, "data": 4, "ball": 4, "gaussian": 4, "sphere": 4, "spheric": 4, "election_posit": 4, "rng": 4, "_gener": [], "respect": [4, 6], "treesampl": [5, 6], "tree": [5, 6, 9, 10], "all_schroeder_tre": [5, 7], "caterpillar_tre": [5, 7], "schroeder_tre": [5, 7, 11], "schroeder_tree_brute_forc": [5, 7, 11], "schroeder_tree_lescann": [5, 7, 11], "composit": 5, "filter": 5, "unanim": 6, "equal": [6, 10], "like": [6, 10], "occur": [6, 10], "get": 6, "anonym": [6, 9], "everi": [6, 8, 10], "multi": 6, "For": [6, 10], "observ": [6, 8, 10], "b": 6, "wa": [6, 7], "8": 6, "see": [6, 8, 10], "lepellei": 6, "valogn": 6, "2003": 6, "here": [6, 8, 10], "bool": [3, 6], "1957": 6, "parameteris": 6, "decreas": 6, "exponenti": 6, "between": [6, 9], "dispers": 6, "coeffici": 6, "kendal": 6, "tau": 6, "consider": 6, "close": 6, "render": 6, "far": 6, "awai": 6, "unlik": 6, "opposit": 6, "depend": 6, "applic": 6, "advis": 6, "normalis": 6, "especi": 6, "compar": 6, "boehmer": 6, "faliszewski": 6, "kraiczi": 6, "2023": 6, "detail": [6, 8], "true": [3, 6], "option": [], "whether": 6, "arrang": 6, "shortcut": 6, "increas": 6, "closest": 6, "etc": 6, "plackett": [6, 9], "luce": [6, 9], "vector": 6, "intuit": 6, "qualiti": [6, 10], "m": [6, 10], "step": 6, "fill": 6, "up": 6, "least": 6, "initi": 6, "draw": 6, "select": [3, 6, 7], "its": 6, "Then": 6, "remov": 6, "re": 6, "similar": 6, "dirichlet": 6, "moreov": 6, "higher": 6, "sum": 6, "correl": 6, "concentr": 6, "point": 6, "veri": 6, "spirit": 6, "param": 6, "len": 6, "p\u00f3lya": 6, "eggenberg": 6, "turn": 6, "happen": 6, "With": [6, 10], "urn_siz": 6, "uniformli": [3, 6, 7], "both": 6, "put": 6, "back": [6, 10], "must": 6, "non": [6, 10], "neg": 6, "split": 6, "two": [6, 9], "second": 6, "rel": 6, "upper": 6, "2009": [6, 10], "axi": [6, 10], "left": 6, "right": 6, "come": 6, "method": 6, "iter": 6, "oppos": 6, "dist_peak_to_end": [6, 10], "minimum": [6, 10], "end": [6, 10], "2015": [6, 10], "leftmost": 6, "rightmost": 6, "yet": 6, "been": [6, 10], "circl": [6, 10], "inspir": 6, "peaked": 6, "line": 6, "determin": 6, "done": 6, "subsequ": 6, "take": 6, "avail": [6, 7], "term": 6, "circular": 6, "cross": [6, 9], "elkind": 6, "lackner": 6, "peter": 6, "2022": [6, 7, 8, 9], "domain": 6, "alwai": 6, "valid": [6, 8, 10, 11], "swap": 6, "consecut": 6, "had": 6, "alreadi": 6, "previou": 6, "One": 6, "perform": 6, "admit": 6, "importantli": [6, 9], "success": 6, "further": 6, "down": 6, "than": 6, "previous": 6, "latter": 6, "neutral": 6, "mean": 6, "lexicograph": 6, "obtain": [6, 10], "szufa": [6, 8], "skowron": 6, "slinko": 6, "talmon": 6, "2020": 6, "profil": [6, 10], "yield": [6, 10, 11], "procedur": [6, 7], "unknown": [6, 10, 11], "outcom": [6, 10], "single_crossing_imparti": 6, "becom": 6, "slow": [6, 11], "difficulti": 6, "li": 6, "comput": 6, "instead": 6, "separ": [6, 9], "seprabl": 6, "present": [6, 7, 8, 10, 11], "karpov": 6, "obraztsova": 6, "decomposit": 6, "intern": [6, 7], "node": [6, 7], "children": 6, "revers": 6, "label": 6, "leav": [6, 7, 11], "read": 6, "meant": 6, "howev": [6, 10], "our": 6, "analysi": 6, "impact": 6, "balanc": 6, "caterpillar": [6, 7], "schr\u00f6der": [6, 7, 9], "alonso": [6, 7, 9], "r\u00e9my": [6, 7, 9], "schott": [6, 7, 9], "1997": [6, 9], "schroeder_lescann": 6, "lescann": [6, 7, 9], "schroeder_uniform": 6, "via": 6, "complet": 6, "num_leav": 7, "num_internal_nod": 7, "rerun": 7, "root": 7, "sch\u00f6der": 7, "suitabl": 7, "1997a": 7, "build": 7, "1997b": 7, "schro\u00f6der": 7, "particularli": 7, "ineffici": 7, "directcli": 7, "licenc": 7, "until": 7, "requir": 7, "achiev": 7, "reject": 7, "test": [8, 9, 10, 11], "ran": [8, 10, 11], "binomi": 8, "et": 8, "al": 8, "what": [8, 9], "correct": 9, "packag": 9, "variou": 9, "typic": 9, "sure": 9, "develop": 9, "featur": 9, "program": 9, "perspect": 9, "But": 9, "actual": 9, "displai": 9, "theoret": 9, "allow": 9, "u": 9, "ass": 9, "adequ": 9, "multiset": 10, "discuss": 10, "stratifi": 10, "fall": 10, "interest": 10, "govern": 10, "document": 10, "http": 10, "www": 10, "jstor": 10, "org": 10, "stabl": 10, "30024551": 10, "again": 10, "known": 10, "jmlr": 10, "paper": 10, "v15": 10, "lu14a": 10, "html": 10, "properti": 10, "proceed": 10, "mlr": 10, "press": 10, "v48": 10, "zhaob16": 10, "otherwis": 10, "know": 10, "littl": 10, "propos": 10, "design": 10, "isomorph": 10, "effici": [10, 11], "suppos": [10, 11], "doe": [10, 11], "practic": 11, "larg": 11, "impartial_central_vot": [2, 3, 6], "ignor": [3, 6], "partial": [], "impartial_constant_s": [2, 3, 5], "num_approv": [2, 3], "typeerror": 3}, "objects": {"prefsampling": [[3, 0, 0, "-", "approval"], [4, 0, 0, "-", "core"], [6, 0, 0, "-", "ordinal"], [7, 0, 0, "-", "tree"]], "prefsampling.approval": [[3, 1, 1, "", "NoiseType"], [3, 3, 1, "", "disjoint_resampling"], [3, 3, 1, "", "empty"], [3, 3, 1, "", "euclidean"], [3, 3, 1, "", "full"], [3, 3, 1, "", "identity"], [3, 3, 1, "", "impartial"], [3, 3, 1, "", "impartial_constant_size"], [3, 3, 1, "", "moving_resampling"], [3, 3, 1, "", "noise"], [3, 3, 1, "", "resampling"], [3, 3, 1, "", "truncated_ordinal"], [3, 3, 1, "", "urn_partylist"]], "prefsampling.approval.NoiseType": [[3, 2, 1, "", "BUNKE_SHEARER"], [3, 2, 1, "", "HAMMING"], [3, 2, 1, "", "JACCARD"], [3, 2, 1, "", "ZELINKA"]], "prefsampling.core": [[4, 0, 0, "-", "composition"], [4, 0, 0, "-", "euclidean"], [4, 0, 0, "-", "filters"]], "prefsampling.core.composition": [[4, 3, 1, "", "concatenation"], [4, 3, 1, "", "mixture"]], "prefsampling.core.euclidean": [[4, 1, 1, "", "EuclideanSpace"], [4, 3, 1, "", "election_positions"]], "prefsampling.core.euclidean.EuclideanSpace": [[4, 2, 1, "", "BALL"], [4, 2, 1, "", "GAUSSIAN"], [4, 2, 1, "", "SPHERE"], [4, 2, 1, "", "UNIFORM"]], "prefsampling.core.filters": [[4, 3, 1, "", "permute_voters"], [4, 3, 1, "", "rename_candidates"], [4, 3, 1, "", "resample_as_central_vote"]], "prefsampling.ordinal": [[6, 1, 1, "", "TreeSampler"], [6, 3, 1, "", "didi"], [6, 3, 1, "", "euclidean"], [6, 3, 1, "", "group_separable"], [6, 3, 1, "", "identity"], [6, 3, 1, "", "impartial"], [6, 3, 1, "", "impartial_anonymous"], [6, 3, 1, "", "mallows"], [6, 3, 1, "", "norm_mallows"], [6, 3, 1, "", "plackett_luce"], [6, 3, 1, "", "single_crossing"], [6, 3, 1, "", "single_peaked_circle"], [6, 3, 1, "", "single_peaked_conitzer"], [6, 3, 1, "", "single_peaked_walsh"], [6, 3, 1, "", "stratification"], [6, 3, 1, "", "urn"]], "prefsampling.ordinal.TreeSampler": [[6, 2, 1, "", "BALANCED"], [6, 2, 1, "", "CATERPILLAR"], [6, 2, 1, "", "SCHROEDER"], [6, 2, 1, "", "SCHROEDER_LESCANNE"], [6, 2, 1, "", "SCHROEDER_UNIFORM"]], "prefsampling.tree": [[7, 3, 1, "", "all_schroeder_tree"], [7, 3, 1, "", "caterpillar_tree"], [7, 3, 1, "", "schroeder_tree"], [7, 3, 1, "", "schroeder_tree_brute_force"], [7, 3, 1, "", "schroeder_tree_lescanne"]]}, "objtypes": {"0": "py:module", "1": "py:class", "2": "py:attribute", "3": "py:function"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "class", "Python class"], "2": ["py", "attribute", "Python attribute"], "3": ["py", "function", "Python function"]}, "titleterms": {"prefsampl": 0, "instal": 1, "quick": 2, "start": 2, "organis": 2, "packag": 2, "sampl": 2, "type": 2, "gener": 2, "syntax": 2, "ordin": [2, 6, 10], "sampler": [2, 4, 8, 9, 10, 11], "approv": [2, 3, 8], "composit": [2, 4], "filter": [2, 4], "core": 4, "modul": 4, "euclidean": [4, 10], "refer": 5, "tree": [7, 11], "imparti": [8, 10], "resampl": 8, "disjoint": 8, "nois": 8, "ident": 8, "valid": 9, "procedur": 9, "anonym": 10, "stratif": 10, "urn": 10, "mallow": 10, "plackett": 10, "luce": 10, "didi": 10, "singl": 10, "peak": 10, "cross": 10, "group": 10, "separ": 10, "schr\u00f6der": 11, "alonso": 11, "r\u00e9my": 11, "schott": 11, "1997": 11, "lescann": 11, "2022": 11, "uniform": 11}, "envversion": {"sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.viewcode": 1, "sphinx": 60}, "alltitles": {"PrefSampling": [[0, "prefsampling"]], "Installation": [[1, "installation"]], "Reference": [[5, "reference"]], "Approval Samplers": [[8, "approval-samplers"], [2, "approval-samplers"]], "Impartial": [[8, "impartial"], [10, "impartial"]], "Resampling": [[8, "resampling"]], "Disjoint Resampling": [[8, "disjoint-resampling"]], "Noise": [[8, "noise"]], "Identity": [[8, "identity"]], "Validation": [[9, "validation"]], "Procedure": [[9, "procedure"]], "Validated Samplers": [[9, "validated-samplers"]], "Ordinal Samplers": [[10, "ordinal-samplers"], [2, "ordinal-samplers"]], "Impartial Anonymous": [[10, "impartial-anonymous"]], "Stratification": [[10, "stratification"]], "Urn": [[10, "urn"]], "Mallows": [[10, "mallows"]], "Plackett-Luce": [[10, "plackett-luce"]], "Didi": [[10, "didi"]], "Euclidean": [[10, "euclidean"]], "Single-Peaked": [[10, "single-peaked"]], "Single-Crossing": [[10, "single-crossing"]], "Group-Separable": [[10, "group-separable"]], "Tree Samplers": [[11, "tree-samplers"]], "Schr\u00f6der Trees by Alonso, R\u00e9my, Schott (1997)": [[11, "schroder-trees-by-alonso-remy-schott-1997"]], "Schr\u00f6der Trees by Lescanne (2022)": [[11, "schroder-trees-by-lescanne-2022"]], "Uniform Schr\u00f6der Trees": [[11, "uniform-schroder-trees"]], "Quick Start": [[2, "quick-start"]], "Organisation of the package": [[2, "organisation-of-the-package"]], "Sample Types": [[2, "sample-types"]], "General Syntax": [[2, "general-syntax"]], "Composition of Samplers": [[2, "composition-of-samplers"], [4, "module-prefsampling.core.composition"]], "Filters": [[2, "filters"], [4, "module-prefsampling.core.filters"]], "Approval": [[3, "module-prefsampling.approval"]], "Core": [[4, "module-prefsampling.core"]], "Module core.euclidean": [[4, "module-prefsampling.core.euclidean"]], "Ordinal": [[6, "module-prefsampling.ordinal"]], "Tree": [[7, "module-prefsampling.tree"]]}, "indexentries": {"bunke_shearer (noisetype attribute)": [[3, "prefsampling.approval.NoiseType.BUNKE_SHEARER"]], "hamming (noisetype attribute)": [[3, "prefsampling.approval.NoiseType.HAMMING"]], "jaccard (noisetype attribute)": [[3, "prefsampling.approval.NoiseType.JACCARD"]], "noisetype (class in prefsampling.approval)": [[3, "prefsampling.approval.NoiseType"]], "zelinka (noisetype attribute)": [[3, "prefsampling.approval.NoiseType.ZELINKA"]], "disjoint_resampling() (in module prefsampling.approval)": [[3, "prefsampling.approval.disjoint_resampling"]], "empty() (in module prefsampling.approval)": [[3, "prefsampling.approval.empty"]], "euclidean() (in module prefsampling.approval)": [[3, "prefsampling.approval.euclidean"]], "full() (in module prefsampling.approval)": [[3, "prefsampling.approval.full"]], "identity() (in module prefsampling.approval)": [[3, "prefsampling.approval.identity"]], "impartial() (in module prefsampling.approval)": [[3, "prefsampling.approval.impartial"]], "impartial_constant_size() (in module prefsampling.approval)": [[3, "prefsampling.approval.impartial_constant_size"]], "module": [[3, "module-prefsampling.approval"], [4, "module-prefsampling.core"], [4, "module-prefsampling.core.composition"], [4, "module-prefsampling.core.euclidean"], [4, "module-prefsampling.core.filters"], [6, "module-prefsampling.ordinal"], [7, "module-prefsampling.tree"]], "moving_resampling() (in module prefsampling.approval)": [[3, "prefsampling.approval.moving_resampling"]], "noise() (in module prefsampling.approval)": [[3, "prefsampling.approval.noise"]], "prefsampling.approval": [[3, "module-prefsampling.approval"]], "resampling() (in module prefsampling.approval)": [[3, "prefsampling.approval.resampling"]], "truncated_ordinal() (in module prefsampling.approval)": [[3, "prefsampling.approval.truncated_ordinal"]], "urn_partylist() (in module prefsampling.approval)": [[3, "prefsampling.approval.urn_partylist"]], "ball (euclideanspace attribute)": [[4, "prefsampling.core.euclidean.EuclideanSpace.BALL"]], "euclideanspace (class in prefsampling.core.euclidean)": [[4, "prefsampling.core.euclidean.EuclideanSpace"]], "gaussian (euclideanspace attribute)": [[4, "prefsampling.core.euclidean.EuclideanSpace.GAUSSIAN"]], "sphere (euclideanspace attribute)": [[4, "prefsampling.core.euclidean.EuclideanSpace.SPHERE"]], "uniform (euclideanspace attribute)": [[4, "prefsampling.core.euclidean.EuclideanSpace.UNIFORM"]], "concatenation() (in module prefsampling.core.composition)": [[4, "prefsampling.core.composition.concatenation"]], "election_positions() (in module prefsampling.core.euclidean)": [[4, "prefsampling.core.euclidean.election_positions"]], "mixture() (in module prefsampling.core.composition)": [[4, "prefsampling.core.composition.mixture"]], "permute_voters() (in module prefsampling.core.filters)": [[4, "prefsampling.core.filters.permute_voters"]], "prefsampling.core": [[4, "module-prefsampling.core"]], "prefsampling.core.composition": [[4, "module-prefsampling.core.composition"]], "prefsampling.core.euclidean": [[4, "module-prefsampling.core.euclidean"]], "prefsampling.core.filters": [[4, "module-prefsampling.core.filters"]], "rename_candidates() (in module prefsampling.core.filters)": [[4, "prefsampling.core.filters.rename_candidates"]], "resample_as_central_vote() (in module prefsampling.core.filters)": [[4, "prefsampling.core.filters.resample_as_central_vote"]], "balanced (treesampler attribute)": [[6, "prefsampling.ordinal.TreeSampler.BALANCED"]], "caterpillar (treesampler attribute)": [[6, "prefsampling.ordinal.TreeSampler.CATERPILLAR"]], "schroeder (treesampler attribute)": [[6, "prefsampling.ordinal.TreeSampler.SCHROEDER"]], "schroeder_lescanne (treesampler attribute)": [[6, "prefsampling.ordinal.TreeSampler.SCHROEDER_LESCANNE"]], "schroeder_uniform (treesampler attribute)": [[6, "prefsampling.ordinal.TreeSampler.SCHROEDER_UNIFORM"]], "treesampler (class in prefsampling.ordinal)": [[6, "prefsampling.ordinal.TreeSampler"]], "didi() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.didi"]], "euclidean() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.euclidean"]], "group_separable() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.group_separable"]], "identity() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.identity"]], "impartial() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.impartial"]], "impartial_anonymous() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.impartial_anonymous"]], "mallows() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.mallows"]], "norm_mallows() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.norm_mallows"]], "plackett_luce() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.plackett_luce"]], "prefsampling.ordinal": [[6, "module-prefsampling.ordinal"]], "single_crossing() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.single_crossing"]], "single_peaked_circle() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.single_peaked_circle"]], "single_peaked_conitzer() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.single_peaked_conitzer"]], "single_peaked_walsh() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.single_peaked_walsh"]], "stratification() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.stratification"]], "urn() (in module prefsampling.ordinal)": [[6, "prefsampling.ordinal.urn"]], "all_schroeder_tree() (in module prefsampling.tree)": [[7, "prefsampling.tree.all_schroeder_tree"]], "caterpillar_tree() (in module prefsampling.tree)": [[7, "prefsampling.tree.caterpillar_tree"]], "prefsampling.tree": [[7, "module-prefsampling.tree"]], "schroeder_tree() (in module prefsampling.tree)": [[7, "prefsampling.tree.schroeder_tree"]], "schroeder_tree_brute_force() (in module prefsampling.tree)": [[7, "prefsampling.tree.schroeder_tree_brute_force"]], "schroeder_tree_lescanne() (in module prefsampling.tree)": [[7, "prefsampling.tree.schroeder_tree_lescanne"]]}}) \ No newline at end of file diff --git a/prefsampling/approval/__init__.py b/prefsampling/approval/__init__.py index 97de847..6c8381f 100644 --- a/prefsampling/approval/__init__.py +++ b/prefsampling/approval/__init__.py @@ -3,7 +3,7 @@ disapprove each candidate. """ -from prefsampling.approval.impartial import impartial +from prefsampling.approval.impartial import impartial, impartial_constant_size from prefsampling.approval.identity import identity, full, empty from prefsampling.approval.resampling import ( resampling, @@ -18,6 +18,7 @@ __all__ = [ "impartial", + "impartial_constant_size", "identity", "full", "empty", diff --git a/prefsampling/approval/impartial.py b/prefsampling/approval/impartial.py index f5a8cce..dd4f808 100644 --- a/prefsampling/approval/impartial.py +++ b/prefsampling/approval/impartial.py @@ -2,7 +2,7 @@ import numpy as np -from prefsampling.inputvalidators import validate_num_voters_candidates +from prefsampling.inputvalidators import validate_num_voters_candidates, validate_int @validate_num_voters_candidates @@ -16,6 +16,9 @@ def impartial( probability :code:`p` of being approved. This models ensures that the average number of approved candidate per voter is `p * num_candidate`. + A collection of `num_voters` vote is generated independently and identically following the + process described above. + Parameters ---------- num_voters : int @@ -39,7 +42,7 @@ def impartial( """ if p < 0 or 1 < p: - raise ValueError(f"Incorrect value of p: {p}. Value should be in [0,1]") + raise ValueError(f"Incorrect value of p: {p}. Value should be in [0, 1]") rng = np.random.default_rng(seed) @@ -49,3 +52,55 @@ def impartial( ] return votes + + +@validate_num_voters_candidates +def impartial_constant_size( + num_voters: int, num_candidates: int, num_approvals: int, seed: int = None +) -> list[set]: + """ + Generates approval votes from impartial culture with constant size. + + Under this culture, all ballots are of size :code:`num_approvals`. The ballot is selected + uniformly at random over all ballots of size :code:`num_approvals`. + + A collection of `num_voters` vote is generated independently and identically following the + process described above. + + Parameters + ---------- + num_voters : int + Number of Voters. + num_candidates : int + Number of Candidates. + num_approvals : int + Number of approvals per ballot, i.e., size of the approval ballot. + seed : int + Seed for numpy random number generator. + + Returns + ------- + list[set] + Approval votes. + + Raises + ------ + TypeError + When `num_approvals` is not an int. + ValueError + When `num_approvals` is not in [0, num_candidates] interval. + """ + + validate_int(num_approvals, "number of approvals", lower_bound=0) + if num_approvals > num_candidates: + raise ValueError("The number of approval is higher than the number of candidates:" + f" {num_approvals} > {num_candidates}.") + + rng = np.random.default_rng(seed) + candidate_range = range(num_candidates) + votes = [ + set(rng.choice(candidate_range, size=num_approvals, replace=False)) + for _ in range(num_voters) + ] + + return votes diff --git a/prefsampling/approval/noise.py b/prefsampling/approval/noise.py index add1b1e..5c6f4c3 100644 --- a/prefsampling/approval/noise.py +++ b/prefsampling/approval/noise.py @@ -47,6 +47,9 @@ def noise( """ Generates approval votes under the noise model. + A collection of `num_voters` vote is generated independently and identically following the + process described above. + Parameters ---------- num_voters : int diff --git a/tests/test_samplers/approval/test_all_approval_samplers.py b/tests/test_samplers/approval/test_all_approval_samplers.py index e3df49f..7afe0d2 100644 --- a/tests/test_samplers/approval/test_all_approval_samplers.py +++ b/tests/test_samplers/approval/test_all_approval_samplers.py @@ -6,6 +6,7 @@ disjoint_resampling, moving_resampling, impartial, + impartial_constant_size, euclidean, noise, identity, @@ -37,6 +38,9 @@ lambda num_voters, num_candidates, seed=None: impartial( num_voters, num_candidates, 0.5, seed=seed ), + lambda num_voters, num_candidates, seed=None: impartial_constant_size( + num_voters, num_candidates, int(0.5 * num_candidates), seed=seed + ), lambda num_voters, num_candidates, seed=None: euclidean( num_voters, num_candidates, space=EuclideanSpace.UNIFORM, seed=seed ), diff --git a/tests/test_samplers/approval/test_approval_impartial.py b/tests/test_samplers/approval/test_approval_impartial.py index e56237f..8221d99 100644 --- a/tests/test_samplers/approval/test_approval_impartial.py +++ b/tests/test_samplers/approval/test_approval_impartial.py @@ -1,7 +1,7 @@ from unittest import TestCase -from prefsampling.approval.impartial import impartial +from prefsampling.approval.impartial import impartial, impartial_constant_size class TestApprovalImpartial(TestCase): @@ -10,3 +10,16 @@ def test_approval_impartial(self): impartial(4, 5, p=-0.5) with self.assertRaises(ValueError): impartial(4, 5, p=1.5) + + def test_approval_impartial_constant_size(self): + with self.assertRaises(TypeError): + impartial_constant_size(4, 5, num_approvals=0.5) + with self.assertRaises(ValueError): + impartial_constant_size(4, 5, num_approvals=-1) + with self.assertRaises(ValueError): + impartial_constant_size(4, 5, num_approvals=50) + + for _ in range(100): + votes = impartial_constant_size(50, 50, num_approvals=25) + for vote in votes: + assert len(vote) == 25 diff --git a/tests/test_samplers/test_all_samplers.py b/tests/test_samplers/test_all_samplers.py index 072b508..a97f646 100644 --- a/tests/test_samplers/test_all_samplers.py +++ b/tests/test_samplers/test_all_samplers.py @@ -32,6 +32,7 @@ disjoint_resampling as approval_disjoint_resampling, moving_resampling as approval_moving_resampling, impartial as approval_impartial, + impartial_constant_size as approval_impartial_constant_size, euclidean as approval_euclidean, noise as approval_noise, identity as approval_identity, @@ -108,6 +109,9 @@ lambda num_voters, num_candidates, seed=None: approval_impartial( num_voters, num_candidates, 0.5, seed=seed ), + lambda num_voters, num_candidates, seed=None: approval_impartial_constant_size( + num_voters, num_candidates, int(0.5 * num_candidates), seed=seed + ), lambda num_voters, num_candidates, seed=None: approval_euclidean( num_voters, num_candidates, space=EuclideanSpace.UNIFORM, seed=seed ),