Skip to content

Commit

Permalink
BUG: order of magnitudes was not preserved in _get_payoff_setting
Browse files Browse the repository at this point in the history
  • Loading branch information
sappelhoff committed Nov 26, 2019
1 parent d3787b5 commit 1fa12d2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions sp_experiment/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,20 @@ def _get_payoff_setting(df, trial, experienced=False):
wrong_format_setting.append(i)
continue

# Get the outcomes we have in the sampled distribution/option
# NOTE: make sure that the order of "outcomes" is preserved, i.e.,
# do NOT sort ascending, like a standard np.unique(distr) would do
_, idx = np.unique(distr, return_index=True)
outcomes = np.asarray(distr)[np.sort(idx)]

# Special case 2 if only one outcome sampled: add a 98 with p=0
outcomes = np.unique(distr)
if len(outcomes) < 2:
outcomes = np.append(outcomes, np.array(98))
# Go though outcomes

# After special cases are treated, proceed to go through outcomes
for out_i in outcomes:
wrong_format_setting.append(out_i)
# Round it to one decimal
# Find probability and round it to two decimals
p = np.round(distr.count(out_i) / len(distr), 2)
wrong_format_setting.append(p)

Expand Down

0 comments on commit 1fa12d2

Please sign in to comment.