lmoffatt / macro_dr

GNU General Public License v3.0
1 stars 1 forks source link

right equations for the dependence of the acceptance on the betas #216

Closed lmoffatt closed 3 months ago

lmoffatt commented 4 months ago

The acceptance probability can be approximated in the following way

A_i \approx \Phi(-\frac{\Delta L_i}{sL_i}) + \exp (- \Delta \beta_i \cdot \Delta L_i)

The first term indicates the probability of the temperature jump to be positive, given that the logLikelihood differences $\Delta L_i$ distributes themselves normal with mean $\Delta L_i$ and standard deviation $sL_i$ . The first term approximates the expected probability of being accepted given that the logL difference is negative.

lmoffatt commented 4 months ago

Lets now define the variables:

A_i = \Pr(accept\  i  \to i+1)
\Delta \beta_i = \beta_{i+1} - \beta_i
\Delta L_i = L_{i+1} -L_i
sL_i = \sqrt{ vL_{i} +vL_{i}}

where $vL_i$ is the variance of the logLikelihood for the $i^{th}$ chain.

lmoffatt commented 4 months ago

Now lets find the derivative of $A_i$ with respect to $\betai$ and $beta{i+1}$

\frac {\partial A_i}{\partial \beta_i} \approx \frac{ derL_i}{sL_i} \cdot \phi(-\frac{\Delta L_i}{sL_i})   + (\Delta L_i + \Delta \beta_i \cdot der L_i)\cdot \exp (- \Delta \beta_i \cdot \Delta L_i)

and

\frac {\partial A_i}{\partial \beta_{i+1}} \approx -\frac{ derL_{i+1}}{sL_i} \cdot \phi(-\frac{\Delta L_i}{sL_i})   - (\Delta L_i + \Delta \beta_i \cdot der L_{i+1})\cdot \exp (- \Delta \beta_i \cdot \Delta L_i)

where

derL_i  \equiv \frac {\partial L_i}{\partial \beta_i}
lmoffatt commented 4 months ago

Now, what we want to optimize is the consecutive difference in Acceptances:

\Delta A_i \equiv A_{i+1} - A_i 

we calculate the derivative with respect to $\beta_{i+1}$

\frac{\partial \Delta A_i } {\partial \beta_{i+1} }= \frac{\partial A_{i+1} } {\beta_{i+1}} - \frac{\partial A_i}{\beta_{i+1}}
lmoffatt commented 4 months ago

Lets approximate this expression

\frac{\partial \Delta A_i } {\partial \beta_{i+1} }

\approx \frac{ vL_{i+1}}{sL_{i+1}} \cdot \phi(-\frac{\Delta L_{i+1}}{sL_{i+1}})   + (\Delta L_{i+1} + \Delta \beta_{i+1} \cdot v L_{i+1})\cdot \exp (- \Delta \beta_{i+1} \cdot \Delta L_{i+1}) +

+\frac{ vL_{i+1}}{sL_i} \cdot \phi(-\frac{\Delta L_i}{sL_i})   + (\Delta L_i + \Delta \beta_i \cdot v L_{i+1})\cdot \exp (- \Delta \beta_i \cdot \Delta L_i)
lmoffatt commented 4 months ago

We can use the relation

$$ \frac {\partial L_i} {\partial \beta_i} = vL_i $$

and approximate

$$ \frac {\partial L_i} {\partial \betai} \approx
\frac {1}{2} \cdot \left (\frac {\Delta L
{i-1}}{\Delta \beta{i-1}} +\frac {\Delta L{i}}{\Delta \beta_i} \right) $$

and

s L_i ^2 \approx 
 \frac {1}{2} \cdot \left (\frac {\Delta L_{i-1}}{\Delta \beta_{i-1}}  +2 \cdot \frac {\Delta L_{i}}{\Delta \beta_i} 
+\frac {\Delta L_{i+1}}{\Delta \beta_{i+1}}  \right)

Then we can express everything in terms of $\Delta \beta$ and $\Delta L$

Now if we consider that the value of the incremental coefficient $\frac {\Delta L_{i}}{\Delta \betai}$ is roughly the average of the one for $\beta{i-1}$ and $\beta_{i+1}$ we can approximate further to

s L_i ^2 \approx \approx 2 \cdot \frac {\Delta L_{i}}{\Delta \beta_i} 
lmoffatt commented 4 months ago

as delta L could be sometimes difficult (i.e., negative) , we can find a relationship based on variance that is always positive

\Delta L_i \approx \frac{1}{2}(vL_i+vL_{i+1}) \cdot \Delta \beta_i
lmoffatt commented 3 months ago

lets try to approximate everything

A_i \approx \Phi(-\frac{\Delta L_i}{sL_i}) + \exp (- \Delta \beta_i \cdot \Delta L_i) 
\frac{\Delta L_i}{sL_i} \approx   \frac{\sqrt{ vL_{i} +vL_{i+1}}}{2} \cdot \Delta \beta_i s \approx \approx  \sqrt{\frac{1}{2} \cdot \Delta L_{i} \cdot \Delta \beta_i}