If you have a loop like for(i=1 to C) if(x[i]>best}{ best=x[i]; ibest=i; }
then you will find the maximum x[] but breaking ties always by choosing the maximum index i. However, you can pre-prepare a random permutation of {1,2,...,C} as follows for(i=1 to C) p[i]=i; for(i=C down to 2){ t=random integer from 1 to i; swap(p[i], p[t]); } and then the original loop can be replaced by for(i=1 to C) if(x[p[i]]>best}{ best=x[p[i]]; ibest=p[i]; } in which case all ties are broken randomly. It is probably best to regenerate a new random permutation p[] every time you do stuff, don't re-use old p[]. This kind of thing is very important in many kinds of election simulations because biased-tie-breaking in many simulations can completely throw your statistics off. If in the present election you run STV (say) then you really should run STV many times with different random numbers each run, and report the statistics of the results. -- Warren D. Smith http://RangeVoting.org <-- add your endorsement (by clicking "endorse" as 1st step) and math.temple.edu/~wds/homepage/works.html ---- Election-Methods mailing list - see http://electorama.com/em for list info