Skip to content

Commit

Permalink
support for n_permu > combo/permuteCount cases
Browse files Browse the repository at this point in the history
  • Loading branch information
qddyy committed Sep 14, 2023
1 parent 10f3d9a commit de3245f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
17 changes: 11 additions & 6 deletions R/auxiliary_funcs.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ get_arrangement <- function(

args <- list(v = v, m = m, repetition = replace)

n_possible <- do.call(paste0(which, "Count"), args)

if (!isFALSE(progress)) {
progress <- interactive()
}
if (progress) {
if (is.null(count <- n_sample)) {
count <- do.call(paste0(which, "Count"), args)
if (isTRUE((n_step <- n_possible) > n_sample)) {
n_step <- n_sample
}
assign(
"pb", ProgressBar$new(count),
"pb", ProgressBar$new(n_step),
envir = environment(func)
)
body(func) <- as.call(c(
Expand All @@ -59,12 +61,15 @@ get_arrangement <- function(

args <- c(args, list(FUN = func, FUN.VALUE = func_value))

if (is.null(n_sample)) {
do.call(paste0(which, "General"), args)
} else {
if (isTRUE(n_sample < n_possible)) {
args$n <- n_sample
args$seed <- getOption("pmt_seed")
do.call(paste0(which, "Sample"), args)
} else {
possible <- do.call(paste0(which, "General"), args)
if (is.null(n_sample)) possible else {
possible[sample.int(n_possible, n_sample, replace = TRUE)]
}
}
}

Expand Down
11 changes: 10 additions & 1 deletion vignettes/examples.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ t$p_value
```{r}
# See ?KolmogorovSmirnov or ?twosample.ks
t <- pmt(
"twosample.ks"
"twosample.ks", n_permu <- 5000
)
# See ?Table2.8.1
Expand Down Expand Up @@ -362,6 +362,9 @@ t$feed(Table4.1.1)
t$statistic
t$p_value
t$n_permu <- 4000
t$p_value
```

## Example 4.1.1
Expand Down Expand Up @@ -401,6 +404,9 @@ t$feed(Table4.1.1)
t$statistic
t$p_value
t$n_permu <- 4000
t$p_value
t$type <- "approx"
t$p_value
```
Expand All @@ -421,6 +427,9 @@ t$feed(data.frame(
t$statistic
t$p_value
t$n_permu <- 4000
t$p_value
```

## Example 4.3.1
Expand Down

0 comments on commit de3245f

Please sign in to comment.