Simple example ============== This example is supposed to serve as a quick start to the ModelFitting module of FlavorPy. Import FlavorPy --------------- After installing FlavorPy with :code:`pip install flavorpy`, import the modelfitting module. .. code:: ipython3 # Import the modelfitting module of FlavorPy import flavorpy.modelfitting as mf # We will also need numpy and pandas import numpy as np import pandas as pd Defining mass matrices ---------------------- To define a model of leptons, we start by defining its mass matrices :math:`M_e = \begin{pmatrix} 0.0048\times0.0565 & 0 & 0 \\ 0 & 0.0565 & 0 \\ 0 & 0 & 1\end{pmatrix} \quad` and :math:`\quad M_n = \begin{pmatrix} 1 & v_2 & v_3 \\ v_1 & 1 & v_3 \\ v_1 & v_2 & 1\end{pmatrix}` For this example we have: .. code:: ipython3 # Charged lepton mass matrix def Me(params): v1, v2, v3 = params['v1'], params['v2'], params['v3'] return np.array([[0.0048*0.0565, 0 ,0], [0, 0.0565, 0], [0, 0, 1]]) # Neutrino mass matrix def Mn(params): v1, v2, v3 = params['v1'], params['v2'], params['v3'] return np.array([[1, v2, v3], [v1, 1, v3], [v1, v2, 1]]) Defining parameterspace ----------------------- Next, we define the parameterspace of our model. We therefore construct an empty parameter space and add the parameters to it. When fitting, we will draw random points within this parameter space. .. code:: ipython3 ParamSpace = mf.ParameterSpace() ParamSpace.add_dim(name='v1') ParamSpace.add_dim(name='v2') ParamSpace.add_dim(name='v3') Constructing Model ------------------ Then we can construct the lepton model as follows: .. code:: ipython3 MyModel = mf.FlavorModel(mass_matrix_e=Me, mass_matrix_n=Mn, parameterspace=ParamSpace, ordering='NO') Now we can determine the masses and mixing observables of a given point in parameter space by: .. code:: ipython3 MyModel.get_obs({'v1': 1.5, 'v2': 1.1, 'v3': 1.3}) .. parsed-literal:: {'me/mu': 0.0048, 'mu/mt': 0.0565, 's12^2': 0.9053720503789906, 's13^2': 0.2893377761696659, 's23^2': 0.5280465699834944, 'd/pi': 0.0, 'r': 0.010306101829667999, 'm21^2': 4.9968698643488846e-05, 'm3l^2': 0.0048484576874298696, 'm1': 0.0033969202435270816, 'm2': 0.007842688683377208, 'm3': 0.06971367695488995, 'eta1': 1.0, 'eta2': 1.0, 'J': 0.0, 'Jmax': 0.05585663171203268, 'Sum(m_i)': 0.08095328588179423, 'm_b': 0.03822289118358137, 'm_bb': 0.025548760738177294, 'nscale': 0.019258907884260646} Here, ‘me/mu’ is the mass ratio of electron mass divided by muon mass, ‘sij^2’ refers to the mixing angles :math:`\sin^2(\theta_{ij})`, ‘d/pi’ is the cp violating phase in the PMNS matrix divided by :math:`\pi`, ‘m21^2’ and ‘m3l^2’ and the squared neutrino mass differences, i.e. mij^2 = m_i^2 - m_j^2, ‘r’ is their quotient r = m21^2 / m3l^2, ‘m1’ and ‘m2’ and ‘m3’ are the neutrino masses, ‘eta1’ and ‘eta2’ are the majorana phases, ‘J’ is the Jarskog determinant, ‘m_b’ and ‘m_bb’ are the effective neutrino masses for beta decay and neutrinoless double beta decay, respectively. Fitting model to experimental data ---------------------------------- Let us now fit this model to a specific experimental data set. As a default the NuFit v5.3 for NO with SK data is used. To fit this model we choose for example 3 randomly drawn points in the parameter space and apply minimization algorithms to these points, in order to find a point that matches the experimental data well. Note that by default 4 minimization algorithms are applied consecutively to all 3 random points such that we get 12 points in the end. .. code:: ipython3 pd.set_option('display.max_columns', None) # This pandas setting allows us to see all columns df = MyModel.make_fit(points=5) df .. raw:: html
chisq | chisq_dimless | v1 | v2 | v3 | n_scale | me/mu | mu/mt | s12^2 | s13^2 | s23^2 | d/pi | r | m21^2 | m3l^2 | m1 | m2 | m3 | eta1 | eta2 | J | Jmax | Sum(m_i) | m_b | m_bb | nscale | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 5.651948 | 5.651702 | 5.036863 | -0.528403 | 0.701039 | 1 | 0.0048 | 0.0565 | 0.305000 | 0.022200 | 0.499957 | 1.0 | 0.029596 | 0.000074 | 0.002505 | 0.002326 | 0.008920 | 0.050108 | 0.0 | 1.0 | 4.107236e-18 | 0.033538 | 0.061353 | 0.009208 | 0.005369 | 0.006852 |
1 | 5.651948 | 5.651702 | 5.036863 | -0.528403 | 0.701039 | 1 | 0.0048 | 0.0565 | 0.305000 | 0.022200 | 0.499957 | 1.0 | 0.029596 | 0.000074 | 0.002505 | 0.002326 | 0.008920 | 0.050108 | 0.0 | 1.0 | 4.107236e-18 | 0.033538 | 0.061353 | 0.009208 | 0.005369 | 0.006852 |
2 | 5.651948 | 5.651702 | 5.036863 | -0.528403 | 0.701039 | 1 | 0.0048 | 0.0565 | 0.305000 | 0.022200 | 0.499957 | 1.0 | 0.029596 | 0.000074 | 0.002505 | 0.002326 | 0.008920 | 0.050108 | 0.0 | 1.0 | 4.107236e-18 | 0.033538 | 0.061353 | 0.009208 | 0.005369 | 0.006852 |
3 | 5.651948 | 5.651702 | 5.036863 | -0.528403 | 0.701039 | 1 | 0.0048 | 0.0565 | 0.305000 | 0.022200 | 0.499957 | 1.0 | 0.029596 | 0.000074 | 0.002505 | 0.002326 | 0.008920 | 0.050108 | 0.0 | 1.0 | 4.107236e-18 | 0.033538 | 0.061353 | 0.009208 | 0.005369 | 0.006852 |
4 | 5.655930 | 5.655555 | 5.049672 | -0.534924 | 0.713045 | 1 | 0.0048 | 0.0565 | 0.309623 | 0.022200 | 0.500035 | 1.0 | 0.029592 | 0.000074 | 0.002506 | 0.002402 | 0.008939 | 0.050113 | 0.0 | 1.0 | 4.124460e-18 | 0.033679 | 0.061455 | 0.009246 | 0.005457 | 0.006835 |
5 | 5.655930 | 5.655555 | 5.049672 | -0.534924 | 0.713045 | 1 | 0.0048 | 0.0565 | 0.309623 | 0.022200 | 0.500035 | 1.0 | 0.029592 | 0.000074 | 0.002506 | 0.002402 | 0.008939 | 0.050113 | 0.0 | 1.0 | 4.124460e-18 | 0.033679 | 0.061455 | 0.009246 | 0.005457 | 0.006835 |
6 | 5.655930 | 5.655555 | 5.049672 | -0.534924 | 0.713045 | 1 | 0.0048 | 0.0565 | 0.309623 | 0.022200 | 0.500035 | 1.0 | 0.029592 | 0.000074 | 0.002506 | 0.002402 | 0.008939 | 0.050113 | 0.0 | 1.0 | 4.124460e-18 | 0.033679 | 0.061455 | 0.009246 | 0.005457 | 0.006835 |
7 | 5.657581 | 5.657194 | 5.041598 | -0.533464 | 0.714117 | 1 | 0.0048 | 0.0565 | 0.309623 | 0.022280 | 0.500068 | 1.0 | 0.029592 | 0.000074 | 0.002506 | 0.002413 | 0.008942 | 0.050114 | 0.0 | 1.0 | 4.131556e-18 | 0.033737 | 0.061469 | 0.009260 | 0.005469 | 0.006845 |
8 | 5.657581 | 5.657194 | 5.041598 | -0.533464 | 0.714117 | 1 | 0.0048 | 0.0565 | 0.309623 | 0.022280 | 0.500068 | 1.0 | 0.029592 | 0.000074 | 0.002506 | 0.002413 | 0.008942 | 0.050114 | 0.0 | 1.0 | 4.131556e-18 | 0.033737 | 0.061469 | 0.009260 | 0.005469 | 0.006845 |
9 | 5.657581 | 5.657194 | 5.041598 | -0.533464 | 0.714117 | 1 | 0.0048 | 0.0565 | 0.309623 | 0.022280 | 0.500068 | 1.0 | 0.029592 | 0.000074 | 0.002506 | 0.002413 | 0.008942 | 0.050114 | 0.0 | 1.0 | 4.131556e-18 | 0.033737 | 0.061469 | 0.009260 | 0.005469 | 0.006845 |
10 | 5.657581 | 5.657194 | 5.041598 | -0.533464 | 0.714117 | 1 | 0.0048 | 0.0565 | 0.309623 | 0.022280 | 0.500068 | 1.0 | 0.029592 | 0.000074 | 0.002506 | 0.002413 | 0.008942 | 0.050114 | 0.0 | 1.0 | 4.131556e-18 | 0.033737 | 0.061469 | 0.009260 | 0.005469 | 0.006845 |
11 | 5.658516 | 5.658316 | 5.050711 | -0.535313 | 0.712793 | 1 | 0.0048 | 0.0565 | 0.309623 | 0.022189 | 0.500027 | 1.0 | 0.029604 | 0.000074 | 0.002505 | 0.002400 | 0.008940 | 0.050108 | 0.0 | 1.0 | 4.123487e-18 | 0.033671 | 0.061447 | 0.009243 | 0.005455 | 0.006833 |
12 | 14.019848 | 14.013724 | 5.028969 | 0.702363 | -0.526542 | 1 | 0.0048 | 0.0565 | 0.305000 | 0.022280 | 0.500002 | 0.0 | 0.029570 | 0.000074 | 0.002506 | 0.002339 | 0.008921 | 0.050119 | 0.0 | 0.0 | 0.000000e+00 | 0.033596 | 0.061379 | 0.009223 | 0.005383 | 0.006864 |
13 | 14.019853 | 14.013724 | 5.028969 | 0.702363 | -0.526542 | 1 | 0.0048 | 0.0565 | 0.305000 | 0.022280 | 0.500002 | 0.0 | 0.029570 | 0.000074 | 0.002506 | 0.002339 | 0.008921 | 0.050119 | 0.0 | 0.0 | 0.000000e+00 | 0.033596 | 0.061379 | 0.009223 | 0.005383 | 0.006864 |
14 | 14.019853 | 14.013724 | 5.028969 | 0.702363 | -0.526542 | 1 | 0.0048 | 0.0565 | 0.305000 | 0.022280 | 0.500002 | 0.0 | 0.029570 | 0.000074 | 0.002506 | 0.002339 | 0.008921 | 0.050119 | 0.0 | 0.0 | 0.000000e+00 | 0.033596 | 0.061379 | 0.009223 | 0.005383 | 0.006864 |
15 | 14.019853 | 14.013724 | 5.028969 | 0.702363 | -0.526542 | 1 | 0.0048 | 0.0565 | 0.305000 | 0.022280 | 0.500002 | 0.0 | 0.029570 | 0.000074 | 0.002506 | 0.002339 | 0.008921 | 0.050119 | 0.0 | 0.0 | 0.000000e+00 | 0.033596 | 0.061379 | 0.009223 | 0.005383 | 0.006864 |
16 | 14.020580 | 14.014997 | 5.028979 | 0.702446 | -0.526597 | 1 | 0.0048 | 0.0565 | 0.305033 | 0.022281 | 0.500001 | 0.0 | 0.029571 | 0.000074 | 0.002506 | 0.002340 | 0.008921 | 0.050119 | 0.0 | 0.0 | 0.000000e+00 | 0.033597 | 0.061380 | 0.009224 | 0.005383 | 0.006864 |
17 | 14.021824 | 14.013749 | 5.028994 | 0.702405 | -0.526469 | 1 | 0.0048 | 0.0565 | 0.305000 | 0.022280 | 0.500000 | 0.0 | 0.029565 | 0.000074 | 0.002507 | 0.002339 | 0.008921 | 0.050121 | 0.0 | 0.0 | 0.000000e+00 | 0.033596 | 0.061382 | 0.009223 | 0.005383 | 0.006864 |
18 | 14.021824 | 14.013749 | 5.028994 | 0.702405 | -0.526469 | 1 | 0.0048 | 0.0565 | 0.305000 | 0.022280 | 0.500000 | 0.0 | 0.029565 | 0.000074 | 0.002507 | 0.002339 | 0.008921 | 0.050121 | 0.0 | 0.0 | 0.000000e+00 | 0.033596 | 0.061382 | 0.009223 | 0.005383 | 0.006864 |
19 | 14.022732 | 14.014400 | 5.029001 | 0.702364 | -0.526447 | 1 | 0.0048 | 0.0565 | 0.304985 | 0.022280 | 0.500000 | 0.0 | 0.029565 | 0.000074 | 0.002507 | 0.002339 | 0.008921 | 0.050121 | 0.0 | 0.0 | 0.000000e+00 | 0.033595 | 0.061381 | 0.009223 | 0.005383 | 0.006864 |