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

## one question about computing variance using MKL 10.3

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

status = 0
status = 0
status = 0
var = 0.000000

Here is my code:

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;

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

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

status = vsldSSCompute(task, VSL_SS_VARIATION , VSL_SS_METHOD_FAST );

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

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

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

Can someone tell me why? Thanks!!!
3 Replies
Employee
792 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
Beginner
792 Views
solved. Thank you so much!
Beginner
792 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