I am trying to implement a roulette wheel selection. I have understood this algorithm:
- Calculate the sum S of all chromosome fitnesses in population
- Generate a random number, r, from interval (0,S)
- Loop through the population and sum fitnesses from 0 till S, this is the partial sum, call it P.
- When the P > S: stop and return the corresponding chromosome.
What I don't understand is how this corresponds to doing this instead: Roulette wheel selection algorithm (the answer with 44 votes). This makes sense to me, but not the one above.