# Question about SMC step tuning (older version)

**URL:** <https://discourse.pymc.io/t/question-about-smc-step-tuning-older-version/7051>\
**Category:** Questions\
**Created:** [March 22, 2021, 9:41am UTC](https://discourse.pymc.io/t/question-about-smc-step-tuning-older-version/7051 "2021-03-22T09:41:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![somogyibalint](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/somogyibalint/32/3834_2.png) [@somogyibalint](https://discourse.pymc.io/u/somogyibalint)\
**Post date:** [March 22, 2021, 9:41am UTC](https://discourse.pymc.io/t/question-about-smc-step-tuning-older-version/7051/1 "2021-03-22T09:41:41Z")

</div>

Hi,

I’m trying to understand the tune() procedure of the older SMC implementation (the random walk version). I understand the motivation behind scaling the step size of each chain according to previous acceptance rates, but cannot make sense of the actual scaling formula. Is there a probabilistic motivation, or is this just a heuristic formula? My intuition is that this is the first iteration to solve some implicit equation, but I might be completely wrong.

I don’t expect a detailed explanation, but I would appreciate if somebody points me in the right direction (papers, books, theorems, etc.).

The code in question:  
ave\_scaling = np.exp(np.log(self.scalings.mean()) + (self.acc\_per\_chain.mean() - 0.234))  
self.scalings = 0.5 \* (ave\_scaling + np.exp(np.log(self.scalings) + (self.acc\_per\_chain - 0.234)))

---

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [March 22, 2021, 11:15am UTC](https://discourse.pymc.io/t/question-about-smc-step-tuning-older-version/7051/2 "2021-03-22T11:15:31Z")

</div>

`0.234` is the target acceptance ratio for the random walk Kernel. The value is 0.234 since that’s optimal for Random Walk Metropolis kernel with Gaussian like target [1].  
So these 2 lines of code compute the current target scaling in `ave_scaling` (it’s an approximation), and push the current scaling `self.scalings` towards this target a little bit [2].

[1] Roberts GO, Gelman A, Gilks WR. Weak convergence and optimal scaling of random walk Metropolis algorithms. _The annals of applied probability_. 1997;7(1):110-20.  
[2] Del Moral, Pierre, Arnaud Doucet, and Ajay Jasra. An adaptive sequential Monte Carlo method for approximate Bayesian computation. _Statistics and Computing_, 22.5(1009-1020), 2012
