function a=softmax(EstQ,tau) % FUNCTION a=softmax(EstQ, tau) % Input: Estimated payoff values in EstQ (size 1 x N, % where N is the number of machines % tau - "temperature": High values- the probs are all % close to equal; Low values, becomes "greedy" % Output: The machine that we should play (a number between 1 and N) if tau==0 fprintf('Error in the SoftMax program-\n'); fprintf('Tau must be greater than zero\n'); a=0; return end Temp=exp(EstQ./tau); S1=sum(Temp); Probs=Temp./S1; %These are the probabilities we’ll use %Select a machine using the probabilities we just computed. x=rand; TotalBins=histc(x,[0,cumsum(Probs)']); a=find(TotalBins==1);