PDF_Distance

class turbustat.statistics.PDF_Distance(img1, img2, min_val1=-inf, min_val2=-inf, do_fit=True, normalization_type=None, nbins=None, weights1=None, weights2=None, bin_min=None, bin_max=None)[source]

Bases: object

Calculate the distance between two arrays using their PDFs.

Note

Pre-computed PDF classes cannot be passed to PDF_Distance as the data need to be normalized and the PDFs should use the same set of histogram bins.

Parameters:
img1numpy.ndarray or astropy.io.fits.PrimaryHDU or astropy.io.fits.ImageHDU or spectral_cube.Projection or spectral_cube.Slice or SpectralCube

Array (1-3D).

img2numpy.ndarray or astropy.io.fits.PrimaryHDU or astropy.io.fits.ImageHDU or spectral_cube.Projection or spectral_cube.Slice or SpectralCube

Array (1-3D).

min_val1float, optional

Minimum value to keep in img1

min_val2float, optional

Minimum value to keep in img2

do_fitbool, optional

Enables fitting a lognormal distribution to each data set.

normalization_type{“normalize”, “normalize_by_mean”}, optional

See data_normalization.

nbinsint, optional

Manually set the number of bins to use for creating the PDFs.

weights1numpy.ndarray or astropy.io.fits.PrimaryHDU or astropy.io.fits.ImageHDU or spectral_cube.Projection or spectral_cube.Slice or SpectralCube, optional

Weights to be used with img1

weights2numpy.ndarray or astropy.io.fits.PrimaryHDU or astropy.io.fits.ImageHDU or spectral_cube.Projection or spectral_cube.Slice or SpectralCube, optional

Weights to be used with img2

bin_minfloat, optional

Minimum value to use for the histogram bins after normalization is applied.

bin_maxfloat, optional

Maximum value to use for the histogram bins after normalization is applied.

Methods Summary

compute_ad_distance()

Compute the distance using the Anderson-Darling Test.

compute_hellinger_distance()

Computes the Hellinger Distance between the two PDFs.

compute_ks_distance()

Compute the distance using the KS Test.

compute_lognormal_distance()

Compute the combined t-statistic for the difference in the widths of a lognormal distribution.

distance_metric([statistic, verbose, ...])

Calculate the distance.

Methods Documentation

compute_ad_distance()[source]

Compute the distance using the Anderson-Darling Test.

compute_hellinger_distance()[source]

Computes the Hellinger Distance between the two PDFs.

compute_ks_distance()[source]

Compute the distance using the KS Test.

compute_lognormal_distance()[source]

Compute the combined t-statistic for the difference in the widths of a lognormal distribution.

distance_metric(statistic='all', verbose=False, plot_kwargs1={'color': 'b', 'label': '1', 'marker': 'D'}, plot_kwargs2={'color': 'g', 'label': '2', 'marker': 'o'}, save_name=None)[source]

Calculate the distance. NOTE: The data are standardized before comparing to ensure the distance is calculated on the same scales.

Parameters:
statistic‘all’, ‘hellinger’, ‘ks’, ‘lognormal’

Which measure of distance to use.

labelstuple, optional

Sets the labels in the output plot.

verbosebool, optional

Enables plotting.

plot_kwargs1dict, optional

Pass kwargs to plot for dataset1.

plot_kwargs2dict, optional

Pass kwargs to plot for dataset2.

save_namestr,optional

Save the figure when a file name is given.