Skip to content
Snippets Groups Projects

Action to compute a chi2 taking into account pdf errors and plot the chi2 per-replica

Merged Emanuele Roberto Nocera requested to merge vpaction-add-pdferr-chi2-table into master

Created by: scarlehoff

Chi2 with pdf errors.

I started working on the history-test project for n3fit I talked about in Varenna. In order to have this I want to have something able to compute \chi^{2} adding a covariance matrix which gives information about the PDF error. i.e.,

equation

Where C is the normal covariance matrix and P is the one due to the PDF errors.

This is the quickest solution I could think of to get the table I wanted, i.e., the result is final, the code will not be (I just saw I left some debug code in in the commit)

Plot chi2 per replica.

There is currently an action to compute the chi2 per replica per experiment, but not a corresponding action to plot it. I will also commit an action to plot this as I am interested in having this in the reports.

Example:

This is an example runcard that will produce a

fit: 181101-001-sc
pdf: 181101-001-sc

use_cuts: internal
q2min: 3.49
w2min: 12.5
theoryid: 53

actions_:
    - perexperiment_pdferr_chi2_table

theory:
    from_: fit

experiments:
  - experiment: NMCPD
    datasets:
      - { dataset: NMCPD, frac: 0.5 }

Note: i could not find this done anywhere in vp, if it has been done let me know¡!

Merge request reports

Merged by avatar (Apr 8, 2025 2:48am UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
509 615 )
510 616 return covmat
511 617
618 def pdferr_plus_experiment_covmat(experiment, pdf, experiment_covmat):
619 """Like `pdferr_plus_data_covmat` except for an experiment"""
620 # do checks get performed here?
  • Emanuele Roberto Nocera
  • Created by: Zaharid

    Yes indeed. But please call the flag something else.

  • Created by: wilsonmr

    one day I will add a runcard flag that you don't ask me to change :laughing: I will sort it out in a bit

    @scarlehoff what do you think of this? Does it make some sense now that it's explicit?

  • Created by: siranipour

    Yes indeed. But please call the flag something else.

    Forgive the interjection, but what do we mean by runcard flag?

  • Created by: wilsonmr

    Forgive the interjection, but what do we mean by runcard flag?

    you're allowed to ask questions!

    well in the production rule I added to config.py, the input variable - currently called use_pdferr is something which you can add as a 'flag' to the runcard like use_pdferr: True which signals that you want a certain behaviour, it's nothing more than that. I think flags are generally binary, e.g a boolean but I guess they don't have to be

  • Created by: siranipour

    Forgive the interjection, but what do we mean by runcard flag?

    you're allowed to ask questions!

    well in the production rule I added to config.py, the input variable - currently called use_pdferr is something which you can add as a 'flag' to the runcard like use_pdferr: True which signals that you want a certain behaviour, it's nothing more than that. I think flags are generally binary, e.g a boolean but I guess they don't have to be

    Gotchya, thanks. Is the parsing of the function arguments (the flags) handled by reportengine automagically?

  • Created by: Zaharid

    @siranipour The way it works is that an action (which can be a production rule) asks for dependencies, which is currently done mostly looking at the function arguments. If the runcard (or more precisely, the current relevant namespace) has the corresponding key, its value is taken as the value of the dependency. The value might first be piped though a parse_ method, if it exists.

    So yes, automagically.

  • Created by: siranipour

    @siranipour The way it works is that an action (which can be a production rule) asks for dependencies, which is currently done mostly looking at the function arguments. If the runcard (or more precisely, the current relevant namespace) has the corresponding key, its value is taken as the value of the dependency. The value might first be piped though a parse_ method, if it exists.

    So yes, automagically.

    Very neat! That's kinda what I had in mind. reportengine is pretty awesome

  • Created by: wilsonmr

    possibly we should discuss this elsewhere, and Zahari can probably explain this better but when we run validphys we want to perform some actions - in this case we want to run some action that creates a table of chi2 by experiment. Now this action has a bunch of dependencies which are either other actions like abs_chi2_data_experiment or resources like experiments the seperation between these is kind of abstract but I'm referring to approximately things defined in core.py as a resource

    Now once you've resolved all of this you are left with a bunch of resources which are parsed from the runcard (or take some default values) with the parse_* functions - these go from a string specifying the resource you want: pdf: NNPDF31_nlo_as_0118 to the object pdf: PDF where now PDF is an instance of the class defined in core.py and can be used in actions which require PDF objects.

    Some things which I would consider runcard flags like use_t0 do in fact have a parse_ function. Others such as this one do not and so at the end any 'resource' which doesn't have an action or a parse_* function or production rule or a default is assumed to be specified in the namespace that requires it (so specified in the runcard)

    I think all of this is covered and explained better in this talk:

    https://vp.nnpdf.science/k6UvYJnETzW3NsjihUnMgw==/talk.pdf

    PS: oh I just looked up and realised Zahari answered your question in a short paragraph but I'll still hit 'comment' because it's less effort than hitting backspace a bunch of times

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading