Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nnpdf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Emanuele Roberto Nocera
nnpdf
Commits
894138a9
Commit
894138a9
authored
3 years ago
by
andreab1997
Browse files
Options
Downloads
Patches
Plain Diff
Added docs
parent
0ce016bf
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!1557
Fix the chi2 computation in the report when there is a thcovmat
,
!1528
Fit with theory covmat with n3fit
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
validphys2/src/validphys/covmats.py
+45
-0
45 additions, 0 deletions
validphys2/src/validphys/covmats.py
validphys2/src/validphys/pseudodata.py
+11
-1
11 additions, 1 deletion
validphys2/src/validphys/pseudodata.py
with
56 additions
and
1 deletion
validphys2/src/validphys/covmats.py
+
45
−
0
View file @
894138a9
...
...
@@ -384,6 +384,13 @@ def dataset_inputs_sampling_covmat(dataset_inputs_loaded_cd_with_cuts,
use_t0_sampling
,
separate_multiplicative
,
):
"""
Function to compute the total covmat to be used to generate replicas by make_replica.
Depending on the theory_covmat_flag value, the theory covmat will be added to the
experimental covmat or not. With the use_t0_sampling flag it is possible to choose
if using the t0 prescription in the covmat computation. In order to compute the covmat
only using the additive errors, you can set separate_multiplicative to True.
"""
covmat
=
generate_exp_covmat
(
dataset_inputs_loaded_cd_with_cuts
,
data_input
,
use_weights_in_covmat
,
norm_threshold
,
dataset_inputs_t0_predictions
if
use_t0_sampling
is
True
else
None
,
separate_multiplicative
)
if
theory_covmat_flag
and
use_thcovmat_in_sampling
:
covmat
+=
loaded_theory_covmat
...
...
@@ -402,12 +409,50 @@ def dataset_inputs_t0_total_covmat(dataset_inputs_loaded_cd_with_cuts,
use_t0_fitting
,
only_add
=
False
,
):
"""
Function to compute the total covmat to be used for the chi2 by fitting_data_dict.
Depending on the theory_covmat_flag value, the theory covmat will be added to the
experimental covmat or not. With the use_t0_fitting flag it is possible to choose
if using the t0 prescription in the covmat computation. In order to compute the covmat
only using the additive errors, you can set only_add to True.
"""
covmat
=
generate_exp_covmat
(
dataset_inputs_loaded_cd_with_cuts
,
data_input
,
use_weights_in_covmat
,
norm_threshold
,
dataset_inputs_t0_predictions
if
use_t0_fitting
is
True
else
None
,
only_add
)
if
theory_covmat_flag
and
use_thcovmat_in_fitting
:
covmat
+=
loaded_theory_covmat
return
covmat
def
generate_exp_covmat
(
datasets_input
,
data
,
use_weights
,
norm_thre
,
_list_of_c_values
,
only_add
):
"""
Function to generate the experimental covmat eventually using the t0 prescription. It is also
possible to compute it only with the additive errors.
Parameters
----------
dataset_inputs: list[validphys.coredata.CommonData]
list of CommonData objects.
data: list[validphys.core.DataSetInput]
Settings for each dataset, each element contains the weight for the
current dataset. The elements of the returned covmat for dataset
i and j will be divided by sqrt(weight_i)*sqrt(weight_j), if
``use_weights_in_covmat``. The default weight is 1, which means
the returned covmat will be unmodified.
use_weights: bool
Whether to weight the covmat, True by default.
norm_thre: number
threshold used to regularize covariance matrix
_list_of_c_values: None, list[np.array]
list of 1-D arrays which contain alternative central values which are
combined with the multiplicative errors to calculate their absolute
contribution. By default this is None and the experimental central
values are used.
only_add: bool
specifies whether to use only the additive errors to compute the covmat
Returns
-------
: np.array
experimental covariance matrix
"""
return
dataset_inputs_covmat_from_systematics
(
datasets_input
,
data
,
...
...
This diff is collapsed.
Click to expand it.
validphys2/src/validphys/pseudodata.py
+
11
−
1
View file @
894138a9
...
...
@@ -116,10 +116,20 @@ def make_replica(groups_dataset_inputs_loaded_cd_with_cuts, replica_mcseed, dat
List of CommonData objects which stores information about systematic errors,
their treatment and description, for each dataset.
seed: int, None
replica_mc
seed: int, None
Seed used to initialise the numpy random number generator. If ``None`` then a random seed is
allocated using the default numpy behaviour.
dataset_inputs_sampling_covmat: np.array
Full covmat to be used. It can be either only experimental or also theoretical.
separate_multiplicative: bool
Specifies whether computing the shifts with the full covmat or separating multiplicative
errors (in the latter case remember to generate the covmat coherently)
genrep: bool
Specifies whether computing replicas or not
Returns
-------
pseudodata: np.array
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment