Visible to Intel only — GUID: GUID-AC75C2EC-D341-4900-B00C-A7D2C607CA8F
Visible to Intel only — GUID: GUID-AC75C2EC-D341-4900-B00C-A7D2C607CA8F
Summary Statistics Usage Examples
The following examples show various standard operations with Summary Statistics routines.
Calculating Fixed Estimates for Fixed Data
The example shows recurrent calculation of the same estimates with a given set of variables for the complete life cycle of the task in the case of a variance-covariance matrix. The set of vector components to process remains unchanged, and the data comes in blocks. Before you call the vslSSCompute routine, initialize pointers to arrays for mean and covariance and set buffers.
…. double w[2]; double indices[DIM] = {1, 0, 1}; /* calculating mean for 1st and 3d random vector components */ /* Initialize parameters of the task */ p = DIM; n = N; xstorage = VSL_SS_MATRIX_STORAGE_ROWS; covstorage = VSL_SS_MATRIX_STORAGE_FULL; w[0] = 0.0; w[1] = 0.0; for ( i = 0; i < p; i++ ) mean[i] = 0.0; for ( i = 0; i < p*p; i++ ) cov[i] = 0.0; status = vsldSSNewTask( &task, &p, &n, &xstorage, x, 0, indices ); status = vsldSSEditTask ( task, VSL_SS_ED_ACCUM_WEIGHT, w ); status = vsldSSEditCovCor( task, mean, cov, &covstorage, 0, 0 );
You can process data arrays that come in blocks as follows:
for ( i = 0; i < num_of_blocks; i++ ) { status = vsldSSCompute( task, VSL_SS_COV, VSL_SS_METHOD_FAST ); /* Read new data block into array x */ } …
Calculating Different Estimates for Variable Data
The context of your calculation may change in the process of data analysis. The example below shows the data that comes in two blocks. You need to estimate a covariance matrix for the complete data, and the third central moment for the second block of the data using the weights that were accumulated for the previous datasets. The second block of the data is stored in another array. You can proceed as follows:
/* Set parameters for the task */ p = DIM; n = N; xstorage = VSL_SS_MATRIX_STORAGE_ROWS; covstorage = VSL_SS_MATRIX_STORAGE_FULL; w[0] = 0.0; w[1] = 0.0; for ( i = 0; i < p; i++ ) mean[i] = 0.0; for ( i = 0; i < p*p; i++ ) cov[i] = 0.0; /* Create task */ status = vsldSSNewTask( &task, &p, &n, &xstorage, x1, 0, indices ); /* Initialize the task parameters */ status = vsldSSEditTask( task, VSL_SS_ED_ACCUM_WEIGHT, w ); status = vsldSSEditCovCor( task, mean, cov, &covstorage, 0, 0 ); /* Calculate covariance for the x1 data */ status = vsldSSCompute( task, VSL_SS_COV, VSL_SS_METHOD_FAST ); /* Initialize array of the 3d central moments and pass the pointer to the task */ for ( i = 0; i < p; i++ ) c3_m[i] = 0.0; /* Modify task context */ status = vsldSSEditTask( task, VSL_SS_ED_3C_MOM, c3_m ); status = vsldSSEditTask( task, VSL_SS_ED_OBSERV, x2 ); /* Calculate covariance for the x1 & x2 data block */ /* Calculate the 3d central moment for the 2nd data block using earlier accumulated weight */ status = vsldSSCompute(task, VSL_SS_COV|VSL_SS_3C_MOM, VSL_SS_METHOD_FAST ); … status = vslSSDeleteTask( &task );
Similarly, you can modify indices of the variables to be processed for the next data block.