Я хочу реализовать простой mcm c в python, но, поскольку я новичок в этом языке, у меня есть некоторые ошибки, которые я не могу определить. Может кто-нибудь мне помочь? Заранее спасибо.
import numpy as np
def target(x) :
if x < 0 :
print(0)
else:
print(np.exp(-x))
return
target(1)
target(-1)
x = np.repeat(0,1000)
x[0] = 3
for(i in range(2,1000)
current = x[i-1]
proposal = current + np.random.normal(0,1,1)
A = target(proposal)/target(current)
if np.random.uniform(0,1,1) < A :
x[i] = proposal
else:
x[i] = current
plt.plot(x)