Community
cancel
Showing results for 
Search instead for 
Did you mean: 
frank_ctx
Beginner
80 Views

one question about computing variance using MKL 10.3

Hi, here is my simple test code for calculating variance. But it reports

status = 0
status = 0
status = -4006 (BAD_MEAN_ADDR ???)
status = 0
var = 0.000000

Here is my code:


VSLSSTaskPtr task;
double x[9] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
double v = 0.0;
int indices[1] = {1};
MKL_INT p, n, xstorage;

int status;

p = 1;
n = 9;
xstorage = VSL_SS_MATRIX_STORAGE_ROWS;

/* create task */
status = vsldSSNewTask( &task, &p, &n, &xstorage, x, 0, indices);

myprint("status = %d\\n", status);

status = vsldSSEditTask( task, VSL_SS_ED_VARIATION, &v );

myprint("status = %d\\n", status);

status = vsldSSCompute(task, VSL_SS_VARIATION , VSL_SS_METHOD_FAST );

myprint("status = %d\\n", status);

status = vslSSDeleteTask( &task );

myprint("status = %d\\n", status);

myprint("var = %f\\n", v);


Can someone tell me why? Thanks!!!
0 Kudos
3 Replies
Andrey_N_Intel
Employee
80 Views

Hi Frank,
Thanks for the question and the short test case.

As a first note, can you please clarify which estimate you would like to compute, variation coefficientVC=Sigma/E, where Sigma is standard deviation, andE - Expectation (Mean), or variance Sigma^2 = E(X-E(X))^2, E(X) - is expectation of random variable X?

Variation coefficient is defined by mean and standard deviation,square root ofsecond central moment.Computation of i-th central momentuses raw (algebraic) moments up to i-th order. In case of VC estimates, the library will compute mean and the second raw moment.For this reason youneed to allocate the buffersfor those estimates and make them available to the libraryby using Task Editor [d|s]SSEditTask. Size ofeach bufferis defined by dimension of task p (which equal to 1 in your case).

The additional details describing the requirement of buffer allocation for intermediate estimatesare available in Section 3.1.1 of Summary StatsApplication Notes, http://software.intel.com/sites/products/documentation/hpc/mkl/sslnotes/sslnotes.pdf

Can you please let me know if the issue is resolvedwith the allocation of the memory?
Also, feel free to ask more questions on Statistical Component of Intel MKL, and we will gladly help.

Best,
Andrey
frank_ctx
Beginner
80 Views

solved. Thank you so much!
SDyul
Beginner
80 Views

Please update the documentation how variation is computed.

Looks confusing.

There is a variance and there is a standard deviation.

This quantity variation what is it used for?

I could not find any definition for it.

 

All the best

Reply