Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
vidjil
vidjil
Commits
90a27598
Commit
90a27598
authored
Apr 02, 2015
by
Mikaël Salson
Browse files
segment: Optimise probability computation.
Avoid using pow in the loop. Call it once and then multiply or divide.
parent
a51084cd
Changes
1
Show whitespace changes
Inline
Side-by-side
algo/core/segment.cpp
View file @
90a27598
...
...
@@ -358,8 +358,12 @@ double KmerSegmenter::getProbabilityAtLeastOrAbove(int at_least) const {
float
index_load
=
getKmerAffectAnalyser
()
->
getIndex
().
getIndexLoad
()
;
double
proba
=
0
;
double
probability_having_system
=
pow
(
index_load
,
at_least
);
double
probability_not_having_system
=
pow
(
1
-
index_load
,
n
-
at_least
);
for
(
int
i
=
at_least
;
i
<
n
;
i
++
)
{
proba
+=
nChoosek
(
n
,
i
)
*
pow
(
index_load
,
i
)
*
pow
(
1
-
index_load
,
n
-
i
);
proba
+=
nChoosek
(
n
,
i
)
*
probability_having_system
*
probability_not_having_system
;
probability_having_system
*=
index_load
;
probability_not_having_system
/=
index_load
;
}
return
proba
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment