Skip to content

Commit

Permalink
Commit made by the Bioconductor Git-SVN bridge.
Browse files Browse the repository at this point in the history
Consists of 3 commits.

Commit information:

Commit id: 032e785

    Merge branch 'alyst-fixes'

    It contains two commits of Pull request #3.
    
Committed by: Sebastian Bauer
Author Name: Sebastian Bauer
Commit date: 2014-10-25 13:58:37 +0200
Author date: 2014-10-25 13:58:37 +0200

Commit id: 4287f56

    use log1p() where possible

    log1p(-x) should be more accurate and faster than log(1-x)
    
Committed by: Alexey Stukalov
Author Name: Alexey Stukalov
Commit date: 2014-10-24 19:06:07 +0200
Author date: 2014-10-23 15:28:46 +0200

Commit id: ba756a9

    fix parameter sampling

Committed by: Alexey Stukalov
Author Name: Alexey Stukalov
Commit date: 2014-10-23 02:09:01 +0200
Author date: 2014-10-23 02:05:37 +0200


git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/mgsa@96027 bc3139a8-67e5-0310-9ffc-ced21a209358
  • Loading branch information
sba1 committed Oct 25, 2014
1 parent 81e844d commit 9b638e8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/mgsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,12 @@ static void parameter_prior_sample(struct prior_sample *sample, struct parameter

if (prior->uniform_continuous)
{
sample->u.continuous_value = prior->uniform_continous_lower + (rnd - prior->uniform_continous_lower)*(prior->uniform_continous_upper - prior->uniform_continous_lower);
sample->u.continuous_value = prior->uniform_continous_lower + rnd * (prior->uniform_continous_upper - prior->uniform_continous_lower);
} else
{
sample->u.discrete_index = rnd * prior->number_of_states;
sample->u.discrete_index %= prior->number_of_states;
if ( sample->u.discrete_index >= prior->number_of_states )
sample->u.discrete_index = prior->number_of_states - 1;
}
}

Expand Down Expand Up @@ -891,10 +892,10 @@ static double get_score(struct context *cn)
double beta = get_beta(cn);
double p = get_p(cn);

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

/* apply prior */
score += log(p) * (cn->number_of_sets - cn->number_of_inactive_sets) + log(1.0-p) * cn->number_of_inactive_sets;
score += log(p) * (cn->number_of_sets - cn->number_of_inactive_sets) + log1p(-p) * cn->number_of_inactive_sets;
return score;
}

Expand Down

0 comments on commit 9b638e8

Please sign in to comment.