-
Notifications
You must be signed in to change notification settings - Fork 4
Add 95% CI error bars to CE and CW examples (Sourcery refactored) #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
| | SU max | 100.0 | 84.1 | 79.6 | 78.4 | 77.3 | 77.5 | | ||
| | CW | 100.0 | 91.7 | 83.1 | 75.6 | 64.3 | 52.9 | | ||
| """ | ||
|
|
||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
This removes the following comments ( why? ): |
||
| import time | ||
| from collections import Counter | ||
| import numpy as np | ||
|
|
@@ -51,7 +52,7 @@ | |
|
|
||
| start_time = time.monotonic() | ||
|
|
||
| for iteration in range(n_elections): | ||
| for _ in range(n_elections): | ||
| for n_cands in n_cands_list: | ||
| utilities = random_utilities(n_voters, n_cands) | ||
|
|
||
|
|
@@ -126,11 +127,12 @@ | |
|
|
||
| # Likelihood that social utility maximizer is Condorcet Winner | ||
| x, y = zip(*sorted(condorcet_winner_count['SU max'].items())) | ||
| table.append(['SU max', *np.array(y)/y_cw*100]) | ||
|
|
||
| # Likelihood of Condorcet Winner (normalized by n elections) | ||
| table.append(['CW', *np.asarray(y_cw) / n_elections * 100]) | ||
|
|
||
| table.extend( | ||
| ( | ||
| ['SU max', *np.array(y) / y_cw * 100], | ||
| ['CW', *np.asarray(y_cw) / n_elections * 100], | ||
| ) | ||
| ) | ||
| print(tabulate(table, ["Method", *x], tablefmt="pipe", floatfmt='.1f')) | ||
|
|
||
| plt.plot([], [], 'k:', lw=0.8, label='Merrill') # Dummy plot for label | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,7 +52,7 @@ def simulate_batch(n_voters): | |
| condorcet_paradox_count = Counter() | ||
| # Reuse the same chunk of memory to save time | ||
| election = np.empty((n_voters, n_cands), dtype=np.uint8) | ||
| for iteration in range(batch_size): | ||
| for _ in range(batch_size): | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| election[:] = impartial_culture(n_voters, n_cands) | ||
| CW = condorcet(election) | ||
| if CW is None: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines
96-96refactored with the following changes:for-index-underscore)