2) Bounded Pareto pdf is (k is lower bound, p is upper bound):

- pdf is f(x) = ((a*k^a) / (1 - (k/p)^a))*x^(-a-1)

double bpareto(double a, double k, double p)

{

double z; // Uniform random number from 0 to 1

double pb_rv; // Computed bounded Pareto value to be returned

// Pull a uniform random number (0.0 < z < 1.0)

do

{

z = rand_val(0);

}

while ((z == 0.0) || (z == 1.0));

// Generate the bounded Pareto rv using the inversion method

pb_rv = -(z * pow(p,a) - z * pow(k, a) - pow(p,a)) / (pow(p, a) * pow(k,a));

pb_rv = pow(pb_rv, (-1.0 / a));

return(pb_rv);

}