smoofit.utils.build_1d_tunfold_matrix

smoofit.utils.build_1d_tunfold_matrix(n_bins, bin_widths=None)[source]

Build matrix of discrete second derivatives for TUnfold-like regularization in 1 dimension

The second derivative operator of a 1D array with n entries is the (n-2,n) matrix

\[\begin{split}\begin{pmatrix} 1 & -2 & 1 & 0 & \dots & 0 \\ 0 & 1 & -2 & 1 & \dots & 0 \\ \dots & & & & & \\ 0 & \dots & 0 & 1 & -2 & 1 \end{pmatrix}\end{split}\]

This assumes uniform spacing (bin width) of the entries. If that is not the case, the estimation of the derivatives should take that into account. Given the differential cross sections \(s_{i-1}\), \(s_i\), \(s_{i+1}\), and the corresponding bin widths \(w_{i-1}\), \(w_{i}\), and \(w_{i+1}\), the distances between the bin centers are therefore \(d_i = 0.5(w_{i-1} + w_i)\) and \(d_{i+1} = 0.5(w_i + w_{i+1})\), and the second derivative in \(i\) is estimated as:

\[s_{i-1} \frac{2}{d_i (d_i + d_{i+1})} + s_i \frac{4}{d_i d_{i+1} (d_i + d_{i+1})} + s_{i+1} \frac{2}{d_{i+1} (d_i + d_{i+1})}\]
Parameters
  • n_bins (int) – number of elements in the vector for which the second derivative is to be computed (should be \(\geq 3\))

  • bin_widths (Union[List[float], ndarray, DeviceArrayBase, None]) – 1D array with n_bins entries specifying the bin widths of the distribution

Return type

DeviceArrayBase

Returns

matrix of second derivatives