Commit ca736b9c authored by Benjamin Farr's avatar Benjamin Farr
Browse files

lalinference_mcmc: changed starting sigmas for adaptation

Original: 7450f0f21e5f04236bb1778e6c24e9ba66521bd1
parent 699a463c
......@@ -1480,9 +1480,18 @@ void initVariables(LALInferenceRunState *state)
fprintf(stdout, "Adapting single-param step sizes.\n");
if (!LALInferenceCheckVariable(state->proposalArgs, SIGMAVECTORNAME)) {
/* We need a sigma vector for adaptable jumps. */
char *name = NULL;
REAL8Vector *sigmas = XLALCreateREAL8Vector(N);
for (i = 0; i < N; i++) {
sigmas->data[i] = 1e-4;
for(i=0;i<N;++i){
name = LALInferenceGetVariableName(state->currentParams, (i+1));
if (!strcmp(name,"massratio") || !strcmp(name,"asym_massratio") || !strcmp(name,"time") || !strcmp(name,"a_spin2") || !strcmp(name,"a_spin1")){
sigmas->data[i] = 0.001;
} else if (!strcmp(name,"polarisation") || !strcmp(name,"phase") || !strcmp(name,"inclination")){
sigmas->data[i] = 0.1;
} else {
sigmas->data[i] = 0.01;
}
}
......
......@@ -527,7 +527,7 @@ void PTMCMCAlgorithm(struct tagLALInferenceRunState *runState)
logLAtAdaptStart = runState->currentLikelihood;
}
s_gamma=10.0*exp(-(1.0/adaptTau)*log((double)i-(double)adaptStart))-1;
s_gamma=exp(-(1.0/adaptTau)*log((double)i-(double)adaptStart))-0.1;
LALInferenceSetVariable(runState->proposalArgs, "s_gamma", &(s_gamma));
}
......@@ -707,6 +707,7 @@ void PTMCMCOneStep(LALInferenceRunState *runState)
REAL8 logProposalRatio = 0.0; // = log(P(backward)/P(forward))
REAL8 logAcceptanceProbability;
REAL8 temperature;
REAL8 targetAcceptance = 0.234;
INT4 acceptanceCount;
INT4 accepted = 0;
UINT4 tMaxSearch = 0;
......@@ -814,9 +815,9 @@ void PTMCMCOneStep(LALInferenceRunState *runState)
dprior = priorMax - priorMin;
if(accepted == 1){
sigma=sigma+s_gamma*(dprior/100.0)*(1.0-0.234);
sigma=sigma+s_gamma*(dprior/100.0)*(1.0-targetAcceptance);
}else{
sigma=sigma-s_gamma*(dprior/100.0)*(0.234);
sigma=sigma-s_gamma*(dprior/100.0)*(targetAcceptance);
}
sigma = (sigma > dprior ? dprior : sigma);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment