How to improve the efficiency of loop, and find a root

Thanks for your suggest. I’m a bigger to PyMC.
I also found that the Metropolis sampling is usually much faster than NUTS, but the posterior is not as good as NUTS. The posterior may diverge or exit many noise.