Skip to content

Commit 032e785

Browse files
committed
Merge branch 'alyst-fixes'
It contains two commits of Pull request #3.
2 parents 52e060a + 4287f56 commit 032e785

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/mgsa.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,12 @@ static void parameter_prior_sample(struct prior_sample *sample, struct parameter
207207

208208
if (prior->uniform_continuous)
209209
{
210-
sample->u.continuous_value = prior->uniform_continous_lower + (rnd - prior->uniform_continous_lower)*(prior->uniform_continous_upper - prior->uniform_continous_lower);
210+
sample->u.continuous_value = prior->uniform_continous_lower + rnd * (prior->uniform_continous_upper - prior->uniform_continous_lower);
211211
} else
212212
{
213213
sample->u.discrete_index = rnd * prior->number_of_states;
214-
sample->u.discrete_index %= prior->number_of_states;
214+
if ( sample->u.discrete_index >= prior->number_of_states )
215+
sample->u.discrete_index = prior->number_of_states - 1;
215216
}
216217
}
217218

@@ -891,10 +892,10 @@ static double get_score(struct context *cn)
891892
double beta = get_beta(cn);
892893
double p = get_p(cn);
893894

894-
double score = log(alpha) * cn->n10 + log(1.0-alpha) * cn->n00 + log(1-beta)* cn->n11 + log(beta)*cn->n01;
895+
double score = log(alpha) * cn->n10 + log1p(-alpha) * cn->n00 + log1p(-beta)* cn->n11 + log(beta)*cn->n01;
895896

896897
/* apply prior */
897-
score += log(p) * (cn->number_of_sets - cn->number_of_inactive_sets) + log(1.0-p) * cn->number_of_inactive_sets;
898+
score += log(p) * (cn->number_of_sets - cn->number_of_inactive_sets) + log1p(-p) * cn->number_of_inactive_sets;
898899
return score;
899900
}
900901

0 commit comments

Comments
 (0)