高校数学の質問スレ(医者・東大卒専用) Part438 (899レス)
高校数学の質問スレ(医者・東大卒専用) Part438 http://rio2016.5ch.net/test/read.cgi/math/1723152147/
上
下
前
次
1-
新
通常表示
512バイト分割
レス栞
818: 132人目の素数さん [sage] 2025/05/01(木) 11:18:32.55 ID:L1qIlz9/ ニッチな値の探索処理が終了しないコード rm(list=ls()) library(fmsb) library(parallel) alpha <- 0.05 # Function to perform a single simulation sim_single <- function(N = 100) { A <- sample(1:N, 1) while (A > N - 2) A <- sample(1:N, 1) B <- sample(N - A - 1, 1) C <- N - A - B ABC <- c(A, B, C) abc <- sapply(ABC, function(x) sample(x, 1)) x <- abc n <- ABC m <- rbind(s = x, f = n - x) bonf_res <- pairwise.fisher.test(x, n, p.adj = 'bonf') holm_res <- pairwise.fisher.test(x, n, p.adj = 'holm') fdr_res <- pairwise.fisher.test(x, n, p.adj = 'fdr') none_res <- pairwise.fisher.test(x, n, p.adj = 'none') bonf <- min(bonf_res$p.value, na.rm = TRUE) holm <- min(holm_res$p.value, na.rm = TRUE) fdr <- min(fdr_res$p.value, na.rm = TRUE) none <- min(none_res$p.value, na.rm = TRUE) list(m = m, bonf = bonf, holm = holm, fdr = fdr, none = none) } # Function to find a result that meets the criteria using parallel processing find_result_parallel_loop <- function(alpha = 0.05, num_cores = detectCores() - 1) { # Create a cluster of worker processes cl <- makeCluster(num_cores) # Ensure the cluster is stopped when the function exits on.exit(stopCluster(cl)) # Export the sim_single function to the worker processes clusterExport(cl, "sim_single") # Load the fmsb library in the worker processes clusterEvalQ(cl, library(fmsb)) cat("Searching for a result that meets the criteria...\n") while (TRUE) { # Run simulations in parallel results <- parLapply(cl, 1:num_cores, function(i) { # Run as many simulations as cores sim_single() }) # Check the results for the desired condition for (res in results) { if (res$bonf > alpha && res$holm < alpha) { cat("Result meeting the criteria found:\n") return(res) } } # If no result found in this batch, continue the loop } } # Find the result using parallel processing until found res_parallel_loop <- find_result_parallel_loop(alpha = alpha) # Output the result (will be printed within the loop when found) print(res_parallel_loop) http://rio2016.5ch.net/test/read.cgi/math/1723152147/818
メモ帳
(0/65535文字)
上
下
前
次
1-
新
書
関
写
板
覧
索
設
栞
歴
あと 81 レスあります
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.008s