<jupyter_start><jupyter_text>flavio tutorial Part 5: Extending flavio  Adding an observable: photon polarization in $B\to K\pi\pi\gamma$$$\lambda_\gamma = \frac{|G_L|^2 - |G_R|^2}{|G_L|^2 + |G_R|^2}$$$$G_L = C_7^\text{eff} + \ldots, \qquad G_L = C_7' + \ldots $$$\ldots$ refer to non-factorizable hadronic contributions - let's ignore them for simplicity Writing a function that takes a `WilsonCoefficients` instance and a dictionary of parameter values as input<jupyter_code>import flavio

def ll_lgamma(wc_obj, par_dict):
    scale = flavio.config['renormalization scale']['bvgamma']
    wc_dict = flavio.physics.bdecays.wilsoncoefficients.wctot_dict(wc_obj, 'bsee', scale, par_dict)
    delta_C7 = flavio.physics.bdecays.matrixelements.delta_C7(
        par=par_dict, wc=wc_dict, q2=0, scale=scale, qiqj='bs')
    a = {}
    GL = abs(wc_dict['C7eff_bs'] + delta_C7)**2
    GR = abs(wc_dict['C7effp_bs'])**2
    return (GL**2 - GR**2) / (GL**2 + GR**2)<jupyter_output><empty_output><jupyter_text>Defining the `Observable` and `Prediction` instances<jupyter_code>obs = 'lambda_gamma'
flavio.classes.Observable(obs)
flavio.classes.Prediction(obs, ll_lgamma);
flavio.sm_prediction('lambda_gamma')
wc = flavio.WilsonCoefficients()
wc.set_initial({'C7p_bs': 0.25}, 4.8)
flavio.np_prediction('lambda_gamma', wc)<jupyter_output><empty_output><jupyter_text>Adding a new parameter<jupyter_code>flavio.classes.Parameter('my_fudge_factor')
flavio.default_parameters.set_constraint('my_fudge_factor', '0 +- 0.2')
flavio.default_parameters.get_central('my_fudge_factor')
[flavio.default_parameters.get_random_all()['my_fudge_factor'] for i in range(5)]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14661879114302812, 'fraction_numerical': 0.017953321364452424, 'mean_word_length': 6.776744186046511, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '1198', 'license': 'MIT', 'n_tokens_mistral': 663, 'n_tokens_neox': 635, 'n_words': 109, 'path': '5 Extending.ipynb', 'repo_name': 'DavidMStraub/flavio-tutorial', 'size': '1671'}