Package Overview#
BSSUnfold is a Python package for neutron spectrum unfolding from Bonner Sphere Spectrometers (BSS). It provides 17 unfolding algorithms, 25 spectrum comparison metrics, ICRP-116 dose calculations, and Monte Carlo uncertainty quantification.
Unfolding Methods#
All 17 methods are accessible as instance methods on the
bssunfold.Detector class. They are organised into the following
categories:
graph TD
A["Unfolding Methods"] --> B["Tikhonov-type"]
A --> C["Iterative"]
A --> D["Bayesian"]
A --> E["Maximum Entropy"]
A --> F["Statistical Regularization"]
A --> G["Optimization-based"]
A --> H["Pipeline"]
B --> B1["unfold_cvxpy"]
B --> B2["unfold_qpsolvers"]
B --> B3["unfold_tsvd"]
B --> B4["unfold_tikhonov_legendre"]
C --> C1["unfold_landweber"]
C --> C2["unfold_mlem"]
C --> C3["unfold_mlem_odl"]
C --> C4["unfold_gravel"]
C --> C5["unfold_doroshenko"]
C --> C6["unfold_kaczmarz"]
D --> D1["unfold_bayes"]
D --> D2["unfold_bayes_spline_regularization"]
E --> E1["unfold_maxed"]
F --> F1["unfold_statreg"]
G --> G1["unfold_lmfit"]
G --> G2["unfold_scipy_direct_method"]
H --> H1["unfold_combined"]
style A fill:#4a90d9,color:#fff
style B fill:#e8f0fe
style C fill:#e8f0fe
style D fill:#e8f0fe
style E fill:#e8f0fe
style F fill:#e8f0fe
style G fill:#e8f0fe
style H fill:#e8f0fe
Method Reference#
# |
Method |
Category |
Unique Parameters |
Dependencies |
Description |
|---|---|---|---|---|---|
1 |
|
Tikhonov |
|
cvxpy |
Convex optimization with Tikhonov regularization |
2 |
|
Tikhonov |
|
qpsolvers |
QP-based unfolding with L1/L2/smoothness norms |
3 |
|
Tikhonov |
|
— |
Truncated SVD with automatic k-selection |
4 |
|
Tikhonov |
|
— |
Tikhonov regularization in Legendre polynomial basis |
5 |
|
Iterative |
|
— |
Landweber fixed-point iteration |
6 |
|
Iterative |
|
— |
Pure-NumPy MLEM (expectation maximization) |
7 |
|
Iterative |
|
odl |
MLEM via ODL operator framework |
8 |
|
Iterative |
|
— |
GRAVEL with relative entropy weighting |
9 |
|
Iterative |
|
— |
Coordinate-update iterative method |
10 |
|
Iterative |
|
— |
ART (Algebraic Reconstruction Technique) |
11 |
|
Bayesian |
|
— |
D’Agostini Bayesian iterative unfolding |
12 |
|
Bayesian |
|
— |
Bayes with spline smoothing on log10-spectrum |
13 |
|
MaxEnt |
|
— |
Maximum entropy deconvolution |
14 |
|
Statistical Reg. |
|
— |
Turchin’s statistical regularization |
15 |
|
Optimization |
|
lmfit |
L1/L2/Elastic Net via lmfit |
16 |
|
Optimization |
|
— |
Direct SciPy linear solvers |
17 |
|
Pipeline |
|
— |
Sequential multi-method pipeline |
Note
Common parameters shared by most methods:
readings, initial_spectrum, calculate_errors, noise_level,
n_montecarlo, save_result, random_state.
See the Index or Detector Class for complete API signatures.
Spectrum Comparison Metrics#
25 metrics organised into 7 categories. All implemented with pure NumPy/SciPy.
graph TD
A["Comparison Metrics"] --> B["Entropy"]
A --> C["Distribution"]
A --> D["Correlation"]
A --> E["Error"]
A --> F["Similarity"]
A --> G["Chi-squared"]
A --> H["Statistical"]
B --> B1["kl_divergence"]
B --> B2["cross_entropy"]
B --> B3["entropy_difference_percent"]
C --> C1["wasserstein_dist"]
C --> C2["energy_dist"]
C --> C3["kolmogorov_smirnov_stat"]
D --> D1["pearson_r"]
D --> D2["spearman_r"]
E --> E1["mean_squared_error"]
E --> E2["root_mean_squared_error"]
E --> E3["mean_absolute_error"]
E --> E4["mape"]
E --> E5["r2_score"]
E --> E6["max_error"]
E --> E7["median_absolute_error"]
F --> F1["cosine_similarity"]
F --> F2["mmd_rbf"]
G --> G1["chi_squared"]
G --> G2["g_test"]
G --> G3["freeman_tukey"]
G --> G4["cressie_read"]
H --> H1["anderson_darling"]
H --> H2["wilcoxon_test"]
H --> H3["mannwhitneyu_test"]
H --> H4["standardized_mean_difference"]
style A fill:#4a90d9,color:#fff
Metrics Reference#
Category |
Metric Key |
Description |
Range |
|---|---|---|---|
Entropy |
|
Kullback-Leibler divergence D_KL(p‖q) |
[0, ∞) |
|
Cross-entropy H(p,q) = -∑p·log(q) |
[0, ∞) |
|
|
Relative cross-entropy excess (%) |
[0, ∞) |
|
Distribution |
|
Earth mover’s / Wasserstein distance |
[0, ∞) |
|
Energy distance between distributions |
[0, ∞) |
|
|
Kolmogorov-Smirnov D-statistic |
[0, 1] |
|
Correlation |
|
Pearson correlation coefficient |
[-1, 1] |
|
Spearman rank correlation |
[-1, 1] |
|
Error |
|
Mean squared error |
[0, ∞) |
|
Root mean squared error |
[0, ∞) |
|
|
Mean absolute error |
[0, ∞) |
|
|
Mean absolute percentage error (%) |
[0, 100] |
|
|
R² (coefficient of determination) |
(-∞, 1] |
|
|
Maximum residual error |
[0, ∞) |
|
|
Median absolute error |
[0, ∞) |
|
Similarity |
|
Cosine similarity cos(θ) |
[0, 1] |
|
Maximum Mean Discrepancy (RBF kernel) |
[0, ∞) |
|
Chi-squared |
|
Pearson’s chi-squared statistic |
[0, ∞) |
|
G-test (log-likelihood ratio) |
[0, ∞) |
|
|
Freeman-Tukey statistic |
[0, ∞) |
|
|
Cressie-Read power divergence |
[0, ∞) |
|
Statistical |
|
Anderson-Darling k-sample statistic |
[0, ∞) |
|
Wilcoxon signed-rank test statistic |
[0, ∞) |
|
|
Mann-Whitney U test statistic |
[0, ∞) |
|
|
Cohen’s d (standardized mean difference) |
(-∞, ∞) |