我正在尝试运行Metropolis算法,但是对于拒绝/接受条件,我一直收到错误。 我的代码如下所示:
for i in range(1, nbSteps):
formerState = trajectory[i-1]
newState = formerState + rw[i]
if newState < 0 :
newState = nbStates - 1
utilityEff = utility * (1 + k * omega * visitedValues)
utilityEff[visitedValues == 0] *= alpha
mu=np.exp(omega * (utilityEff[newState]-utilityEff[formerState]))
最后一行出错:
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
干杯