fixed random number generator bug

moved the initialization into the trials loop. It worked fine
before, but the subsequent trials would not start from a known
seed preventing reproducing those runs.