Skip to content

Commit

Permalink
Merge pull request #12 from MindTheGap-ERC/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
NiklasHohmann authored Jul 22, 2024
2 parents 1658f00 + 58096bb commit 38e82e5
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions R/apply_niche.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ apply_niche = function(x, niche_def, gc){
#' Models niches by removing events (fossil occurrences) when they are outside of their niche using the function `thin`.
#' Combines the functions `niche_def` and `gc` ("gradient change") to determine how the taxons' collection probability changes with time/position. This is done by composing `niche_def` and `gc`. The result is then used as a thinning on the events `x`.
#'
#' @returns numeric vector, events preserved after thinning
#'
#' @examples
#' \dontrun{
#' ## setup
Expand Down
8 changes: 8 additions & 0 deletions R/apply_taphonomy.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ apply_taphonomy = function(x, pres_potential, ctc){
#'
#' @seealso [apply_niche()] for modeling niche preferences based on the same principle, [thin()] for the underlying mathematical procedure.
#'
#' @returns numeric vector, events preserved after taphonomic effects are applied
#'
#' @examples
#' \dontrun{
#' # see
#' vignette("advanced_functionality")
#' # details on usage
#' }
#'

# function that returns preservation potential as a function of input (e.g. time or position)
change_pres_pot = function(y) pres_potential(ctc(y))
Expand Down
2 changes: 2 additions & 0 deletions R/p3_var_rate.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ p3_var_rate = function(x, y = NULL, from = 0, to = 1, f_max = 1, n = NULL){
#' }
#'
#' @seealso [p3()] for the constant rate implementation, [rej_samp()] for the underlying random number generation.
#'
#' @returns numeric vector, timing/location of events

if (from >= to){
stop("\"from\" must be smaller than \"to\".")
Expand Down
2 changes: 2 additions & 0 deletions R/rej_samp.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ rej_samp = function(f, x_min, x_max, n = 1L, f_max = 1){
#' hist(x) # note that no samples are drawn where sin is negative
#' }
#' @seealso [p3_var_rate()] for the derived variable rate Poisson point process implementation.
#'
#' @returns numeric vector, samples drawn from the (pseudo) pdf
x = c()
warn = FALSE
if (f_max <= 0) {stop("`f_max` must be positive.")}
Expand Down
2 changes: 2 additions & 0 deletions R/thin.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ thin = function(x, thin){
#' }
#'
#' @seealso [apply_niche()] and [apply_taphonomy()] for use cases with biological meaning
#'
#' @returns numeric vector, events after thinning

p = pmax(pmin(thin(x), rep(1, length(x))), rep(0, length(x))) # cut off at 0 and 1
ind = stats::rbinom(n = length(x), size = 1, prob = p) # determine if preserved or not
Expand Down
3 changes: 3 additions & 0 deletions man/apply_niche.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions man/apply_taphonomy.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/p3_var_rate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/rej_samp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/thin.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 38e82e5

Please sign in to comment.