phylojunction.calculation package
Submodules
phylojunction.calculation.clock_model module
- class phylojunction.calculation.clock_model.ClockModel(*, tree_dag_node: NodeDAG, attr_name: str)
Bases:
DeterministicFnAbstract base class for molecular clock models.
A clock model is a deterministic function (PhyloJunction’s ‘:=’ operator) that takes a chronogram DAG node – one or more phylogenetic trees whose branch lengths are measured in time – and, for each tree, returns a new tree whose reconstructed topology has been annotated with molecular-rate-related attributes.
Every concrete clock model must, at a minimum, populate a node attribute, named after ‘self.attr_name’ (float, in expected number of character changes per unit of branch length), on every branch of non-zero length in the reconstructed tree. The name of this attribute is chosen by the user (e.g., ‘mutation_rate’ for a molecular clock, ‘morph_rate’ for a morphological one) rather than hard-coded, so that PhyloJunction’s tree-plotting machinery (which can color branches by any such attribute) is not tied to any one clock model’s naming convention. Concrete subclasses are free to also populate additional, model-specific attributes under their own, fixed names (e.g., a punctuated, ‘Gamma-spike’ clock model also populates ‘branch_raw_rate’ and ‘spike_effect’).
A clock model does not originate its own sample size the way a sampling distribution (i.e., a ‘pgm.DistrForSampling’ instance) does – it inherits ‘n_samples’ and ‘n_repl’ from the tree DAG node it is applied to (‘tree_dag_node’ below).
- Parameters:
attr_name (str) – See ‘__init__’.
tree_dag_node (pgm.NodeDAG) – See ‘__init__’.
n_samples (int) – Number of tree samples this clock model will be applied to. Mirrors ‘tree_dag_node.sample_size’.
n_repl (int) – Number of (plated) replicates per tree sample this clock model will be applied to. Mirrors ‘tree_dag_node.repl_size’.
- abstract property CLOCK_MODEL_NAME: str
- property DET_FN_NAME: str
See ‘pgm.DeterministicFn.DET_FN_NAME’.
Every clock model is itself a deterministic function, so this concretely satisfies ‘pgm.DeterministicFn’s contract on behalf of every clock model at once, by forwarding to the more specific ‘CLOCK_MODEL_NAME’ each concrete subclass must provide.
- attr_name: str
- generate() List[AnnotatedTree]
Apply this clock model to every tree in ‘tree_dag_node’.
This method is the same for every clock model – what varies between concrete clock models is only ‘populate_branch_rates’ – so it is implemented here, concretely, rather than being abstract. Concrete subclasses should not need to override it.
- Returns:
- One new, deep-copied tree per
tree held by ‘self.tree_dag_node’, each annotated by ‘populate_branch_rates’.
- Return type:
(list of AnnotatedTree)
- abstractmethod populate_branch_rates(ann_tr: AnnotatedTree, tree_idx: int) None
Populate per-branch molecular-rate attributes (side-effect).
This method mutates ‘ann_tr’ in place; ‘generate()’ below is responsible for deep-copying each input tree before calling this method on the copy, so that ‘tree_dag_node’s own trees (this clock model’s DAG parent) are never mutated.
- Parameters:
ann_tr (AnnotatedTree) – Tree instance whose reconstructed tree’s branches will be annotated with molecular-rate attributes, in place.
tree_idx (int) – ‘ann_tr’s position (0-based) within ‘self.tree_dag_node.value’ – i.e., which (sample, replicate) slot this tree is. A concrete clock model that consumes another, equally-shaped DAG node for per-tree data (e.g., pre-generated per-branch base rates) uses this to index into that node’s own value list, so the two stay in lockstep without either model needing to track its own call count.
phylojunction.calculation.discrete_sse module
- class phylojunction.calculation.discrete_sse.DiscreteStateDependentParameter(val: int | float | str | List[int | float | str], name: str = '', state: int = 0, epoch_idx: int = 1)
Bases:
objectDiscrete state-dependent parameter.
This is the parent class for either state-dependent rates or state-dependent parameters.
Supports vectorization of values only.
- Parameters:
value (Union[int, float, str]) – Either an integer, float or string, or a list of any of those.
name (str) – Name of SSE parameter.
state (int) – Integer representing the state this SSE parameter is associated to.
epoch_idx (int) – Time slice (epoch) this SSE parameter is associated to.
- epoch_idx: int
- name: str
- state: int
- value: int | float | str | List[int | float | str]
- class phylojunction.calculation.discrete_sse.DiscreteStateDependentParameterManager(matrix_state_dep_params: List[List[DiscreteStateDependentParameter]], total_state_count: int, seed_age_for_time_slicing: float | None = None, list_time_slice_age_ends: List[float] | None = None, epsilon: float = 1e-12)
Bases:
objectClass for checking, organizing, and storing SSE parameters.
Upon initialization, this class verifies that user provided SSE parameters (and their time slice annotation) is acceptable. Then given a seed age for anchoring ages and converting them into times, and time slice age ends, this class produces computes time slice time ends.
This class does not care about vectorization. It manipulates instances of DiscreteStateDependentParameter, which then in turn contain multiple values if vectors have been passed by user.
Currently there is no support for vectorization of seed ages nor of time slices.
- Parameters:
matrix_state_dep_params (DiscreteStateDependentParameter) – 2D list, with first dimension being time slices, the second being SSE parameters. This is just a raw container of SSE parameters, and is not used for computations.
state_dep_params_dict (dict) – Dictionary with state indices (int) as keys, and a list of SSE parameters as values. This is the container that is used by MacroEvolEventHandler when calculating rates.
seed_age (float, optional) – Age of origin or root used to anchor time slice age ends so as to convert them into time slice time ends.
slice_age_ends (float) – List of time slice age ends.
slice_t_ends (float, optional) – List of time slice time ends. It is automatically filled upon initialization.
n_slices_to_ignore (int) – How many time slices are in their totality older than the whole tree (the user may have specified more time slice age ends than necessary given an origin or root time for the tree). Defaults to 0.
param_type (DiscreteStateDependentParameterType) – Attribute holding what type of SSE parameter this is (rate or probability).
epsilon (float) – Threshold for considering a difference equal to zero.
- epsilon: float
- matrix_state_dep_params: List[List[DiscreteStateDependentParameter]]
- n_slices_to_ignore: int
- param_type: DiscreteStateDependentParameterType
- seed_age: float | None
- slice_age_ends: List[float]
- slice_t_ends: List[float] | None
- state_dep_params_at_time(a_time: float, params_matrix: List[List[DiscreteStateDependentParameter]] | None = None) List[DiscreteStateDependentParameter]
Return list of SSE parameters given a specific time.
This method finds the time slice a specific time belongs to, and retrieves the list of SSE parameters pertaining to that time slice. This list is retrieved from a user-specified matrix, or from the matrix member of the enclosing class, self.matrix_state_dep_params.
- Parameters:
a_time (float) – A time at which we want to grab SSE parameters.
param_matrix (DiscreteStateDependentParameter) – A 2D list where the first dimension are time slices, and the second dimension are SSE parameters.
- Returns:
- a list of SSE parameters
from the appropriate time slice.
- Return type:
- state_dep_params_dict: Dict[int, List[List[DiscreteStateDependentParameter]]]
- class phylojunction.calculation.discrete_sse.DiscreteStateDependentParameterType(*values)
Bases:
Enum- PROBABILITY = 2
- RATE = 1
- UNDEFINED = 0
- class phylojunction.calculation.discrete_sse.DiscreteStateDependentProbability(val: int | float | str | List[int | float | str], name: str = '', state: int = 0, epoch_idx: int = 1)
Bases:
DiscreteStateDependentParameterState-dependent probability main class.
This class is derived from DiscreteStateDependentParameter. It holds a value for the probability, the name of the variable holding it, the state associated to the probability, and the time slice (epoch) that probability applies to.
Supports vectorization of values only.
- Parameters:
str_representation (str) – The string that is put together upon initialization and printed when __str__() is called.
- state_representation: str
- class phylojunction.calculation.discrete_sse.DiscreteStateDependentProbabilityHandler(state_dep_prob_manager: DiscreteStateDependentParameterManager)
Bases:
objectClass for handling state-dependent taxon sampling.
This is the sister class to MacroevolEventHandler. Note that time slices do not have to be the same as those for SSE rates.
- Parameters:
state_dep_prob_manager (DiscreteStateDependentParameterManager) – Object that checks, organizes and stores SSE probabilities.
state_count (int) – Number of states characterizing the SSE process.
n_time_slices (int) – Number of time slices.
slice_age_ends (float) – List of time slice age ends.
slice_t_ends (float, optional) – List of time slice time ends.
str_representation (str) – The string that is put together upon initialization and printed when __str__() is called.
- n_time_slices: int
- randomly_decide_taxon_sampling_at_time_at_state(a_time, state_idx, sample_idx) bool
Raises:
- seed_age: float | None
- slice_age_ends: List[float]
- slice_t_ends: List[float] | None
- state_count: int
- state_dep_prob_manager: DiscreteStateDependentParameterManager
- str_representation: str
- class phylojunction.calculation.discrete_sse.DiscreteStateDependentRate(val: int | float | str | List[int | float | str], event: MacroevolEvent, name: str = '', states: List[int] = [], epoch_idx: int = 1)
Bases:
DiscreteStateDependentParameterState-dependent rate main class.
This class is derived from DiscreteStateDependentParameter. It holds a value for the rate, the type of rate, the name of variable holding it, the state associated to the rate, and the time slice (epoch) that rate applies to.
Supports vectorization of values only.
- Parameters:
state_tuple (int) – Tuple storing all states associated to SSE parameter.
departing_state (int) – State event is departing from.
arriving_state (int) – State event is arriving at.
event (MacroevolEvent) – The type of macroevolutionary event (e.g., within-region speciation, extinction, etc.) this SSE parameter is associated to.
str_representation (str) – The string that is put together upon initialization and printed when __str__() is called.
- arriving_state: int
- departing_state: int
- event: MacroevolEvent
- state_tuple: Tuple[int]
- states: List[int]
- str_representation: str
- class phylojunction.calculation.discrete_sse.MacroevolEvent(*values)
Bases:
Enum- ANAGENETIC_TRANSITION = 4
- ANCESTOR_SAMPLING = 5
- ASYM_SPECIATION = 2
- BW_SPECIATION = 1
- EXTINCTION = 3
- W_SPECIATION = 0
- class phylojunction.calculation.discrete_sse.MacroevolEventHandler(sse_rate_manager: DiscreteStateDependentParameterManager)
Bases:
objectClass for handling state-dependent rates.
Some of the methods in this class are vector-aware (through parameter value_idx), because instances of this class will be directly called by dn_sse.simulate() method, which in turn will try to access parameter values stored in a #-simulations-sized list.
- Parameters:
sse_rate_manager (DiscreteStateDependentParameterManager) – Object that checks, organizes and stores SSE rates.
state_count (int) – Number of states characterizing the SSE process.
n_time_slices (int) – Number of time slices.
slice_age_ends (float) – List of time slice age ends.
slice_t_ends (float, optional) – List of time slice time ends.
seed_age (float, optional) – Age of seed (origin or root), stored in ‘state_dep_rate_manager’.
str_representation (str) – The string that is put together upon initialization and printed when __str__() is called.
- n_time_slices: int
- sample_event_sse_rate_param(denominator: float, a_time: float, state_indices: List[int], value_idx: int = 0, a_seed: float | None = None, debug: bool | None = False)
Return one-sized list with a random SSE rate.
This method accesses the sse_rate_manager member to grab all SSE rates departing from one or more focal states. It then weighs each SSE rate by their value divided by the sum of the values of all SSE rates departing from the focal state. Given these weighed SSE rates, it randomly picks one and returns.
This method is called by DnSSE (dn_discrete_sse.py) when randomly choosing an event, after an event time and a node have already been chosen.
- Parameters:
denominator (float) – Normalization term for computing weights of different events.
a_time (float) – When the event will take place.
state_indices (int) – Event is conditioned on departing from this state(s).
value_idx (int, optional) – Index specifying which parameter value (within a vector of #-of-simulations-size) we care about. Defaults to 0 (first element).
a_seed (int, optional) – Random seed for simulation (not working at the moment). Defaults to None.
debug (bool, optional) – Flag for printing debugging messages. Defaults to False.
- Returns:
List with a single SSE rate.
- Return type:
- seed_age: float | None
- slice_age_ends: List[float]
- slice_t_ends: List[float] | None
- sse_rate_manager: DiscreteStateDependentParameterManager
- state_count: int
- str_representation: str
- total_rate(a_time: float, state_representation_dict: Dict[int, Set[str]], value_idx: int = 0, departing_state: int | None = None, debug: bool | None = False) float | Tuple[float, List[float]]
Get total rate given possible events at time slice and tree.
This method is called by DnSSE (dn_discrete_sse.py) when it is time to draw the time to the next event, which is exponentially distributed with rate equal to the total sum of rates being computed by this method (the first return in the tuple).
For the first return in the tuple, this method gets all event rates for a given time slice, and adds them up. Different rates are weighed depending on their departing states, with the weight being the number of lineages representing that state.
For the second return in the tuple, this method adds up rates by their departing states, but there is no weighing. The grouped rates are put into a list, at index = state index.
The ‘departing_state’ argument remains as legacy; this method never actually gets called with departing_state. This also means that a pure float return also never happens (only the tuple return).
- Parameters:
a_time (float) – Forward time (not age!) we want to recover rates with.
state_representation_dict (dict) – Dictionary with (int) states as keys and list of (str) node labels at that state.
value_idx (int, optional) – Index specifying which parameter value (within a vector of #-of-simulations-size) we care about. Defaults to 0 (first element).
departing_state (int, optional) – State we can condition rates on. Defaults to None.
debug (bool, optional) – Flag for printing debugging messages. Defaults to False.
- Returns:
- If no departing_state is provided, returns the global
rate. Otherwise, returns a state-conditioned total rate and a list with each state total rate.
- Return type:
(float)
- class phylojunction.calculation.discrete_sse.SSEStash(macroevol_event_handler: MacroevolEventHandler, state_dep_prob_handler: DiscreteStateDependentProbabilityHandler | None = None)
Bases:
objectClass for stashing state-dependent rate and probability handlers.
- Parameters:
meh (MacroevolEventHandler) – Instance of state-dependent rate handler class.
prob_handler (DiscreteStateDependentProbabilityHandler) – Instance of state-dependent probability handler class.
- get_meh() MacroevolEventHandler
- get_prob_handler() DiscreteStateDependentProbabilityHandler
- prob_handler: DiscreteStateDependentProbabilityHandler
- str_representation: str
- class phylojunction.calculation.discrete_sse.StateIntoPatternConverter(n_characters: int, n_states_per_char: int)
Bases:
objectStash and machinery for checking and converting character compound-states into bit patterns, and vice-versa.
For example, if we are thinking about regions as characters, then compound-state means different ranges (e.g., “A”, “AB”), while ‘state’ is the number of different values a single character can take. In the case of 1-character-1-region, then the number of states is 2, because a species is either present or not in a region.
- Parameters:
n_char (int) – Number of characters.
n_states_per_char (int) – Number of states per character.
n_states (int) – Total number of states.
str (set2int_dict (dict of) – str): Dictionary for converting a state coded as an integer into a bit set.
str – str): Dictionary for converting a state coded as a bit set into an integer.
- int2set_dict: Dict[str, str]
- n_char: int
- n_states: int
- n_states_per_char: int
- set2int_dict: Dict[str, str]
phylojunction.calculation.gamma_spike_clock_model module
- class phylojunction.calculation.gamma_spike_clock_model.GammaSpikeClockModel(*, tree_dag_node: NodeDAG, attr_name: str, clock_rate: float, spike_mean: float, spike_shape: float, br_specific_rel_rate_dag_node: NodeDAG, strict_clock_when_no_stubs: bool = False)
Bases:
ClockModelPunctuated (‘Gamma-spike’) relaxed molecular clock model.
Each branch’s molecular rate is the sum of a gradual component (an i.i.d. log-normal relaxed clock) and an abrupt, ‘spike’ component, whose size is drawn from a Gamma distribution conditioned on the number of stubs (unsampled bifurcations) on that branch. See ‘populate_gamma_spike_mol_rates_on_rec_tr_branches’ (this module) for the underlying algorithm, which this class wraps as a PhyloJunction clock model.
References
Douglas, J., Bouckaert, R., Harris, S.C., Carter Jr, C.W., Wills, P.R. (2025) Evolution is coupled with branching across many granularities of life. Proceedings of the Royal Society B, 292: 20250182. https://doi.org/10.1098/rspb.2025.0182
- CLOCK_MODEL_NAME = 'gamma_spike_clock'
- clock_rate: float
- get_rev_inference_spec_info() List[str]
See ‘pgm.ValueGenerator.get_rev_inference_spec_info’.
Not yet implemented: RevBayes has no known equivalent of the Gamma-spike clock model (it is a 2025 BEAST2-only addition at the time of writing), and PhyloJunction’s own RevBayes inference-script export (‘pjcli –inference-output’) is itself still an unfinished feature (see ‘pj_cli.py’). Revisit this once that feature is implemented for other distributions.
- init_check_vectorize_sample_size(param_list: List[Any] = []) None
Validate Gamma-spike clock hyperparameters (currently scalar-only).
FOR LATER: once per-sample vectorized clock hyperparameters are supported (e.g., a different ‘clock_rate’ per tree sample, drawn from an upstream DAG node), this method should grow each scalar hyperparameter into a list of length ‘self.n_samples’, mirroring how distributions in ‘distribution.dn_parametric’ do it today. For now, every hyperparameter is a plain scalar float (enforced by this class’ type hints), so there is nothing to vectorize.
- populate_branch_rates(ann_tr: AnnotatedTree, tree_idx: int) None
See ‘ClockModel.populate_branch_rates’.
In addition to ‘self.attr_name’, this model also populates ‘branch_raw_rate’ and ‘spike_effect’ on every non-zero-length reconstructed-tree branch – see ‘populate_gamma_spike_mol_rates_on_rec_tr_branches’ (this module) for their exact definitions.
- spike_mean: float
- spike_shape: float
- strict_clock_when_no_stubs: bool
- phylojunction.calculation.gamma_spike_clock_model.populate_gamma_spike_mol_rates_on_rec_tr_branches(ann_tr: AnnotatedTree, clock_rate: float, spike_mean: float, spike_shape: float, br_specific_rel_rates: List[float], strict_clock_when_no_stubs: bool = False) None
Populate molecular-rate attrs on rec. tree branches (Gamma-spike clock).
Implements the punctuated (‘Gamma-spike’) relaxed-clock model of Douglas et al. (2025): each branch’s molecular rate is a gradual (log-normal relaxed-clock) component plus an abrupt (‘spike’) component whose size depends on the number of stubs (unsampled bifurcations) on that branch.
Under the model exactly as described by Douglas et al. (‘strict_clock_when_no_stubs=False’, the default), a branch with zero stubs still gets independent, randomly-drawn gradual and spike components (a relaxed clock varies rates branch-to-branch regardless of stubs; zero stubs just means one baseline spike – see eqn 2.7 – rather than a larger, stub-inflated one). Setting ‘strict_clock_when_no_stubs=True’ deliberately departs from the paper: a branch with zero stubs instead gets a fixed, deterministic rate (equivalent to a strict clock: ‘branch_raw_rate = 1.0’, ‘spike_effect = 0.0’, so ‘mol_rate’ is exactly ‘clock_rate’ for every such branch), and only a branch with at least one stub keeps the usual relaxed-clock-plus-spike draw.
NOTE: ‘strict_clock_when_no_stubs=True’ is NOT a realistic alternative model of molecular evolution, and should not be used to represent a biological hypothesis – pinning every stub-free branch to a fixed rate has no basis in Douglas et al. (2025) or elsewhere. It exists purely as a debugging/diagnostic device: by making every stub-free branch identical (e.g., the same color, if colored by ‘mol_rate’), it isolates the spike component’s effect from ordinary relaxed-clock rate variation, which is useful for probing/visualizing how stubs alone affect rates, or for sanity- checking a clock-model implementation, but it is not meant to be used as a clock model for actual analyses.
This function is deliberately independent of PhyloJunction’s DAG and grammar machinery (see ‘GammaSpikeClockModel’ below for that): it operates on a single ‘AnnotatedTree’ instance, in place, and can be imported and used on its own.
Random draws are made with NumPy’s legacy, global random number generator (module-level ‘numpy.random.*’ functions), the same convention used throughout PhyloJunction (e.g., ‘distribution.dn_discrete_sse.DnSSE’). There is no ‘seed’ parameter here: reproducibility is controlled once, globally, by whichever caller already seeded that generator – the DAG’s own ‘random_seed’ (set from a ‘.pj’ script’s ‘-r’ CLI flag or the GUI’s seed field; see ‘pgm.DirectedAcyclicGraph.random_seed’). Callers that are not going through the DAG (e.g., unit tests) must call ‘numpy.random.seed(…)’ themselves beforehand for reproducible draws.
Side-effect: populates the attributes ‘branch_raw_rate’ (the log-normal relaxed-clock draw), ‘spike_effect’ (the Gamma-spike draw), and ‘mol_rate’ (their combination, see below) on every node of ‘ann_tr.tree_reconstructed’ with a non-zero-length branch. The root, and any sampled-ancestor branch (both of which have no meaningful rate of their own), get ‘None’ for all three.
This function also (re-)populates the ‘n_stub’ attribute these branches require, by calling ‘AnnotatedTree.populate_n_stubs_on_branches_of_rec_tr’ itself – counting stubs is pure tree-topology bookkeeping, shared by any future stub-aware clock model, and cheap/idempotent to redo, so callers do not need to remember to call it first.
References
Douglas, J., Bouckaert, R., Harris, S.C., Carter Jr, C.W., Wills, P.R. (2025) Evolution is coupled with branching across many granularities of life. Proceedings of the Royal Society B, 292: 20250182. https://doi.org/10.1098/rspb.2025.0182
- Parameters:
ann_tr (AnnotatedTree) – Tree instance whose reconstructed tree’s branches will be annotated, in place.
clock_rate (float) – Mean clock (substitution) rate (mu_c in Douglas et al. 2025). Must be > 0.0.
spike_mean (float) – Mean spike size (S_mu). Must be >= 0.0.
spike_shape (float) – Shape (S_alpha) of the Gamma distribution governing spike sizes (eqn 2.7). Must be > 0.0.
br_specific_rel_rates (list of float) – Pre-generated per-branch relative rates (the gradual, relaxed-clock component), e.g. produced by a separate ‘distribution.dn_parametric.DnLogNormal’ node via the grammar’s ‘n_nr_from’ argument pointed at an ‘n_rec_branches’ det-fn node for this same tree (see ‘interface.grammar.dn_grammar’). Conventionally centered at 1.0 in real space (e.g., a log-normal with ‘meanlog = -sdlog**2 / 2’), so that ‘clock_rate’ alone remains the mean absolute rate – the same identifiability convention BEAST2’s UCLN relaxed clock uses – though this function itself does not enforce that centering; it simply multiplies whatever is given by ‘clock_rate’. Must have exactly ‘ann_tr.n_rec_branches()’ entries, one per real branch of the reconstructed tree, in the same (preorder) order ‘n_rec_branches’ counts them in – checked directly against the tree’s own actual real- branch count, regardless of how ‘br_specific_rel_rates’ was itself produced. The spike component is always still drawn internally here.
strict_clock_when_no_stubs (bool) – See above – NOT a realistic model, a debugging/diagnostic device only. Defaults to ‘False’ (the model as described by Douglas et al.).
- Raises:
ValueError – Is raised if any of ‘clock_rate’, ‘spike_mean’, or ‘spike_shape’ is out of its valid range, or if ‘br_specific_rel_rates’ is given with the wrong number of entries.
phylojunction.calculation.math_utils module
- class phylojunction.calculation.math_utils.BaseEnum(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
- class phylojunction.calculation.math_utils.MetaEnum(cls, bases, classdict, *, boundary=None, _simple=False, **kwds)
Bases:
EnumType
- class phylojunction.calculation.math_utils.ParametricDistribution(*values)
Bases:
str,BaseEnum- EXPONENTIAL = 'expn'
- GAMMA = 'gamma'
- LOGNORMAL = 'lnormal'
- NORMAL = 'normal'
- UNIFORM = 'uniform'
- phylojunction.calculation.math_utils.exp_extant_count_bd(birth_rate: float, death_rate: float, tree_age: float, n_starting_lineages: int | None = 1) float
Return expected count of extant taxa in a birth-death tree
- Parameters:
birth_rate (float) – Birth-rate (lambda) of birth-death process.
death_rate (float) – Death-rate (mu) of birth-death process.
tree_age (float) – Age of birth-death tree (starting from origin).
n_starting_lineages (int) – Number of starting lineages. Defaults to 1.
- Returns:
Expected count of extant taxa.
- Return type:
int
- phylojunction.calculation.math_utils.exp_root_height_yule_ntaxa(birth_rate: float, n_taxa: int) float
Return expected root height of Yule tree simulated up to a specified number of tips
- Parameters:
birth_rate (float) – Birth-rate (lambda) of Yule process.
n_taxa (int) – Tree is simulated until this number of tips.
- Returns:
Expected root height
- Return type:
float