-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from SpeysideHEP/combiner
Bugfix in stat combiner
- Loading branch information
Showing
7 changed files
with
158 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
"""Version number (major.minor.patch[-label])""" | ||
|
||
__version__ = "0.1.10" | ||
__version__ = "0.1.11-beta" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"""Test uncorrelated statistics combiner""" | ||
|
||
import numpy as np | ||
|
||
import spey | ||
from spey.combiner.uncorrelated_statistics_combiner import UnCorrStatisticsCombiner | ||
|
||
|
||
def test_combiner(): | ||
"""Test uncorrelated statistics combiner""" | ||
|
||
normal = spey.get_backend("default_pdf.normal")( | ||
signal_yields=[1, 1, 1], | ||
background_yields=[2, 1, 3], | ||
data=[2, 2, 2], | ||
absolute_uncertainties=[1, 1, 1], | ||
) | ||
normal_cls = normal.exclusion_confidence_level()[0] | ||
normal = spey.get_backend("default_pdf.multivariate_normal")( | ||
signal_yields=[1, 1, 1], | ||
background_yields=[2, 1, 3], | ||
data=[2, 2, 2], | ||
covariance_matrix=np.diag([1, 1, 1]), | ||
) | ||
multivar_norm_cls = normal.exclusion_confidence_level()[0] | ||
|
||
assert np.isclose( | ||
normal_cls, multivar_norm_cls | ||
), "Normal CLs is not the same as Multivariant normal CLs" | ||
|
||
normal1 = spey.get_backend("default_pdf.normal")( | ||
signal_yields=[1], | ||
background_yields=[3], | ||
data=[2], | ||
absolute_uncertainties=[1], | ||
analysis="norm1", | ||
) | ||
normal2 = spey.get_backend("default_pdf.normal")( | ||
signal_yields=[1], | ||
background_yields=[1], | ||
data=[2], | ||
absolute_uncertainties=[1], | ||
analysis="norm2", | ||
) | ||
normal3 = spey.get_backend("default_pdf.normal")( | ||
signal_yields=[1], | ||
background_yields=[2], | ||
data=[2], | ||
absolute_uncertainties=[1], | ||
analysis="norm3", | ||
) | ||
combined = UnCorrStatisticsCombiner(normal1, normal2, normal3) | ||
combined_cls = combined.exclusion_confidence_level()[0] | ||
|
||
assert np.isclose(multivar_norm_cls, combined_cls), "Combined CLs is wrong" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"""Test simplified models at the limit""" | ||
|
||
import numpy as np | ||
|
||
import spey | ||
from spey.helper_functions import covariance_to_correlation | ||
|
||
|
||
def test_simplified_llhds_at_limit(): | ||
"""Test models at the limit""" | ||
|
||
base_model = spey.get_backend("default_pdf.uncorrelated_background")( | ||
signal_yields=[1, 1, 1], | ||
background_yields=[2, 1, 3], | ||
data=[2, 2, 2], | ||
absolute_uncertainties=[1, 1, 1], | ||
) | ||
base_model_cls = base_model.exclusion_confidence_level()[0] | ||
|
||
correlated_model = spey.get_backend("default_pdf.correlated_background")( | ||
signal_yields=[1, 1, 1], | ||
background_yields=[2, 1, 3], | ||
data=[2, 2, 2], | ||
covariance_matrix=np.diag([1, 1, 1]), | ||
) | ||
correlated_model_cls = correlated_model.exclusion_confidence_level()[0] | ||
|
||
assert np.isclose( | ||
correlated_model_cls, base_model_cls | ||
), "Correlated model is not same as base model" | ||
|
||
third_moment_model = spey.get_backend("default_pdf.third_moment_expansion")( | ||
signal_yields=[1, 1, 1], | ||
background_yields=[2, 1, 3], | ||
data=[2, 2, 2], | ||
covariance_matrix=np.diag([1, 1, 1]), | ||
third_moment=[0.0, 0.0, 0.0], | ||
) | ||
third_moment_model_cls = third_moment_model.exclusion_confidence_level()[0] | ||
|
||
assert np.isclose( | ||
third_moment_model_cls, base_model_cls | ||
), "third moment model is not same as base model" | ||
|
||
eff_sigma_model = spey.get_backend("default_pdf.effective_sigma")( | ||
signal_yields=[1, 1, 1], | ||
background_yields=[2, 1, 3], | ||
data=[2, 2, 2], | ||
correlation_matrix=covariance_to_correlation(np.diag([1, 1, 1])), | ||
absolute_uncertainty_envelops=[(1.0, 1.0), (1.0, 1.0), (1.0, 1.0)], | ||
) | ||
eff_sigma_model_cls = eff_sigma_model.exclusion_confidence_level()[0] | ||
|
||
assert np.isclose( | ||
eff_sigma_model_cls, base_model_cls | ||
), "effective sigma model is not same as base model" |