views:

182

answers:

3

I am trying to implement non-uniform probability distribution in genetic algorithm.

In the implementation of genetic program, I have an experiment which has 3 outcomes, where each outcome has different probabilities. Let say, probablity of one outcome is 0.85, other is 0.01 and last one is 0.14?

P.S: i recently came to know that it is called non-uniform distribution of probability. I'm implementing it in Java, can anyone tell the theory behind non-uniform prob. distribution & also any Java packages implementing it.

Feel free to ask me know, if u need any more information on the problem!

Thanks in advance!

+3  A: 

For a simple discrete distribution, you can write a sampler that will return your outcomes with the desired frequency by using the cumulative probabilities.

Random r = new Random();
double v = r.nextDouble();

if (v <= 0.85) { return 0; }
if (v <= 0.86) { return 1; }
return 2;

This will return the numbers 0, 1 and 2 with a probability of 0.85, 0.01 and 0.14.

As far as the theory on non-uniform probability distributions, you can start with this Wikipedia article on probability distributions; take special note of the collapsible sections at the bottom of the page. You will find that there are dozens of non-uniform distribution (both continuous and discrete) with different properties.

Lucas
Hey lucas! Can you please justify ur answer? Not coding but logic stuff!
Reddy
You start with a value from a uniform distribution on [0.0, 1.0) and then slice up the interval into sections that are proportional to your probabilities.
Lucas
@Reddy Did you click on the wiki link provided by Lucas? If you dig through the links you will understand why it works. You could also run the algorithm suggested by Lucas and satisfy yourself that Prob(draw = 0) = 0.85 and so on.
Anon
wonderful guys! Just learnt that random functions are deisgned based on randomized algorithms, whose output is based on uniform probabilistic choices. Didn't realize that! It was intitutive, but tricky. THANKS LUCAS! and also ANON! bye
Reddy
+2  A: 

In your particular case it is better to get a random value in [0; 100) using uniform distribution and then check what range it falls in: [0; 85), [85;99), [99, 100)

nailxx
Reddy
+1  A: 

Based on your description it seems to me that you are talking about fitness proportionate selection (also known as roulette wheel selection).
http://en.wikipedia.org/wiki/Roulette-wheel_selection

I think nailxx' answer is a pretty compact description what you need to do.

see also http://stackoverflow.com/questions/177271/roulette-selection-in-genetic-algorithms
http://stackoverflow.com/questions/298301/roulette-wheel-selection-algorithm

If I'm wrong here are some libraries that you may find useful:
http://www.ee.ucl.ac.uk/~mflanaga/java/Stat.html
http://commons.apache.org/math/apidocs/org/apache/commons/math/random/package-summary.html

Sandor Murakozi