Skip to content

Commit

Permalink
add t > 0 enforcement for lower incomplete gamma
Browse files Browse the repository at this point in the history
  • Loading branch information
seabbs committed Oct 8, 2024
1 parent 95073b5 commit 79a12aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions R/primary_censored_dist.R
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,9 @@ primary_censored_cdf.pcens_pweibull_dunif <- function(

g <- function(t) {
# Use the lower incomplete gamma function
t <- pmax(t, 0)
scaled_t <- (t * inv_scale)^shape
vapply(scaled_t, function(x) {
if (x <= 0) {
return(0)
}
pracma::gammainc(x, 1 + inv_shape)["lowinc"]
}, numeric(1))
}
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-primary_censored_dist.R
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ test_that(
dprimary <- dunif

shapes <- c(0.5, 1, 2, 3)
scales <- c(0.5, 1, 2, 5)
pwindows <- c(1, 2, 5, 10)
scales <- c(0.5, 1, 2)
pwindows <- c(1, 2, 5)

for (shape in shapes) {
for (scale in scales) {
Expand Down

0 comments on commit 79a12aa

Please sign in to comment.