Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add resample_pseudodata flag #2088

Merged
merged 3 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions n3fit/runcards/examples/Basic_runcard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ datacuts:
theory:
theoryid: 708 # database id

resample_negative_pseudodata: True

sampling:
separate_multiplicative: true
parameters: # This defines the parameter dictionary that is passed to the Model Trainer
Expand Down
5 changes: 4 additions & 1 deletion validphys2/src/validphys/pseudodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def make_replica(
sep_mult,
genrep=True,
max_tries=int(1e6),
resample_negative_pseudodata=True,
):
"""Function that takes in a list of :py:class:`validphys.coredata.CommonData`
objects and returns a pseudodata replica accounting for
Expand Down Expand Up @@ -163,6 +164,8 @@ def make_replica(
If after max_tries (default=1e6) no physical configuration is found,
it will raise a :py:class:`ReplicaGenerationError`

resample_negative_pseudodata: bool
When True, replicas that produce negative predictions will be resampled for ``max_tries`` until all points are positive (default: True)
Returns
-------
pseudodata: np.array
Expand Down Expand Up @@ -263,7 +266,7 @@ def make_replica(
# Shifting pseudodata
shifted_pseudodata = (all_pseudodata + shifts) * mult_part
# positivity control
if np.all(shifted_pseudodata[full_mask] >= 0):
if np.all(shifted_pseudodata[full_mask] >= 0) or not resample_negative_pseudodata:
return shifted_pseudodata

dfail = " ".join(i.setname for i in groups_dataset_inputs_loaded_cd_with_cuts)
Expand Down
Loading