Metropolis的IndexError:只有整数,切片(`:`),省略号(```),numpy.newaxis(`None`)和整数或布尔数组是有效的索引

时间:2018-06-06 15:27:18

标签: python numpy montecarlo

我正在尝试运行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

干杯

0 个答案:

没有答案