Skip to content

Commit

Permalink
Add kurtosis as metric to evaluate performance of standardization
Browse files Browse the repository at this point in the history
  • Loading branch information
rhugonnet committed Nov 3, 2023
1 parent 1bec388 commit 405167a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion examples/advanced/plot_standardization.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
maxc_arr = np.maximum(np.abs(planc_arr), np.abs(profc_arr))

# Remove large outliers
dh_arr[np.abs(dh_arr) > 4 * xdem.spatialstats.nmad(dh_arr)] = np.nan
dh_arr[np.abs(dh_arr) > 7 * xdem.spatialstats.nmad(dh_arr)] = np.nan

# Define bins for 2D binning
custom_bin_slope = np.unique(
Expand Down Expand Up @@ -97,6 +97,12 @@
z_dh.data[mask_glacier.data] = np.nan
z_dh.data[np.abs(z_dh.data) > 4] = np.nan

from scipy.stats import kurtosis
kbef = kurtosis(dh_arr, nan_policy="omit")
kaft = kurtosis(z_dh.flatten(), nan_policy="omit")
print("Excess kurtosis before standardization: {}".format(kbef))
print("Excess kurtosis after standardization: {}".format(kaft))

# %%
# We perform a scale-correction for the standardization, to ensure that the spread of the data is exactly 1.
# The NMAD is used as a robust measure for the spread (see :ref:`robuststats-nmad`).
Expand Down

0 comments on commit 405167a

Please sign in to comment.