Made fig_invariance_cross_species_thresh__appendix.pdf.
This commit is contained in:
@@ -54,9 +54,9 @@ calculate_regression = True
|
||||
test_regression = True
|
||||
|
||||
# SUBSET SETTINGS:
|
||||
types = np.array([1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10])
|
||||
types = np.array([1, -1, 2, -2, 3, -3, 4, -4])
|
||||
# types = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]
|
||||
sigmas = np.array([0.001, 0.002, 0.004, 0.008, 0.016, 0.032])
|
||||
sigmas = np.array([0.001, 0.002, 0.004, 0.008, 0.016])
|
||||
# sigmas = [0.001, 0.002, 0.004, 0.008, 0.016, 0.032]
|
||||
kernels = None
|
||||
reduce_kernels = any(var is not None for var in [kernels, types, sigmas])
|
||||
@@ -84,7 +84,7 @@ song_grid_kwargs = dict(
|
||||
)
|
||||
|
||||
# PLOT SETTINGS:
|
||||
kern_colors = load_colors('../data/feat_colors_all.npz')
|
||||
kern_colors = load_colors('../data/feat_colors_subset.npz')
|
||||
fs = dict(
|
||||
lab_norm=16,
|
||||
lab_tex=20,
|
||||
@@ -178,16 +178,44 @@ if test_regression:
|
||||
test_ax_side,
|
||||
test_ax_side
|
||||
]
|
||||
xlab_test = '$\\rho$'
|
||||
ylab_test = '$\\text{PDF}_{\\rho}$'
|
||||
xloc_test = 0.5
|
||||
yloc_test = 10
|
||||
ylab_test = '$\\rho$'
|
||||
yloc_test = 0.5
|
||||
ylab_test_kwargs = dict(
|
||||
x=-0.3,
|
||||
fontsize=fs['lab_norm'],
|
||||
ha='center',
|
||||
va='bottom',
|
||||
)
|
||||
boxplot_kwargs = dict(
|
||||
positions=[0, 1],
|
||||
widths=0.9,
|
||||
tick_labels=['inter', 'intra'],
|
||||
zorder=1,
|
||||
medianprops=dict(
|
||||
color='k',
|
||||
lw=1,
|
||||
),
|
||||
boxprops=dict(
|
||||
color='k',
|
||||
lw=1,
|
||||
),
|
||||
)
|
||||
boxplot_kwargs.update(
|
||||
capprops=boxplot_kwargs['boxprops'],
|
||||
whiskerprops=boxplot_kwargs['boxprops'],
|
||||
)
|
||||
boxplot_dot_kwargs = dict(
|
||||
ls='none',
|
||||
marker='o',
|
||||
ms=4,
|
||||
mec='k',
|
||||
mfc='w',
|
||||
mew=1.5,
|
||||
alpha=0.5,
|
||||
zorder=2,
|
||||
)
|
||||
|
||||
|
||||
nbins = 10
|
||||
spec_color = 'darkorchid'
|
||||
song_color = 'goldenrod'
|
||||
@@ -385,35 +413,22 @@ for x, y in product(range(n_song), range(n_song)):
|
||||
if test_regression:
|
||||
# Add test result subplot:
|
||||
test_ax = fig.add_subplot(test_ax_bounds)
|
||||
test_ax.xaxis.set_major_locator(plt.MultipleLocator(xloc_test))
|
||||
test_ax.set_xlim(-0.6, 1.6)
|
||||
test_ax.set_ylim(0, 1)
|
||||
test_ax.yaxis.set_major_locator(plt.MultipleLocator(yloc_test))
|
||||
xlabel(test_ax, xlab_test, transform=fig.transFigure, **xlab_low_kwargs)
|
||||
ylabel(test_ax, ylab_test, **ylab_test_kwargs)
|
||||
|
||||
# Show boxplots of correlation coefficients:
|
||||
test_ax.boxplot([spec_regs, song_regs], **boxplot_kwargs)
|
||||
|
||||
# Show underlying datapoints:
|
||||
test_ax.plot(np.zeros(len(spec_regs)), spec_regs, **boxplot_dot_kwargs)
|
||||
test_ax.plot(np.ones(len(song_regs)), song_regs, **boxplot_dot_kwargs)
|
||||
|
||||
# Perform t-test:
|
||||
test = ttest_ind(spec_regs, song_regs, equal_var=False)
|
||||
t, p = test.pvalue, test.statistic
|
||||
print(f'\nT-test result: t={t}, p={p}')
|
||||
# Calculate histograms:
|
||||
limits = np.array([min(spec_regs + song_regs), max(spec_regs + song_regs)])
|
||||
limits += np.array([-1.1, 1.1]) * (limits[1] - limits[0])
|
||||
edges = np.linspace(*limits, nbins + 1)
|
||||
centers = edges[:-1] + (edges[1] - edges[0]) / 2
|
||||
spec_hist, _ = np.histogram(spec_regs, bins=edges, density=True)
|
||||
song_hist, _ = np.histogram(song_regs, bins=edges, density=True)
|
||||
# Plot histograms:
|
||||
bar_kwargs['width'] *= (centers[1] - centers[0])
|
||||
test_ax.bar(centers, spec_hist, color=spec_color, label='inter-species', **bar_kwargs)
|
||||
test_ax.bar(centers, song_hist, color=song_color, label='intra-species', **bar_kwargs)
|
||||
# Indicate means:
|
||||
test_ax.axvline(np.mean(spec_regs), color=spec_color, **mean_kwargs)
|
||||
test_ax.axvline(np.mean(song_regs), color=song_color, **mean_kwargs)
|
||||
# Add legend:
|
||||
test_ax.legend(**leg_kwargs)
|
||||
# Posthocs:
|
||||
test_ax.set_ylim(0, max(spec_hist.max(), song_hist.max()) * 1.05)
|
||||
test_ax.set_xlim(min(0, max(-1, limits[0])),
|
||||
min(1, limits[1]))
|
||||
|
||||
|
||||
if save_path is not None:
|
||||
fig.savefig(save_path)
|
||||
|
||||
Reference in New Issue
Block a user