#
Estimating Quantiles

`*d`

`elements, wherep`

is the dimension of the task.pis the number of the requested quantiles.d

#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; }