Here is my question:

I want to simulate a random variable using cauchy distribution with C language. Scale and position must be setted manually.

I fuond the GSL library wich contain the function: gsl_ran_cauchy (const gsl_rng * r, double a)

the problem that i can't unsterstand how to fix the position and the scale and there is not a lot of documentation about that.


  • $\begingroup$ Welcome on Math.SE! Although this is also math question you might get more help on stackoverflow. $\endgroup$ – quapka Nov 28 '14 at 10:36

As demontstrated in the examples page of the documentation, in order to use the function gsl_ran_cauchy (const gsl_rng * r, double a) you must first initialise the random number generation, like this (for example)

const gsl_rng_type * T;
gsl_rng * r;


T = gsl_rng_default;
r = gsl_rng_alloc (T);

and then, as you can see in the documentation you can simply generate a random cauchy variable with scale a by calling the function like this:

gsl_ran_cauchy (const gsl_rng * r, double a)

I don't understand what you mean by "position". If you simply mean the mean, or equivalently the starting point of your random walk, you can simply say

my_ran = mean + gsl_ran_cauchy (const gsl_rng * r, double a)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.