function action = choose(Qs,epsilon)

p = ones(1,length(Qs))*epsilon/(length(Qs)-1); %assign epsilon/(n-1) to all actions
p(find(Qs==max(Qs),1)) = 1-epsilon; %assign 1-epsilon to best action
action = find(rand(1)<cumsum(p),1); %choose according to probabilities p