# Bucket shift
ax_010 = plt.Subplot(f, gs01[1, 0])
f.add_subplot(ax_010)
ax_010.plot(x, df_data['sim_y_t'][plot_range[0]:plot_range[1]], linewidth=2, color="#090030")
ax_010.set_ylabel('Bucket shift')
ax_010.set_xlabel('Trial')

# -------------------------------------------
# 9. Plot perseveration and estimation errors
# -------------------------------------------

# Perseveration
gs02 = gridspec.GridSpecFromSubplotSpec(2, 3, subplot_spec=gs0[2:5, :], wspace=0.5, hspace=0.5)
ax_11 = plt.Subplot(f, gs02[0, 0])
f.add_subplot(ax_11)
ax_11 = swarm_boxplot(ax_11, fig_5_c_cond_diff, 'pers', 'Perseveration-\nprobability difference', 2)

# Estimation errors
ax_12 = plt.Subplot(f, gs02[0, 1])
f.add_subplot(ax_12)
swarm_boxplot(ax_12, fig_5_d_cond_diff, 'e_t', 'Estimation-\nerror difference', 2)

# ---------------------------------------------------
# 10. Plot learning rate and bucket bias (regression)
# ---------------------------------------------------

# Learning rate
ax_13 = plt.Subplot(f, gs02[0, 2])
f.add_subplot(ax_13)
swarm_boxplot(ax_13, df_reg, 'alpha', ' ', 2)
ax_13.set_ylabel('Learning rate')
Esempio n. 2
0
# Create figure
f = plt.figure(figsize=cm2inch(fig_width, fig_height))

# Plot colors
colors = ["#92e0a9", "#69b0c1", "#6d6192", "#352d4d"]
sns.set_palette(sns.color_palette(colors))

# ---------------------------
# 3. Plot parameter estimates
# ---------------------------

# omikron_0
plt.subplot(221)
ax_00 = plt.gca()
swarm_boxplot(ax_00, model_exp1, 'omikron_0', 'Parameter estimate', 1)
ax_00.set_title('Motor noise')

# omikron_1
plt.subplot(222)
ax_01 = plt.gca()
swarm_boxplot(ax_01, model_exp1, 'omikron_1', 'Parameter estimate', 1)
ax_01.set_title('Learning-rate noise')

# q
plt.subplot(223)
ax_10 = plt.gca()
swarm_boxplot(ax_10, model_exp1, 'q', 'Parameter estimate', 1)
ax_10.set_title('Reward bias')

# sigma_H
colors = ["#92e0a9", "#69b0c1", "#6d6192", "#352d4d"]
sns.set_palette(sns.color_palette(colors))

# Create figure
fig_height = 13.5
fig_witdh = 15
f = plt.figure(figsize=cm2inch(fig_witdh, fig_height))

# ---------------------------
# 4. Plot parameter estimates
# ---------------------------

# omikron_0
plt.subplot(331)
ax_00 = plt.gca()
swarm_boxplot(ax_00, model_results, 'omikron_0', 'Parameter estimate', 2)
ax_00.set_title('Motor noise')

# omikron_1
plt.subplot(332)
ax_01 = plt.gca()
swarm_boxplot(ax_01, model_results, 'omikron_1', 'Parameter estimate', 2)
ax_01.set_title('Learning-rate noise')

# u
plt.subplot(333)
ax_02 = plt.gca()
swarm_boxplot(ax_02, model_results, 'u', 'Parameter estimate', 2)
ax_02.set_title('Uncertainty underestimation')

# s
Esempio n. 4
0
# -------------------------------
# 3. Plot perseveration frequency
# -------------------------------

# Create subplot grid
gs_00 = gridspec.GridSpecFromSubplotSpec(2,
                                         3,
                                         subplot_spec=gs_0[0],
                                         hspace=0.6,
                                         wspace=0.5)

# Plot perseveration frequency
exp = 1
ax_00 = plt.Subplot(f, gs_00[0, 0])
f.add_subplot(ax_00)
swarm_boxplot(ax_00, pers, 'pers', 'Estimated probability', exp)
ax_00.set_title('Participant perseveration')

# ----------------------------------
# 4. Plot mixture-model illustration
# ----------------------------------

# Adjust data frame
model_results['subj_num'] = np.arange(0, len(model_results))

# Extract parameter estimates for the group of younger adults
ya_median_h = np.median(model_results[model_results['age_group'] == 3]['h'])
ya_median_s = np.median(model_results[model_results['age_group'] == 3]['s'])
ya_median_u = np.median(model_results[model_results['age_group'] == 3]['u'])

# Create agent-object instance for learning-rate illustration
# ----------------------------------------------
# 7. Plot performance and average learning rates
# ----------------------------------------------

# Create subplot grid
gs_02 = gridspec.GridSpecFromSubplotSpec(1,
                                         2,
                                         subplot_spec=gs_0[3],
                                         hspace=0.1,
                                         wspace=0.5)

# Plot estimation-error swarm-boxplot
exp = 1
ax_2 = plt.Subplot(f, gs_02[0, 0])
f.add_subplot(ax_2)
ax_2 = swarm_boxplot(ax_2, e_t, 'e_t', 'Estimation error', exp)

# Plot learning-rate swarm-boxplot
exp = 1
ax_3 = plt.Subplot(f, gs_02[0, 1])
f.add_subplot(ax_3)
ax_3 = swarm_boxplot(ax_3, df_alpha, 'alpha', 'Learning rate', exp)

# Delete unnecessary axes
sns.despine()

# -------------------------------------
# 8. Add subplot labels and save figure
# -------------------------------------

# Label letters
ax_02.plot(np.arange(80), alpha_h, color="#584b42")
ax_02.set_ylim([-0.02, 1.02])
ax_02.set_xlabel('Prediction error')
ax_02.set_title('Simulated\nhazard-rate impact')

# ---------------------------
# 5. Plot parameter estimates
# ---------------------------

# Plot properties
exp = 1

# Uncertainty underestimation
ax_10 = plt.Subplot(f, gs_00[1, 0])
f.add_subplot(ax_10)
swarm_boxplot(ax_10, model_results, 'u', 'Parameter estimate', exp)
ax_10.set_ylim([-1.5, 8.5])
ax_10.set_title('Empirical\nuncertainty underestimation')

# Surprise sensitivity
ax_11 = plt.Subplot(f, gs_00[1, 1])
f.add_subplot(ax_11)
swarm_boxplot(ax_11, model_results, 's', ' ', exp)
ax_11.set_title('Empirical\nsurprise sensitivity')

# Hazard rate
ax_12 = plt.Subplot(f, gs_00[1, 2])
f.add_subplot(ax_12)
swarm_boxplot(ax_12, model_results, 'h', ' ', exp)
ax_12.set_title('Empirical\nhazard rate')
sns.despine()
                                     1]['age_group'])

# Add learning rate results to data frame
df_reg = pd.DataFrame()
df_reg['alpha'] = alpha
df_reg['bucket_bias'] = bucket_bias
df_reg['age_group'] = age_group

# --------------------------------------------------------------------
# 7. Plot bucket bias, perseveration probability and estimation errors
# --------------------------------------------------------------------

# Plot bucket bias
ax_1 = plt.Subplot(f, gs_12[0, 1])
f.add_subplot(ax_1)
swarm_boxplot(ax_1, df_reg, 'bucket_bias', ' ', 2)
ax_1.set_ylabel('Belief bias (regression)')

# Difference between conditions
all_est_errs['diff'] = all_est_errs['push'] - all_est_errs['noPush']
all_pers['diff'] = all_pers['push'] - all_pers['noPush']

# Plot perseveration probability
ax_0 = plt.Subplot(f, gs_12[1, 0])
f.add_subplot(ax_0)
swarm_boxplot(ax_0, all_pers, "diff", "diff", 2)
ax_0.set_ylabel('Perseveration-\nprobability difference')
ax_0.set_xlabel('Age group')
plt.xticks([0, 1, 2], ('CH', 'YA', 'OA'))

# Plot estimation errors