Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

VSL questions

Shigeo_Kobayashi
Beginner
322 Views

Hi, I am using MKL 11.0 update 3 on Windows 7,core i7 machine.
1. Invalid correlation matrix ?
 #define N 2
 #define DIM 2
 void Test()
 {
    VSLSSTaskPtr task;     MKL_INT dim = DIM, n=N;
    MKL_INT x_storage=VSL_SS_MATRIX_STORAGE_COLS;
    MKL_INT cov_storage=VSL_SS_MATRIX_STORAGE_FULL,cor_storage=VSL_SS_MATRIX_STORAGE_FULL;
    double x[DIM],mean[DIM], cov[DIM][DIM], cor[DIM][DIM];
    double raw2[DIM], raw3[DIM], raw4[DIM],cen2[DIM], cen3[DIM], cen4[DIM];
    int i, j, errcode;     unsigned MKL_INT64 estimate = 0;
    x[0][0] = 2; x[0][1] = 3;
    x[1][0] = 4; x[1][1] = 2;
    errcode = vsldSSNewTask( &task, &dim, &n, &x_storage, (double*)x, 0, 0 );
    errcode = vsldSSEditMoments( task, mean, raw2, raw3, raw4,cen2, cen3, cen4 );
    errcode = vsldSSEditCovCor( task, mean, (double*)cov, &cov_storage ,(double*)cor, &cor_storage );
    estimate = VSL_SS_MEAN | VSL_SS_2R_MOM | VSL_SS_3R_MOM | VSL_SS_4R_MOM |
               VSL_SS_2C_MOM | VSL_SS_3C_MOM |VSL_SS_4C_MOM |VSL_SS_COV | VSL_SS_COR;
    errcode = vsldSSCompute( task, estimate, VSL_SS_METHOD_FAST );
    printf("\n Computed covariance matrix  Computed correlation matrix\n");
    for(i = 0; i < dim; i++) {
        for(j = 0; j < dim; j++) {
            printf(" %+9lf ", cov);
        }
        printf("            ");
        for(j = 0; j < dim; j++) {
            printf(" %+9lf ", cor);
        }
        printf("\n");
    }
    errcode = vslSSDeleteTask( &task );
 }
 Results of the program above follows:
  Computed covariance matrix  Computed correlation matrix
  +2.000000  -1.000000              +2.000000  -1.000000
  -1.000000  +0.500000              -1.000000  +0.500000
 Why is covariance matrix and correlation matrix the same ?

2.Variance confusing ?
 In documentation, "Mathematical Notation and Definitions" defines  "central moments of the third and the fourth order" and "variance" of freedom n-1.  The central moments of the 2nd order(which is not defined in the manual) is  the variance of freedom n in general. But it can be specified in  vslSSEditMoments  by c2m which actually returns variance of freedom n-1(not the central moments of  the 2nd order).
#After repeating same computation,c2m(only) occasionally become NaN(racing condition?),   but it's not always...

3. In All MKL examples for random numbers(vdrnggaussian.c etc),can DeltaM and DeltaD be negative ?
   Is there any intension or theoretical backbone for not using absolute values ?
   Could someone kindly tell me the meaning of DeltaD which seems to be some expansion but I cannot    derive it...

4. http://software.intel.com/sites/products/documentation/doclib/mkl_sa/11/mklman/index.htm
   vslSSEditSums & vslEditCP go "404 Not Found".

0 Kudos
3 Replies
Andrey_N_Intel
Employee
322 Views

Hi Shigeo, let me answer your questions.

1. I assume your question about correlation matrix is related to its major diagonal. Intel(R) MKL algorithm for computation of correlation  supports progressive estimation, that is the case when data arrive in blocks, and correlation should be computed for whole data array. Update of the correlation matrix estimate for the next block requires available variance estimates. Use of the major matrix diagonal to store current variance estimates is the design decision which is described in "Summary Statistics Application Notes" available at http://software.intel.com/sites/products/documentation/doclib/mkl_sa/11/sslnotes/index.htm (see section "Calculating Multiple Estimates" in "Estimating Raw and Central Moments, Skewness, Excess Kurtosis, Variation, and Variance-Covariance/Correlation Matrix" Chapter)

2. Central moment of the second order (or 2nd central moment) is variance for which we provide unbiased estimate by choosing proper normalizing coefficient (which is n-1, if all observations have weight 1). You can use this estimate to convert it into estimate which relies on normalization n, if for some reasons you need it.

3. DeltaM and DeltaD are used to measure stat distance between sample and theoretical estimates and can, generally, take positive & negative values. So, the examples you mention should apply module operation to those variables before comparison against threshold. We are aware about this issue in the examples and plan to fix it in one of future releases of the library.

4. There was the bug in the documentation which was recently fixed. For this reason, you may see broken links in Intel(R) MKL 11.0.3 Manual.

Please, let me know, if this addresses your questions or you need additional details.

Andrey

 

 

0 Kudos
Shigeo_Kobayashi
Beginner
322 Views

Hi Andrey,
1. I now understand why the diagonal elements are not 1 !!    But It should be described in the reference.

2. 3.  4. OK

Thank you always !

0 Kudos
Andrey_N_Intel
Employee
322 Views

Hi Shigeo,

Yes, it makes sense to provide info about major diagonal of corrrelation matrix in Intel(R) MKL Manual, in addition to the Summary Stats Application Notes.

Andrey

0 Kudos
Reply