I have a problem where I want to generate a set of random integer values between 1 and 5 inclusive using a probability distribution.
Poisson and Inverse Gamma are t
I would just produce uniformly distributed random numbers then pass them into the distribution function you want, so if the distribution function was x^2
import java.util.ArrayList;
import java.util.Random;
public class Test{
public static void main(String args[]){
Test t=new Test();
}
public Test(){
Random rnd=new Random();
ArrayList data=new ArrayList();
for(int i=0;i<1000;i++){
data.add(useFunction(rnd.nextDouble()));
}
}
public double useFunction(double in){
return in*in;
}
}