Visible to Intel only — GUID: GUID-8C653AAC-59C9-45A4-8E14-D6F61742CE8F

Visible to Intel only — GUID: GUID-8C653AAC-59C9-45A4-8E14-D6F61742CE8F

## Estimating Quantiles

You can use the Summary Statistics routines to compute quantiles for a matrix of observations. The computation routine can calculate more than one quantile at a time. Quantile orders belonging to the interval (0,1) are packed and passed into the library as an array. You should allocate enough memory to hold results of the calculations. The size of the array should provide storage for at least `d`*`p` elements, where

`p`is the dimension of the task.`d`is the number of the requested quantiles.

Quantiles in the array are packed component by component, starting from the first component of the random vector and following the quantile orders.

See the Mathematical Notation and Definitions chapter in the Summary Statistics section of [MKLMan] for additional information.

The example below illustrates quantile-related calculations:

#include "mkl_vsl.h" #include <stdio.h> #define DIM 3 /* dimension of the task */ #define N 1000 /* number of observations */ #define M 100 /* number of quantiles to compute */ int main() { int i, status; VSLSSTaskPtr task; float x[DIM][N]; /* matrix of observations */ float order_stats[N]; /* matrix to store order statistics */ float q_order[M], quants[M]; MKL_INT q_order_n; MKL_INT p, n, xstorage, ostatstorage; unsigned long long estimates; int indices[DIM]={1,0,0}; /* the first vector component is processed */ /* Parameters of the task and initialization */ p = DIM; n = N; q_order_n = M; xstorage = VSL_SS_MATRIX_STORAGE_ROWS; ostatstorage = VSL_SS_MATRIX_STORAGE_ROWS; /* Calculate percentiles */ for ( i = 0; i < M; i++ ) q_order[i] = (float)i / (float)M; /* Create a task */ status = vslsSSNewTask( &task, &p, &n, &xstorage, (float*)x, 0, indices ); /* Initialize the task parameters */ status = vslsSSEditQuantiles( task, &q_order_n, q_order, quants, order_stats, &ostatstorage ); /* Compute the percentiles and order statistics */ estimates = VSL_SS_QUANTS|VSL_SS_ORDER_STATS; status = vslsSSCompute( task, estimates, VSL_SS_METHOD_FAST ); /* Deallocate the task resources */ status = vslSSDeleteTask( &task ); return 0; }

**Parent topic:**Algorithms and Interfaces in Summary Statistics