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

big difference of kurt between float and double

rolandsun
Beginner
600 Views

I test computing kurtosis by MKL  with float and double , and get strange result as following , why kurt of float and double have such big difference ?

 

 

double skew -3.2811 ,kurt 9.3626 ,mean 32.29 ,r2m 1042.57,r3m 33668.46 ,r4m 1087393.04
float skew -3.3029 ,kurt 5.7297 ,mean 32.29 ,r2m 1042.57,r3m 33668.46 ,r4m 1087393.00

 

#define DIM 1
#define N  16
void test_mkl_skew_double()
{
        VSLSSTaskPtr task;
        double x[N]= {32.368824, 32.3732567, 32.3706436, 32.3741646, 32.3736801, 32.3755112, 32.3742905, 32.3735313, 32.3738403, 30.9899216, 32.3761978, 32.3737259, 32.3755112, 32.3710899, 32.3742638, 32.3742638};
        double mean=0,skew=0,kurt={0},vari=0;
        MKL_INT p,n,xst;
        int status;
        p=DIM;
        n=N;
        xst=VSL_SS_MATRIX_STORAGE_ROWS;
        status = vsldSSNewTask( &task, &p, &n, &xst, x, 0, 0 );
        double rm[8]={-1};
        status=vsldSSEditMoments(task,&rm[0],&rm[1],&rm[2],&rm[3],&rm[4],&rm[6],&rm[5]);
        status = vsldSSEditTask( task, VSL_SS_ED_SKEWNESS, &skew );
        status = vsldSSEditTask( task, VSL_SS_ED_KURTOSIS, &kurt );
        MKL_UINT64 mask = VSL_SS_MEAN | VSL_SS_KURTOSIS | VSL_SS_SKEWNESS | VSL_SS_2R_MOM | VSL_SS_3R_MOM | VSL_SS_4R_MOM | VSL_SS_2C_MOM | VSL_SS_3C_MOM | VSL_SS_4C_MOM  ;
        status = vsldSSCompute(task, mask, VSL_SS_METHOD_FAST );
        status = vslSSDeleteTask( &task );
        printf ("double skew %.4f ,kurt %.4f ,mean %.2f ,r2m %.2f,r3m %.2f ,r4m %.2f\n",skew,kurt,rm[0],rm[1],rm[2],rm[3]);
}
void test_mkl_skew_float()
{
        VSLSSTaskPtr task;
        float x[N]= {32.368824, 32.3732567, 32.3706436, 32.3741646, 32.3736801, 32.3755112, 32.3742905, 32.3735313, 32.3738403, 30.9899216, 32.3761978, 32.3737259, 32.3755112, 32.3710899, 32.3742638, 32.3742638};
        float mean=0,skew=0,kurt={0},vari=0;
        MKL_INT p,n,xst;
        int status;
        p=DIM;
        n=N;
        xst=VSL_SS_MATRIX_STORAGE_ROWS;
        status = vslsSSNewTask( &task, &p, &n, &xst, x, 0, 0 );
        float rm[8]={-1};
        status=vslsSSEditMoments(task,&rm[0],&rm[1],&rm[2],&rm[3],&rm[4],&rm[6],&rm[5]);
        status = vslsSSEditTask( task, VSL_SS_ED_SKEWNESS, &skew );
        status = vslsSSEditTask( task, VSL_SS_ED_KURTOSIS, &kurt );
        MKL_UINT64 mask = VSL_SS_MEAN | VSL_SS_KURTOSIS | VSL_SS_SKEWNESS | VSL_SS_2R_MOM | VSL_SS_3R_MOM | VSL_SS_4R_MOM | VSL_SS_2C_MOM | VSL_SS_3C_MOM | VSL_SS_4C_MOM  ;
        status = vslsSSCompute(task, mask, VSL_SS_METHOD_FAST );
        status = vslSSDeleteTask( &task );
        printf ("float skew %.4f ,kurt %.4f ,mean %.2f ,r2m %.2f,r3m %.2f ,r4m %.2f\n",skew,kurt,rm[0],rm[1],rm[2],rm[3]);
}
0 Kudos
1 Solution
VidyalathaB_Intel
Moderator
573 Views

Hi Roland,

 

The issue raised by you is reproducible with VSL_SS_METHOD_FAST method parameter.

 

Meanwhile could you please try changing the method parameter to the function vslSSCompute as shown below?

 

 

//kurtosis of double datatype
status = vsldSSCompute(task, mask, VSL_SS_METHOD_1PASS);
//kurtosis of float datatype
status = vslsSSCompute(task, mask, VSL_SS_METHOD_1PASS );

 

 

We checked it from our end and could see that the results are same for both float and double kurtosis.

 

Reference Link:https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/statistical-functions/summary-statistics/summary-statistics-task-computation-routines.html#summary-statistics-task-computation-routines_TBL10-29

 

Please refer to the below screenshot and do let us know if it helps in resolving the issue.

VidyalathaB_Intel_0-1646392668170.png

 

 

Regards,

Vidya.

 

 

View solution in original post

3 Replies
VidyalathaB_Intel
Moderator
574 Views

Hi Roland,

 

The issue raised by you is reproducible with VSL_SS_METHOD_FAST method parameter.

 

Meanwhile could you please try changing the method parameter to the function vslSSCompute as shown below?

 

 

//kurtosis of double datatype
status = vsldSSCompute(task, mask, VSL_SS_METHOD_1PASS);
//kurtosis of float datatype
status = vslsSSCompute(task, mask, VSL_SS_METHOD_1PASS );

 

 

We checked it from our end and could see that the results are same for both float and double kurtosis.

 

Reference Link:https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/statistical-functions/summary-statistics/summary-statistics-task-computation-routines.html#summary-statistics-task-computation-routines_TBL10-29

 

Please refer to the below screenshot and do let us know if it helps in resolving the issue.

VidyalathaB_Intel_0-1646392668170.png

 

 

Regards,

Vidya.

 

 

rolandsun
Beginner
487 Views
0 Kudos
Ruqiu_C_Intel
Moderator
402 Views

Thank you for reaching us. This issue is closing and we will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only. 


0 Kudos
Reply