pyrolite.util.distributions
- pyrolite.util.distributions.get_scaler(*fs)[source]
Generate a function which will transform columns of an array based on input functions (e.g.
np.logwill log-transform the x values,None, np.logwill log-transform the y values but not the x).
- Parameters:
fs – A series of functions to apply to subsequent axes of an array.
- pyrolite.util.distributions.sample_kde(data, samples, renorm=False, transform=<function <lambda>>, bw_method=None)[source]
Sample a Kernel Density Estimate at points or a grid defined.
- Parameters:
data (
numpy.ndarray) – Source data to estimate the kernel density estimate; observations should be in rows (npoints, ndim).samples (
numpy.ndarray) – Coordinates to sample the KDE estimate at (npoints, ndim).transform – Transformation used prior to kernel density estimate.
bw_method (
str,float, callable) – Method used to calculate the estimator bandwidth. Seescipy.stats.gaussian_kde().- Return type:
- pyrolite.util.distributions.sample_ternary_kde(data, samples, transform=<function ILR>)[source]
Sample a Kernel Density Estimate in ternary space points or a grid defined by samples.
- Parameters:
data (
numpy.ndarray) – Source data to estimate the kernel density estimate (npoints, ndim).samples (
numpy.ndarray) – Coordinates to sample the KDE estimate at (npoints, ndim)..transform – Log-transformation used prior to kernel density estimate.
- Return type:
- pyrolite.util.distributions.lognorm_to_norm(mu, s)[source]
Calculate mean and variance for a normal random variable from the lognormal parameters
muands.
- pyrolite.util.distributions.norm_to_lognorm(mean, sigma, exp=True)[source]
Calculate
muandsigmaparameters for a lognormal random variable with a given mean and variance. Lognormal with parametersmeanandsigma.
- Parameters:
mean (
float) – Mean of the normal distribution.sigma (
float) –sigmaof the normal distribution.exp (
bool) – If using thescipy.statsparameterisation; this usesscale = np.exp(mu).- Returns: