Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
VEBER Philippe
codepi
Commits
b4e42135
Commit
b4e42135
authored
Mar 16, 2021
by
Louis Duchemin
Browse files
TDG09 : faster matrix exponentiation (hopefully ?)
parent
de17b6b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
lib/tk/tdg09.ml
lib/tk/tdg09.ml
+13
-8
No files found.
lib/tk/tdg09.ml
View file @
b4e42135
...
...
@@ -22,8 +22,13 @@ module Evolution_model = struct
)
let
transition_probability_matrix
p
=
let
m
=
rate_matrix
p
in
let
(
d_vec
,
transform_matrix
)
=
Amino_acid
.
Matrix
.
diagonalize
m
in
let
rev_trans_matrix
=
Amino_acid
.
Matrix
.
inverse
transform_matrix
in
fun
t
->
Amino_acid
.
Matrix
.(
expm
(
scal_mul
t
m
))
let
exp_matrix
=
Amino_acid
.
Vector
.(
exp
(
scal_mul
t
d_vec
))
|>
Amino_acid
.
Matrix
.
diagm
in
Amino_acid
.
Matrix
.(
dot
(
dot
transform_matrix
exp_matrix
)
rev_trans_matrix
)
(* Amino_acid.Matrix.(expm (scal_mul t m)) *)
end
let
choose_aa
p
=
...
...
@@ -533,9 +538,9 @@ module Implementation_check = struct
ignore
(
let
values
=
Array
.
map
results
~
f
:
(
fun
(
_
,_,_,
lrt
)
->
lrt
.
pvalue
)
in
OCamlR_graphics
.
hist
~
main
:
title
~
xlab
:
"p"
~
breaks
:
(
`n
20
)
values
:>
OCamlR_graphics
.
hist
)
;
~
main
:
title
~
xlab
:
"p"
~
breaks
:
(
`n
20
)
values
:>
OCamlR_graphics
.
hist
)
;
OCamlR_grDevices
.
dev_off
()
let
render_stat_histogram
~
title
~
df
results
dest
=
...
...
@@ -543,10 +548,10 @@ module Implementation_check = struct
ignore
(
let
values
=
Array
.
map
results
~
f
:
(
fun
(
_
,_,_,
lrt
)
->
lrt
._
D_
)
in
OCamlR_graphics
.
hist
~
main
:
title
~
xlab
:
"D"
~
freq
:
false
~
breaks
:
(
`n
20
)
values
:>
OCamlR_graphics
.
hist
)
;
~
main
:
title
~
xlab
:
"D"
~
freq
:
false
~
breaks
:
(
`n
20
)
values
:>
OCamlR_graphics
.
hist
)
;
let
x
=
Array
.
init
1_000
~
f
:
(
fun
i
->
float
i
/.
10
.
)
in
let
y
=
Array
.
map
x
~
f
:
(
Gsl
.
Randist
.
chisq_pdf
~
nu
:
df
)
in
OCamlR_graphics
.
lines
~
x
~
y
()
;
...
...
Write
Preview
Markdown
is supported
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