class_docstr: Responsible for evaluating the ratio of mutations to the reverse movement
class_docstr_tok: ["Responsible","for","evaluating","the","ratio","of","mutations","to","the","reverse","movement"]
docstr: Calculated the ratio of the likelihood of a mutation over the likelihood of the reverse movement
  
  Main access point for the class
  
  Parameters
  ----------
  model: Model
      The overall model object the tree belongs to
  tree: Tree
      The tree being changed
  mutation: TreeMutation
      The proposed mutation
  
  Returns
  -------
  float
      logged ratio of likelihoods
docstr_tok: ["Calculated","the","ratio","of","the","likelihood","of","a","mutation","over","the","likelihood","of","the","reverse","movement","Main","access","point","for","the","class","Parameters","--","--","--","--","--","model",":","Model","The","overall","model","object","the","tree","belongs","to","tree",":","Tree","The","tree","being","changed","mutation",":","TreeMutation","The","proposed","mutation","Returns","--","--","--","-","float","logged","ratio","of","likelihoods"]
code: def log_probability_ratio(
      self, model: Model, tree: Tree, mutation: TreeMutation
  ) -> Tuple[float, tuple, tuple]:
      """
      Calculated the ratio of the likelihood of a mutation over the likelihood of the reverse movement
  
      Main access point for the class
  
      Parameters
      ----------
      model: Model
          The overall model object the tree belongs to
      tree: Tree
          The tree being changed
      mutation: TreeMutation
          The proposed mutation
  
      Returns
      -------
      float
          logged ratio of likelihoods
      """
      log_likelihood_ratio, (l_new, l_old) = self.log_likelihood_ratio(
          model, tree, mutation
      )
      log_transition_ratio, (t_new, t_old) = self.log_transition_ratio(
          tree, mutation
      )
      log_prior_ratio, (p_new, p_old) = self.log_tree_ratio(
          model, tree, mutation
      )
      bayes_term = log_transition_ratio + log_prior_ratio
      prob_score = bayes_term + log_likelihood_ratio
      ratio = np.exp(prob_score)
      p_t_new = p_new + t_new
      p_t_old = p_old + t_old
      prob_new = l_new + p_t_new
      prob_old = l_old + p_t_old
      return ratio, (l_new, l_old), (prob_new, prob_old)
  
file_path: imodels/imodels/experimental/bartpy/samplers/treemutation.py
imports: import numpy
  from abc import abstractmethod, ABC
  from typing import Optional, Tuple
  from ..model import Model
  from ..mutation import TreeMutation
  from ..samplers.sampler import Sampler
  from ..tree import Tree
label_desc: Use image node_id 1 for calling the TreeMutationLikelihoodRatio obj's underlying member method code with example usage: obj.log_probability_ratio(model, tree, mutation) and returns: ratio,  l_new,  l_old,  prob_new,  prob_old