ARMS stands for Adaptive Rejection Metropolis Sampling, and it is the generalization of ARS algorithm.
We can implement this algorithm with the following Julia program:
include("../GenRV/ars.jl")using Main.corears# ARMSfunctionarms(T, yfixed::Array) x =ones(T+1)for t =1:T# generate Ywhiletrueglobal y y =gplus_sample(yfixed) u =rand() u <=exp(h(y)-hplus(y, yfixed)) &&breakend# accept or not v =rand() r =exp(h(y))*phi(x[t], yfixed)/(exp(h(x[t]))*phi(y, yfixed))println(r)if r >=1 x[t+1] = yelseif v <= r x[t+1] = yelse x[t+1] = x[t]endendendreturn(x)end