sampling

This module describes procedures to sample preferences for different probability distributions. Note that this has been updated to use the samplers provided in the prefsampling package.

generate_IC(num_voters, num_alternatives)

Generates a profile of strict preferences following the impartial culture. Note that all we are using the prefsampling samplers. This is thus just a wrapper.

Parameters:
  • num_voters (int) – Number of orders to sample.

  • num_alternatives (int) – Number of alternatives for the sampled orders.

Returns:

A vote map, i.e., a dictionary whose keys are orders, mapping to the number of voters with the given order as their preferences.

Return type:

dict

generate_IC_anon(num_voters, num_alternatives)

Generates a profile of strict preferences following the anonymous impartial culture. Note that all we are using the prefsampling samplers. This is thus just a wrapper.

Parameters:
  • num_voters (int) – Number of orders to sample.

  • num_alternatives (int) – Number of alternatives for the sampled orders.

Returns:

A vote map, i.e., a dictionary whose keys are orders, mapping to the number of voters with the given order as their preferences.

Return type:

dict

generate_IC_ballot(num_alternatives)

Generates a strict order over the set of alternatives following the impartial culture. Note that all we are using the prefsampling samplers. This is thus just a wrapper.

Parameters:

num_alternatives (int) – Number of alternatives for the sampled orders.

Returns:

A strict order over the alternatives, i.e., a tuple of tuples of size 1.

Return type:

tuple

generate_mallows(num_voters, num_alternatives, mixture, dispersions, references, norm_phi=False)

Generates a profile following a mixture of Mallow’s models. Note that all we are using the prefsampling samplers. This is thus just a wrapper.

Parameters:
  • num_voters (int) – Number of orders to sample.

  • num_alternatives (int) – Number of alternatives for the sampled orders.

  • mixture (list of positive numbers) – A list of the weights of each element of the mixture.

  • dispersions (list of float) – A list of the dispersion coefficient of each element of the mixture.

  • references (list of tuples of tuples of int) – A list of the reference orders for each element of the mixture.

  • norm_phi (bool) – Computes the normalised phi values based on the dispersion coefficients given if true. Defaults to False.

Returns:

A vote map, i.e., a dictionary whose keys are orders, mapping to the number of voters with the given order as their preferences.

Return type:

dict

generate_mallows_mix(num_voters, num_alternatives, num_references, norm_phi=True)

Generates a profile following a mixture of Mallow’s models for which reference points and dispersion coefficients are independently and identically distributed. Note that all we are using the prefsampling samplers. This is thus just a wrapper.

Parameters:
  • num_voters (int) – Number of orders to sample.

  • num_alternatives (int) – Number of alternatives for the sampled orders.

  • num_references (int) – Number of element

  • norm_phi (bool) – Uses the normalised phi value if true, and just a uniform distribution otherwise. Defaults to True.

Returns:

A vote map, i.e., a dictionary whose keys are orders, mapping to the number of voters with the given order as their preferences.

Return type:

dict

generate_urn(num_voters, num_alternatives, replace)

Generates a profile following the urn model. Note that all we are using the prefsampling samplers. This is thus just a wrapper.

Parameters:
  • num_voters (int) – Number of orders to sample.

  • num_alternatives (int) – Number of alternatives for the sampled orders.

  • replace (int) – The number of replacements for the urn model.

Returns:

A vote map, i.e., a dictionary whose keys are orders, mapping to the number of voters with the given order as their preferences.

Return type:

dict

prefsampling_ordinal_wrapper(sampler, sampler_params)