-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cadebdc
commit cca6fe3
Showing
1 changed file
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,40 @@ | ||
use crate::{rate_matrix::RateMatrix, treestate::TreeMove}; | ||
|
||
pub struct BranchMove{} | ||
use rand::prelude::Distribution; | ||
// use rand::distributions::Normal; | ||
use statrs::distribution::Normal; | ||
use crate::topology::Topology; | ||
use crate::TreeState; | ||
pub struct BranchMove{ | ||
indices: Vec<usize>, | ||
} | ||
|
||
impl<R: RateMatrix> TreeMove<R> for BranchMove { | ||
fn generate(&self, ts: &crate::treestate::TreeState<R>) -> crate::treestate::TreeState<R> { | ||
todo!() | ||
let normal = Normal::new(0.0, 1.0).unwrap(); | ||
let mut changes: Vec<usize> = Vec::new(); | ||
|
||
// This is not ideal | ||
let mut nodes = ts.top.nodes.clone(); | ||
|
||
for i in self.indices.iter() { | ||
let ind = *i; | ||
let mut bl = nodes[ind].get_branchlen(); | ||
bl = bl.ln() + normal.sample(&mut rand::thread_rng()); | ||
nodes[ind].set_branchlen(bl.exp()); | ||
changes.push(ind); | ||
} | ||
|
||
let new_top = Topology{ | ||
nodes: nodes, | ||
tree_vec: ts.top.tree_vec.clone(), | ||
likelihood: ts.top.likelihood, | ||
}; | ||
|
||
TreeState{ | ||
top: new_top, | ||
mat: ts.mat, | ||
ll: ts.ll, | ||
changed_nodes: Some(changes), | ||
} | ||
} | ||
} |