2.1.4.1.5. sf_tools.math.stats module¶
STATISTICS ROUTINES
This module contains methods for basic statistics.
Author: | Samuel Farrens <samuel.farrens@gmail.com> |
---|---|
Version: | 1.2 |
Date: | 20/10/2017 |
-
sf_tools.math.stats.
chi2_gof
(data_obs, data_exp, sigma, ddof=1)[source]¶ Chi-squared goodness-of-fit
This method tests the chi^2 goodness of fit.
Parameters: Returns: Return type: tuple of floats chi-squared and P values
-
sf_tools.math.stats.
gaussian
(point, mean, sigma, amplitude=None)[source]¶ Gaussian distribution
Method under development…
-
sf_tools.math.stats.
gaussian_kernel
(data_shape, sigma, norm='max')[source]¶ Gaussian kernel
This method produces a Gaussian kerenal of a specified size and dispersion
Parameters: Returns: Return type: np.ndarray kernel
-
sf_tools.math.stats.
mad
(data)[source]¶ Median absolute deviation
This method calculates the median absolute deviation of the input data.
Parameters: data (np.ndarray) – Input data array Returns: Return type: float MAD value Notes
The MAD is calculated as follows:
\[\mathrm{MAD} = \mathrm{median}\left(|X_i - \mathrm{median}(X)|\right)\]
-
sf_tools.math.stats.
mse
(data1, data2)[source]¶ Mean Squared Error
This method returns the Mean Squared Error (MSE) between two data sets.
Parameters: - data1 (np.ndarray) – First data set
- data2 (np.ndarray) – Second data set
-
sf_tools.math.stats.
psnr2
(image, noisy_image, max_pix=255)[source]¶ Peak Signal-to-Noise Ratio
This method calculates the PSNR between an image and a noisy version of that image
Parameters: - image (np.ndarray) – Input image, 2D array
- noisy_image (np.ndarray) – Noisy image, 2D array
- max_pix (int) – Maximum number of pixels. Default (max_pix=255)
Returns: Return type: float PSNR value
Notes
Implements PSNR equation on https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio
\[\mathrm{PSNR} = 20\log_{10}(\mathrm{MAX}_I - 10\log_{10}(\mathrm{MSE}))\]
-
sf_tools.math.stats.
psnr
(image, recovered_image)[source]¶ Peak Signal-to-Noise Ratio
This method calculates the PSNR between an image and the recovered version of that image
Parameters: - image (np.ndarray) – Input image, 2D array
- recovered_image (np.ndarray) – Recovered image, 2D array
Returns: Return type: float PSNR value
Notes
Implements eq.3.7 from _[S2010]
-
sf_tools.math.stats.
psnr_stack
(images, recoverd_images, metric=<function mean>)[source]¶ Peak Signa-to-Noise for stack of images
This method calculates the PSNRs for a stack of images and the corresponding recovered images. By default the metod returns the mean value of the PSNRs, but any other metric can be used.
Parameters: - images (np.ndarray) – Stack of images, 3D array
- recovered_images (np.ndarray) – Stack of recovered images, 3D array
- metric (function) – The desired metric to be applied to the PSNR values (default is ‘np.mean’)
Returns: Return type: float metric result of PSNR values
Raises: ValueError
– For invalid input data dimensions
-
sf_tools.math.stats.
sigma_mad
(data)[source]¶ Standard deviation from MAD
This method calculates the standard deviation of the input data from the MAD.
Parameters: data (np.ndarray) – Input data array Returns: Return type: float sigma value Notes
This function can be used for estimating the standeviation of the noise in imgaes.
Sigma is calculated as follows:
\[\sigma = 1.4826 \mathrm{MAD}(X)\]