Fixed and simplified weighted randomness algorithm