Maths¶
Mathematics.
Binning
¶
clusterking.maths.binning.
bin_function
(fct, binning: numpy.array, normalize=False) → numpy.array[source]¶Bin function, i.e. calculate the integrals of a function for each bin.
Parameters:
- fct – Function to be integrated per bin
- binning – Array of bin edge points.
- normalize – If true, we will normalize the distribution, i.e. divide by the sum of all bins in the end.
Returns: Array of bin contents
Metric
¶
clusterking.maths.metric.
chi2
(n1: numpy.ndarray, n2: numpy.ndarray, cov1: numpy.ndarray, cov2: numpy.ndarray, normalize=False) → numpy.ndarray[source]¶
Parameters:
- n1 – n_obs x n_bins
- n2 – Either n_obs x n_bins or just nbins if we’re testing against a constant histogram
- cov1 – Either n_obs x n_bins x n_bins or n_bins x n_bins
- cov2 – Either n_obs x n_bins x n_bins or n_bins x n_bins
- normalize –
Returns: n_obs vector of chi2 test results (degrees of freedom not yet divided out)
clusterking.maths.metric.
chi2_metric
(dwe: clusterking.data.dwe.DataWithErrors, output='condensed')[source]¶Returns the chi2/ndf values of the comparison of a datasets.
Parameters:
- dwe –
clusterking.data.dwe.DataWithErrors
object- output – ‘condensed’ (condensed distance matrix) or ‘full’ (full distance matrix)
Returns: Condensed distance matrix or full distance matrix
Statistics
¶
clusterking.maths.statistics.
cov2err
(cov)[source]¶Convert covariance matrix (or array of covariance matrices of equal shape) to error array (or array thereof).
Parameters: cov – [n x ] nbins x nbins array
- Returns
- [n x ] nbins array
clusterking.maths.statistics.
cov2corr
(cov)[source]¶Convert covariance matrix (or array of covariance matrices of equal shape) to correlation matrix (or array thereof).
Parameters: cov – [n x ] nbins x nbins array
- Returns
- [n x ] nbins x nbins array
clusterking.maths.statistics.
corr2cov
(corr, err)[source]¶Convert correlation matrix (or array of covariance matrices of equal shape) together with error array (or array thereof) to covariance matrix (or array thereof).
Parameters:
- corr – [n x ] nbins x nbins array
- err – [n x ] nbins array
- Returns
- [n x ] nbins x nbins array