Description
This example demonstrates how to generate percentiles for a random vector. Keywords: rank, percentiles
Category : GAMS Data Utilities library
Main file : rank02.gms includes : rank02.gms
$title Generate percentiles for a random vector (rank02,SEQ=136)
$onText
This example demonstrates how to generate percentiles for a random vector.
Keywords: rank, percentiles
$offText
Set
i 'Set on which random data are defined' / a, b, d, c, e /
p 'Percentiles (all of them)' / 0*100 /;
Parameter x(i) 'Random data to be sorted';
* Generate the random data on set i:
x(i) = uniform(0,1);
display x;
Parameter
r(i) 'Rank values'
pct(*) 'Percentiles to be computed' / 20 20.0, median 50.0, 75 75.0 /;
* Generate ranks and compute the specified percentiles (Note that
* the rank array, r, is required, even if the values are not used.)
$libInclude rank x i r pct
* Display three percentiles:
display pct;
pct(p) = (ord(p) - 1) + eps;
pct("median") = 0;
display pct;
$libInclude rank x i r pct
display pct;
* Plot the results using GNUPLOT:
Set pl(p) / 20, 40, 60, 80, 100 /;
$setGlobal domain p
$setGlobal labels pl
$if exist "%gams.sysdir%inclib/plot.gms" $libInclude plot pct