[EM] Exact elections -- Proof of concept
Forest Simmons
forest.simmons21 at gmail.com
Sun Jan 30 15:30:05 PST 2022
Wonderful!
El dom., 30 de ene. de 2022 3:18 p. m., Daniel Carrera <dcarrera at gmail.com>
escribió:
> Here is a more complete implementation. The example in the previous email
> was more of a tutorial + demonstration. This one is more of an actual code
> that you would use. You can have more candidates and higher dimensions. The
> usage is very straightforward:
>
> #
> # EXAMPLE 2
> #
> n_candidates = 4
> n_dim = 5
>
> candidates = np.random.rand(n_candidates,n_dim)
> unit_bound = [ [0,1] for j in range(n_dim) ]
>
> names = ['A','B','C','D']
> tally = compute_tally(candidates,names,unit_bound)
>
>
> This is an example with 4 candidates in a 5-dimensional space. The
> candidates are uniformly randomly distributed and the bounds are the unit
> hypercube. To make the results legible, you need to supply a list of names
> ('A', 'B', 'C', 'D') for the candidates. The compute_tally() function does
> all the work and you just get a dictionary that tells you what fraction of
> voters choose each ballot.
>
> For example:
>
> In [18]: tally
> Out[18]:
> {'A>B>C>D': 0.2158439457766137,
> 'A>B>D>C': 0.058557168066913655,
> 'A>C>B>D': 0.0872,
> 'A>C>D>B': 0.0292,
> 'A>D>B>C': 0.1043845169888461,
> 'A>D>C>B': 0.09699999999999999,
> 'B>A>C>D': 0.019399596489520984,
> ...
>
> and so on.
>
> Cheers,
> --
> Dr. Daniel Carrera
> Postdoctoral Research Associate
> Iowa State University
> ----
> Election-Methods mailing list - see https://electorama.com/em for list
> info
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.electorama.com/pipermail/election-methods-electorama.com/attachments/20220130/865e3c29/attachment.html>
More information about the Election-Methods
mailing list