Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public double myRandomGenerator(double c, double alpha)
- {
- double u, v, t, s;
- u = Math.PI * (randomGenerator.nextDouble()-0.5);
- if(alpha == 1) //CAUCHY
- {
- t = Math.tan(u);
- return c*t;
- }
- do
- {
- v = -Math.log(randomGenerator.nextDouble());
- } while(v == 0);
- if(alpha == 2) //GAUSSIAN
- {
- t = 2*Math.sin(u)*Math.sqrt(v);
- return c*t;
- }
- //GENERAL CASE
- t = Math.sin(alpha*u) / Math.pow(Math.cos(u), 1/alpha);
- s = Math.pow(Math.cos((1-alpha)*u) / v, (1-alpha)/alpha);
- return c*t*s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement