pingouin.gzscore

pingouin.gzscore(x)[source]

Geometric standard (Z) score.

Parameters
xarray_like

Array of raw values

Returns
gzscorearray_like

Array of geometric z-scores (same shape as x)

Notes

Geometric Z-scores are better measures of dispersion than arithmetic z-scores when the sample data come from a log-normally distributed population.

Given the raw scores \(x\), the geometric mean \(\mu_g\) and the geometric standard deviation \(\sigma_g\), the standard score is given by the formula:

\[z = \frac{log(x) - log(\mu_g)}{log(\sigma_g)}\]

References

1

https://en.wikipedia.org/wiki/Geometric_standard_deviation

Examples

Standardize a log-normal array

>>> import numpy as np
>>> from pingouin import gzscore
>>> np.random.seed(123)
>>> raw = np.random.lognormal(size=100)
>>> z = gzscore(raw)
>>> print(round(z.mean(), 3), round(z.std(), 3))
-0.0 0.995