How to use sample with a posterior model?

say I want to sample using

sample(model,  sampling technique(HMC, MH), number of samples),

I have a posterior p(x) = 7exp(-x/4) + 4exp(-x/6) - 7*exp(-(x-4)^2/64)

I want to sample using sample function and the posterior. Can anyone give me an example?