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

Examples with deprecated fits module of flavio #3

Open
bhishmapitamah opened this issue Mar 7, 2020 · 11 comments
Open

Examples with deprecated fits module of flavio #3

bhishmapitamah opened this issue Mar 7, 2020 · 11 comments

Comments

@bhishmapitamah
Copy link

Usage of deprecated module (as mentioned in documentation):

import flavio.statistics.fits

Note that the FastFit class of the flavio.statistics.fits module was deprecated in favour of flavio.statistics.likelihood.FastLikelihood as of flavio v1.6.

Recent installations will have following error:

ImportError                               Traceback (most recent call last)
 in ()
      3 import flavio
      4 import flavio.plots
----> 5 import flavio.statistics.fits
      6 import matplotlib.pyplot as plt
      7 from collections import OrderedDict

ImportError: No module named 'flavio.statistics.fits'

Following ipython examples use the fits module:

FastFit_WilsonCoefficients_C7p.ipynb
FastFit_WilsonCoefficients_CS_CSp.ipynb
FrequentistFit_VubVcb_Profiler.ipynb

They should be replaced with the relevant flavio.statistics.likelihood methods.

@bhishmapitamah bhishmapitamah changed the title Examples using deprecated fits module of flavio Examples with deprecated fits module of flavio Mar 7, 2020
@DavidMStraub
Copy link
Contributor

True, the examples are all outdated.

@bhishmapitamah
Copy link
Author

Can you point out what changes should be make to get these examples working in flavio v2.0.0, as the signature has changed for both FastLikelihood constructor and method log_likelihood.

@bhishmapitamah
Copy link
Author

In the example FastFit_WilsonCoefficients_C7p.ipynb i changed fastfit_obs to

def fastfit_obs(name, obslist):
    return flavio.statistics.likelihood.FastLikelihood(
                name = name,
                observables = obslist
            )

and changed the likelihood functions like global_fastfit.log_likelihood to

par = flavio.default_parameters
par_dict = par.get_central_all()

def ll(x):
    wc_NP.set_initial({ 'C7p_bs': x[0] + 1j * x[1]}, scale=4.8)
    return global_fastfit.log_likelihood(par_dict, wc_NP)

@DavidMStraub can you please tell if these changes are sufficient?

This might not be the best place to ask but I also wanted to know how to add multiple instances of an observable with same bins from different experiments for likelihood as I didn't see any examples with this case.

@DavidMStraub
Copy link
Contributor

Hi,

yes, looks good. The instantiation for wc_NP is missing, but I guess you have it somewhere. Personally, I would nowadays directly use wilson:

from wilson import Wilson
...
def ll(x):
    wc_NP = Wilson({"C7p_bs": ...}, scale=4.8, eft="WET", basis="flavio")
    ...

@bhishmapitamah
Copy link
Author

@DavidMStraub can you please tell how to handle the case of adding multiple instances for some observable with same bins. I see the case with multiple measurements for an observable in you code for paper bkstartmumu, but how to handle the case when even the bins are same for an observable.

@DavidMStraub
Copy link
Contributor

For every bin, all existing measurements will be taken into account automatically. Thus one has to be careful not to double-count. You should also consider using smelli which was developed precisely with the goal to abstract away these subtleties.

@bhishmapitamah
Copy link
Author

I was trying to understand what how flavio takes multiple measurements into account.

For the example given in notebook FastFit_WilsonCoefficients_C7p the number of observables given by global_fastfit.full_measurement_likelihood.get_number_observations() is 9. However global_fastfit.exp_covariance._central_cov[0].shape gives (8, 8) shape.

Does it combine the distributions while calculating χ2 in FastLikelihood?

@DavidMStraub
Copy link
Contributor

As per the doc string, the number of observations is "defined as individual measurements of observables". Apparently, here there is one of the 8 observables that is measured by two experiments.

@bhishmapitamah
Copy link
Author

So it combines the the distributions where it finds more than one measurement for an observable?

@DavidMStraub
Copy link
Contributor

Sure. But it's in the user's responsability to be careful that these measurements are actually independent. For instance, for BR(Bs->mumu), flavio contains a global average as well as the individual measurements, so there is double counting if one doesn't exclude one.

@sambit-1236
Copy link

In the example FastFit_WilsonCoefficients_C7p.ipynb i changed fastfit_obs to

def fastfit_obs(name, obslist):
    return flavio.statistics.likelihood.FastLikelihood(
                name = name,
                observables = obslist
            )

and changed the likelihood functions like global_fastfit.log_likelihood to

par = flavio.default_parameters
par_dict = par.get_central_all()

def ll(x):
    wc_NP.set_initial({ 'C7p_bs': x[0] + 1j * x[1]}, scale=4.8)
    return global_fastfit.log_likelihood(par_dict, wc_NP)

@DavidMStraub can you please tell if these changes are sufficient?

This might not be the best place to ask but I also wanted to know how to add multiple instances of an observable with same bins from different experiments for likelihood as I didn't see any examples with this case.

Can you please share the updated

Usage of deprecated module (as mentioned in documentation):

import flavio.statistics.fits

Note that the FastFit class of the flavio.statistics.fits module was deprecated in favour of flavio.statistics.likelihood.FastLikelihood as of flavio v1.6.

Recent installations will have following error:

ImportError                               Traceback (most recent call last)
 in ()
      3 import flavio
      4 import flavio.plots
----> 5 import flavio.statistics.fits
      6 import matplotlib.pyplot as plt
      7 from collections import OrderedDict

ImportError: No module named 'flavio.statistics.fits'

Following ipython examples use the fits module:

FastFit_WilsonCoefficients_C7p.ipynb FastFit_WilsonCoefficients_CS_CSp.ipynb FrequentistFit_VubVcb_Profiler.ipynb

They should be replaced with the relevant flavio.statistics.likelihood methods.

Can you please share the updated .ipython for these 3 examples? I am new to this package and facing lots of error while trying to modify the outdated examples?

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

No branches or pull requests

3 participants