PDF

class turbustat.statistics.PDF(img, min_val=-inf, bins=None, weights=None, normalization_type=None)[source] [edit on github]

Bases: turbustat.statistics.base_statistic.BaseStatisticMixIn

Create the PDF of a given array.

Parameters:

img : numpy.ndarray or astropy.io.fits.PrimaryHDU or spectral_cube.LowerDimensionalObject or SpectralCube

A 1-3D array.

min_val : float, optional

Minimum value to keep in the given image.

bins : list or numpy.ndarray or int, optional

Bins to compute the PDF from.

weights : numpy.ndarray or astropy.io.fits.PrimaryHDU or spectral_cube.LowerDimensionalObject or SpectralCube, optional

Weights to apply to the image. Must have the same shape as the image.

use_standardized : bool, optional

Enable to standardize the data before computing the PDF and ECDF.

normalization_type : {“standardize”, “center”, “normalize”,

“normalize_by_mean”}, optional

See data_normalization.

Attributes Summary

bins Bin centers.
ecdf ECDF values in bins.
model_params Parameters of the fitted model.
model_stderrs Standard errors of the fitted model.
normalization_type
pdf PDF values in bins.

Methods Summary

corner_plot(**kwargs) Create a corner plot from the MCMC.
find_at_percentile(percentiles) Return the values at the given percentiles.
find_percentile(values) Return the percentiles of given values from the data distribution.
fit_pdf([model, verbose, fit_type]) Fit a model to the PDF.
make_ecdf() Create the ECDF.
make_pdf([bins]) Create the PDF.
run([verbose, save_name, bins, do_fit, model]) Compute the PDF and ECDF.

Attributes Documentation

bins

Bin centers.

ecdf

ECDF values in bins.

model_params

Parameters of the fitted model.

model_stderrs

Standard errors of the fitted model. If using an MCMC, the 15th and 85th percentiles are returned.

normalization_type
pdf

PDF values in bins.

Methods Documentation

corner_plot(**kwargs)[source] [edit on github]

Create a corner plot from the MCMC. Requires the ‘corner’ package.

Parameters:kwargs : Passed to corner.
find_at_percentile(percentiles)[source] [edit on github]

Return the values at the given percentiles.

Parameters:

percentiles : float or np.ndarray

Percentile or array of percentiles. Must be between 0 and 100.

find_percentile(values)[source] [edit on github]

Return the percentiles of given values from the data distribution.

Parameters:

values : float or np.ndarray

Value or array of values.

fit_pdf(model=<scipy.stats._continuous_distns.lognorm_gen object>, verbose=False, fit_type='mle', **kwargs)[source] [edit on github]

Fit a model to the PDF. Use statsmodel’s generalized likelihood setup to get uncertainty estimates and such.

Parameters:

model : scipy.stats distribution, optional

Pass any scipy distribution. NOTE: All fits assume loc can be fixed to 0. This is reasonable for all realistic PDF forms in the ISM.

verbose : bool, optional

Enable printing of the fit results.

fit_type : {‘mle’, ‘mcmc’}, optional

Type of fitting to use. By default Maximum Likelihood Estimation

(‘mle’) is used. An MCMC approach (‘mcmc’) may also be used. This requires the optional emcee to be installed. kwargs can be passed to adjust various properties of the MCMC chain.

kwargs : Passed to EnsembleSampler.

make_ecdf()[source] [edit on github]

Create the ECDF.

make_pdf(bins=None)[source] [edit on github]

Create the PDF.

Parameters:

bins : list or numpy.ndarray or int, optional

Bins to compute the PDF from. Overrides initial bin input.

run(verbose=False, save_name=None, bins=None, do_fit=True, model=<scipy.stats._continuous_distns.lognorm_gen object>, **kwargs)[source] [edit on github]

Compute the PDF and ECDF. Enabling verbose provides a summary plot.

Parameters:

verbose : bool, optional

Enables plotting of the results.

save_name : str,optional

Save the figure when a file name is given.

bins : list or numpy.ndarray or int, optional

Bins to compute the PDF from. Overrides initial bin input.

do_fit : bool, optional

Enables (by default) fitting a given model.

model : scipy.stats distribution, optional

Pass any scipy distribution. See fit_pdf.

kwargs : Passed to fit_pdf.