TMinuit 'NDIM' of external error matrix

Hello,

I am trying to minimize my -log(L) function using TMinuit. The function is only 4 dimentional, that is it takes four variables. So at the end I would expect a 4 dimensional covariance/error matrix. But somehow it returns a 25 dimensional one. NDIM = 25. I am not sure where this is coming from. Change in number of variables doesn’t seem to affect that 25. Here is my sample code that I use to initialize TMinuit and minimize the function and measure the parameters.

int NPAR = 18;
Int_t ierflg = 0;

TMinuit *gMinuit = new TMinuit(NPAR);  //initialize TMinuit with a maximum of NPAR params
gMinuit->SetFCN(myFcn);

char varName[100];
for (int i = 0; i < NPAR; i++)
                {
                sprintf(varName, "X%d", i);
                gMinuit->mnparm(i, varName, 2, 0.1, 0, 0, ierflg);
               }

if (ierflg)
                {
                Printf(" UNABLE TO DEFINE PARAMETER NO.");
                return ierflg;
                }

gMinuit->mncomd("migrad",ierflg);

This is my FCN function, I think it is defined correctly.

void myFcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *x, Int_t iflag)

here is the output:

MIGRAD MINIMIZATION HAS CONVERGED.
 FCN=2616.79 FROM MIGRAD    STATUS=CONVERGED    2017 CALLS        2018 TOTAL
                     EDM=3.97686e-08    STRATEGY= 1  ERROR MATRIX UNCERTAINTY   0.0 per cent
  EXT PARAMETER                                   STEP         FIRST
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE
   1  X0          -1.76140e+01   1.37792e+01   5.32812e-02  -6.32717e-07
   2  X1           1.16348e+01   1.94169e+01   3.76145e-04  -8.53027e-06
   3  X2          -1.83817e+01   1.55787e+01  -5.21848e-03  -7.64993e-07
   4  X3          -9.06032e+00   9.42241e+00  -1.33730e-02  -8.53529e-07
   5  X4          -9.70464e+00   1.16159e+01   1.80833e-02  -7.66515e-07
   6  X5          -8.59800e+00   9.00225e+00   3.14895e-02  -7.47883e-07
   7  X6           4.29303e+02   2.00107e+02  -1.14869e-02  -5.32390e-07
   8  X7           1.85451e+01   1.33070e+01  -1.25921e-02  -9.56697e-07
   9  X8          -2.83218e+02   1.33301e+02   1.45032e-02   8.08761e-07
  10  X9           1.04046e+02   4.93710e+01   1.71177e-04  -1.24508e-06
  11  X10          1.03520e+01   1.04600e+01  -2.19823e-02  -8.70221e-07
  12  X11         -5.91687e+00   8.42677e+00  -1.50251e-02  -8.68688e-07
  13  X12         -1.51446e+01   1.31963e+01  -4.04657e-02  -8.46315e-07
  14  X13         -1.10449e+02   5.32507e+01   2.82864e-02  -2.80705e-07
  15  X14         -7.93951e+00   9.21399e+00  -5.18134e-03  -8.40545e-07
  16  X15         -6.04721e+01   2.99379e+01  -2.26707e-02  -6.63335e-07
  17  X16         -8.16296e+00   9.00400e+00   1.74068e-03  -8.34628e-07
  18  X17          1.16590e+01   1.94579e+01   1.84083e-04  -8.63490e-06
 EXTERNAL ERROR MATRIX.    NDIM=  25    NPAR= 18    ERR DEF=1
 ELEMENTS ABOVE DIAGONAL ARE NOT PRINTED.
  1.899e+02
  8.556e-01  3.770e+02
  6.782e+01 -7.828e-01  2.427e+02
  2.349e+01 -2.030e+00  2.954e+01  8.878e+01
  2.882e+01 -1.081e+00 -9.868e+00  1.779e+01  1.349e+02
  2.823e+01  3.017e-01  2.792e+01  1.444e+01  1.604e+01  8.104e+01
 -1.625e+03 -2.573e+00 -1.701e+03 -8.371e+02 -8.946e+02 -7.887e+02  4.004e+04
 -7.988e+01  2.007e-02 -8.347e+01 -4.044e+01 -4.314e+01 -3.864e+01  1.761e+03  1.771e+02
  1.056e+03  2.227e+00  1.098e+03  5.446e+02  5.823e+02  5.118e+02 -2.650e+04 -1.228e+03  1.777e+04
 -3.987e+02 -8.512e-01 -4.161e+02 -2.052e+02 -2.197e+02 -1.934e+02  9.716e+03  4.295e+02 -6.470e+03  2.437e+03
 -4.366e+01 -3.294e+00 -4.451e+01 -2.256e+01 -2.438e+01 -2.115e+01  9.768e+02  4.698e+01 -6.644e+02  2.347e+02  1.094e+02
  1.838e+01 -1.616e+00  1.939e+01  9.447e+00  1.008e+01  8.857e+00 -5.427e+02 -2.721e+01  3.474e+02 -1.332e+02 -1.500e+01
  1.838e+01 -1.616e+00  1.939e+01  9.447e+00  1.008e+01  8.857e+00 -5.427e+02 -2.721e+01  3.474e+02 -1.332e+02 -1.500e+01  7.101e+01
  5.026e+01 -3.465e+00  5.293e+01  2.522e+01  2.736e+01  2.389e+01 -1.404e+03 -6.988e+01  9.095e+02 -3.446e+02 -3.786e+01
  5.026e+01 -3.465e+00  5.293e+01  2.522e+01  2.736e+01  2.389e+01 -1.404e+03 -6.988e+01  9.095e+02 -3.446e+02 -3.786e+01  1.562e+01  1.741e+02
  3.920e+02  1.147e+01  4.093e+02  2.012e+02  2.144e+02  1.885e+02 -1.032e+04 -4.455e+02  6.851e+03 -2.513e+03 -2.819e+02
  3.920e+02  1.147e+01  4.093e+02  2.012e+02  2.144e+02  1.885e+02 -1.032e+04 -4.455e+02  6.851e+03 -2.513e+03 -2.819e+02  1.250e+02  3.327e+02  2.836e+03
  2.541e+01 -1.532e+00  2.704e+01  1.351e+01  1.439e+01  1.262e+01 -7.312e+02 -3.586e+01  4.736e+02 -1.793e+02 -1.983e+01
  2.541e+01 -1.532e+00  2.704e+01  1.351e+01  1.439e+01  1.262e+01 -7.312e+02 -3.586e+01  4.736e+02 -1.793e+02 -1.983e+01  8.146e+00  1.600e+01  1.728e+02  8.490e+01
2.134e+02  4.582e+00  2.232e+02  1.094e+02  1.161e+02  1.025e+02 -5.646e+03 -2.480e+02  3.745e+03 -1.375e+03 -1.523e+02
  2.134e+02  4.582e+00  2.232e+02  1.094e+02  1.161e+02  1.025e+02 -5.646e+03 -2.480e+02  3.745e+03 -1.375e+03 -1.523e+02  6.784e+01  1.828e+02  1.475e+03  9.379e+01  8.963e+02
  2.657e+01 -1.402e+00  2.797e+01  1.374e+01  1.449e+01  1.288e+01 -7.509e+02 -3.699e+01  4.862e+02 -1.842e+02 -2.030e+01
  2.657e+01 -1.402e+00  2.797e+01  1.374e+01  1.449e+01  1.288e+01 -7.509e+02 -3.699e+01  4.862e+02 -1.842e+02 -2.030e+01  8.344e+00  2.270e+01  1.772e+02  1.185e+01  9.684e+01  8.107e+01
  3.963e-02  3.765e+02 -1.228e+00 -1.779e+00 -7.718e-03  2.048e-01 -2.586e+00  1.102e-01  2.134e+00 -8.226e-01 -3.307e+00
  3.963e-02  3.765e+02 -1.228e+00 -1.779e+00 -7.718e-03  2.048e-01 -2.586e+00  1.102e-01  2.134e+00 -8.226e-01 -3.307e+00 -1.657e+00 -3.434e+00  1.195e+01 -1.516e+00  4.270e+00 -1.547e+00  3.786e+02
 PARAMETER  CORRELATION COEFFICIENTS
       NO.  GLOBAL      1      2      3      4      5      6      7      8      9     10     11     12     13     14     15     16
        1  0.88702   1.000  0.003  0.316  0.181  0.180  0.228 -0.589 -0.436  0.575 -0.586 -0.303  0.158  0.276  0.534  0.200  0.517
        2  0.99654   0.003  1.000 -0.003 -0.011 -0.005  0.002 -0.001  0.000  0.001 -0.001 -0.016 -0.010 -0.014  0.011 -0.009  0.008
        3  0.90701   0.316 -0.003  1.000  0.201 -0.055  0.199 -0.546 -0.403  0.529 -0.541 -0.273  0.148  0.257  0.493  0.188  0.478
        4  0.79619   0.181 -0.011  0.201  1.000  0.163  0.170 -0.444 -0.322  0.434 -0.441 -0.229  0.119  0.203  0.401  0.156  0.388
        5  0.84850   0.180 -0.005 -0.055  0.163  1.000  0.153 -0.385 -0.279  0.376 -0.383 -0.201  0.103  0.178  0.347  0.134  0.334
        6  0.78297   0.228  0.002  0.199  0.170  0.153  1.000 -0.438 -0.323  0.427 -0.435 -0.225  0.117  0.201  0.393  0.152  0.380
        7  0.99933  -0.589 -0.001 -0.546 -0.444 -0.385 -0.438  1.000  0.661 -0.994  0.983  0.467 -0.322 -0.532 -0.968 -0.397 -0.942
        8  0.89543  -0.436  0.000 -0.403 -0.322 -0.279 -0.323  0.661  1.000 -0.693  0.654  0.338 -0.243 -0.398 -0.629 -0.292 -0.622
        9  0.99873   0.575  0.001  0.529  0.434  0.376  0.427 -0.994 -0.693  1.000 -0.983 -0.476  0.309  0.517  0.965  0.386  0.938
       10  0.99311  -0.586 -0.001 -0.541 -0.441 -0.383 -0.435  0.983  0.654 -0.983  1.000  0.455 -0.320 -0.529 -0.956 -0.394 -0.930
       11  0.82591  -0.303 -0.016 -0.273 -0.229 -0.201 -0.225  0.467  0.338 -0.476  0.455  1.000 -0.170 -0.274 -0.506 -0.206 -0.486
       12  0.75160   0.158 -0.010  0.148  0.119  0.103  0.117 -0.322 -0.243  0.309 -0.320 -0.170  1.000  0.140  0.279  0.105  0.269
       13  0.87613   0.276 -0.014  0.257  0.203  0.178  0.201 -0.532 -0.398  0.517 -0.529 -0.274  0.140  1.000  0.474  0.132  0.463
       14  0.99198   0.534  0.011  0.493  0.401  0.347  0.393 -0.968 -0.629  0.965 -0.956 -0.506  0.279  0.474  1.000  0.352  0.925
       15  0.78560   0.200 -0.009  0.188  0.156  0.134  0.152 -0.397 -0.292  0.386 -0.394 -0.206  0.105  0.132  0.352  1.000  0.340
       16  0.97851   0.517  0.008  0.478  0.388  0.334  0.380 -0.942 -0.622  0.938 -0.930 -0.486  0.269  0.463  0.925  0.340  1.000
       17  0.78075   0.214 -0.008  0.199  0.162  0.139  0.159 -0.417 -0.309  0.405 -0.414 -0.216  0.110  0.191  0.370  0.143  0.359
                     1.000 -0.009
       18  0.99654   0.000  0.997 -0.004 -0.010 -0.000  0.001 -0.001  0.000  0.001 -0.001 -0.016 -0.010 -0.013  0.012 -0.008  0.007
                    -0.009  1.000

I would really like to figure out the meaning of this 25 dimensional error matrix and how to set the NDIM parameter if that needs to be set by hand.

Thank you,
Irakli

Hi,

What is it 4-dimensional ? In Minuit you minimise a log-likelihood function, which depends on some number of parameters. The parameters are the variable of the function. You have defined a 18 parameters, so your likelihood has 18 dimension and you will get a 18x18 correlation matrix at the end.
The NDIM value that is printed is not really relevant. (the value 25 reflect some max dimension of the matrix, that is allocated at the beginning). the real size of the matrix is given by the NPAR value which is 18.

Best Regards

Lorenzo

Hello,

Thank you for answer. I understand that I have 18 parameters and my correlation matrix will be represent the correlation parameters for 18 parameters. My question was about the covariance matrix which is also printed out and is 25 dimensional.

When I said 4 dimensional I meant that my likelihood function, besides 18 parameters, also depends on 4 variables, hence 4 dimensional function and thus I would expect the covariance matrix 4x4, which would have sigmas^2-s on the diagonal and so on. Since, I am getting 25x25 instead of that I was wondering why and how to get what I want.

Thanks,
Irakli

I think I understand that covariance matrix is related to the parameters, but the question about the dimension remains. How to I get a meaningful covariance matrix, which in the case of 18 parameters would be 18 dimensional and where did 25 come from? Do I have a handle on that NDIM?

Thanks,
Irakli

Hi,

Forget about that NDIM, this is an internal and irrelevant value. What you get as returned matrix is a 18x18 covariance matrix.

Lorenzo

But my COVARIANCE matrix is 25x25. It is my CORRELATION matrix that is 18x18. And if I understand it right, they are different, and I actually need COVARIANCE matrix for my analysis.

Or should I just chop 18x18 from my 25x25 and that will be the right matrix? This sounds wrong to me.

Irakli

Ooooh… I think I understand what you are saying. You are saying that the COVARIANCE matrix actually is 18 dimensional, it is just wrapped in a very weird way so that I think it is not 18x18.

I will test this hypothesis and report back soon.

Thank you.
Irakli