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

MultiDimFit: add option to change parameter ranges for grid points. #686

Open
wants to merge 1 commit into
base: 102x
Choose a base branch
from

Conversation

riga
Copy link
Contributor

@riga riga commented Aug 27, 2021

Hi,

this PR adds an additional option to MultiDimFit to control the range of parameters for grid points independently from parameter ranges in the initial fit.

The use case is that I would like to scan a parameter in a range that does not include its expected value, say r from 5 to 10. Currently, the scan range is only configurable by setting --setParameterRanges which also affects the range used in the initial fit, leading to deltaNLL values being computed relative to a point other than r=1 (likely r=5).

With the new option, one could do

--algo grid --setParameterRanges r=-20,20 --setParameterRangesForGrid r=5,10 --gridPoints 6 --alignEdges 1

and

--algo grid --setParameterRanges r=-20,20 --setParameterRangesForGrid r=10,15 --gridPoints 6 --alignEdges 1

and end up with consistent deltaNLL and best fit values.

@adewit
Copy link
Collaborator

adewit commented Aug 27, 2021

I don't think I fully understand when the use case would come about - is the idea that you want to stitch multiple such scans together, is it more that you want to have the option to scan additional points in a wider range away from the minimum after you do a first scan, or something else?

In the first two cases, saving the workspace at the best fit, then running the grid scan after loading the snapshot and skipping the initial fit will also give you consistent deltaNLL's wrt the best fit. As a bonus you save repeating the initial fit N times, which can be slow.

@riga
Copy link
Contributor Author

riga commented Aug 27, 2021

is the idea that you want to stitch multiple such scans together, is it more that you want to have the option to scan additional points in a wider range away from the minimum after you do a first scan

Exactly that. For instance, if I perform an initial scan with 20 points from -10 to 10 (no snapshot involved so far) and then decide to increase the density at one of the crossings with dnll2 = 1 in a second scan and stitch them together, I need to make the second range somewhat too large just so that it would cover the expected best fit value.

Snapshots are probably the better option (also performance-wise), but wouldn't this require that the initial scan should have also been using the snapshot in the first place to get consistent deltaNLL's?

(I wasn't sure in the beginning if I should open a PR for that, but after seeing that --setParametersForGrid is already there, I thought I go with it ... )

@nucleosynthesis
Copy link
Contributor

nucleosynthesis commented Aug 27, 2021 via email

@adewit
Copy link
Collaborator

adewit commented Aug 30, 2021

Snapshots are probably the better option (also performance-wise), but wouldn't this require that the initial scan should have also been using the snapshot in the first place to get consistent deltaNLL's?

It's probably better, yes. Assuming that the initial configuration of the initial scan and the fit for the snapshot are identical you would most likely find the same minimum in both cases (you're relying on that with the implementation in this PR too, as you have to redo the initial fit every time. )

@riga
Copy link
Contributor Author

riga commented Aug 30, 2021

It's probably better, yes. Assuming that the initial configuration of the initial scan and the fit for the snapshot are identical you would most likely find the same minimum in both cases (you're relying on that with the implementation in this PR too, as you have to redo the initial fit every time. )

Fully agree 👍

Before using snapshots, I usually set up grid scans for these cases like @nucleosynthesis suggested, but the need to update --gridPoints, the offset of either --firstPoint or --lastPoint as well as the initial parameter range to achieve the desired point density made me think that this additional option could be helpful, especially in 2D. E.g. to scan r within [10, 15] with a step size of 0.25, one would need to run

--algo grid --setParameterRanges r=0.75,15 --gridPoints 58 --alignEdges 1 --firstPoint 37 --lastPoint 57

which would simplify to

--algo grid --setParameterRanges r=-20,20 --setParameterRangesForGrid r=10,15 --gridPoints 21 --alignEdges 1

For 2D or higher, finding the correct --firstPoint / --lastPoint offset is actually not trivial. Here is an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants