/* This program helps you make QQ plots, by generating the */ /* quantiles from the desired theoretical distributions. */ /* Written by Carey Williamson for CPSC 531 in November 2017 */ /* Usage: cc -o qq qq.c -lm */ /* qq */ #include #include #include /* use man 3 log for the math functions */ #define GRANULARITY 0.01 #define A 10.0 /* left edge of Uniform distribution */ #define B 80.0 /* right edge of Uniform distribution */ #define P 0.1 /* parameter of Geometric distribution */ #define MU 15.0 /* mean of Exponential distribution */ #define ALPHA 1.0 /* tail index of Pareto distribution */ int main() { int i; float x, value; x = 0.0; while( x <= 1.0 ) { value = A + floor((B-A+1)*x); /* for EquiLikely(A,B) */ value = x; /* for Uniform(0,1) */ value = floor(log(1-x)/log(1-P)); /* for Geometric(P) */ value = A + (B-A)*x; /* for Uniform(A,B) */ value = 1/pow((1-x), 1/ALPHA); /* for Pareto(ALPHA) */ value = -MU*log(1-x); /* for Exponential(MU) */ printf("%f %f\n", value, x); x += GRANULARITY; } }