Randomly selects an event type (birth, death, or transition) based on the relative rates of each event in a Gillespie simulation algorithm.
sample_action(total_birth_rate, total_death_rate, total_transition_rate)A character string: either "birth", "death", or "transition" indicating the selected event
This function implements the event selection step of the Gillespie algorithm. The probability of selecting each event type is proportional to its rate relative to the total rate of all events combined.
# Example usage:
total_birth_rate <- 0.5
total_death_rate <- 0.3
total_transition_rate <- 0.2
action <- sample_action(total_birth_rate, total_death_rate, total_transition_rate)
#> Warning: restarting interrupted promise evaluation
#> Warning: internal error -3 in R_decompress1
#> Error: lazy-load database '/Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library/cancerSimCraft/R/cancerSimCraft.rdb' is corrupt
print(action) # Possible output: "birth"
#> Error: object 'action' not found