-
Notifications
You must be signed in to change notification settings - Fork 3
Added make_replicas from Validphys #429
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
Changes from 8 commits
c1c30a6
74f90a5
eed39cd
a03ee41
d8cbb48
e898f3d
461cdd9
e647860
8f76e6a
5d771d6
24e59cb
2c4d1c1
f773a53
c9396b5
34f3b0b
16d5cf7
ee289a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,9 @@ | |
| from colibri.export_results import write_exportgrid | ||
| from colibri.core import MCPseudodata | ||
|
|
||
| from validphys.pseudodata import make_replica | ||
| from validphys.n3fit_data import replica_mcseed | ||
|
|
||
| import logging | ||
|
|
||
| log = logging.getLogger(__name__) | ||
|
|
@@ -25,25 +28,35 @@ def mc_pseudodata( | |
| pseudodata_central_covmat_index, | ||
| replica_index, | ||
| trval_seed, | ||
| mcseed, | ||
| shuffle_indices=True, | ||
| positive_pseudodata=False, | ||
| mc_validation_fraction=0.2, | ||
| ): | ||
| """Produces Monte Carlo pseudodata for the replica with index replica_index. | ||
| The pseudodata is returned with a set of training indices, which account for | ||
| a fraction mc_validation_fraction of the data. | ||
| """ | ||
|
|
||
| central_values = pseudodata_central_covmat_index.central_values | ||
| If positive_pseudodata is True, the pseudodata will be resampled until all values | ||
| are positive""" | ||
|
|
||
| central_values = [pseudodata_central_covmat_index.central_values] | ||
| covmat = pseudodata_central_covmat_index.covmat | ||
| all_indices = pseudodata_central_covmat_index.central_values_idx | ||
|
|
||
| # Generate pseudodata according to a multivariate Gaussian centred on | ||
| # central_values and with covariance matrix covmat. | ||
| key = jax.random.PRNGKey(replica_index) | ||
| pseudodata = jax.random.multivariate_normal( | ||
| key, | ||
| central_values, | ||
| covmat, | ||
| seed = replica_mcseed(replica_index, mcseed, genrep=True) | ||
|
|
||
|
Comment on lines
+47
to
48
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does this function do and why do we need it?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is to get the same seed as n3fit. I have added a comment to explain this |
||
| if positive_pseudodata: | ||
| group_positivity_mask = np.ones_like(central_values, dtype=bool) | ||
|
comane marked this conversation as resolved.
|
||
| else: | ||
| group_positivity_mask = None | ||
|
|
||
| pseudodata = jnp.array( | ||
| make_replica( | ||
| central_values, | ||
| seed, | ||
| covmat, | ||
| group_positivity_mask=group_positivity_mask, | ||
| ).squeeze() | ||
| ) | ||
|
|
||
| # Now select a subset of 1 - mc_validation_fraction indices to be the | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment that explains why they need to be a
list?