[過去ログ]
高校数学の質問スレ(医者・東大卒専用) Part438 (1002レス)
上
下
前
次
1-
新
このスレッドは過去ログ倉庫に格納されています。
次スレ検索
歴削→次スレ
栞削→次スレ
過去ログメニュー
816
: 05/01(木)09:09
ID:L1qIlz9/(2/4)
AA×
[240|
320
|
480
|
600
|
100%
|
JPG
|
べ
|
レス栞
|
レス消
]
816: [sage] 2025/05/01(木) 09:09:32.28 ID:L1qIlz9/ Stanで作ったらコンパイルに時間がかかる。簡単なモデルはJAGSの方がいい。離散変数も扱えるし。 # JAGS model library(rjags) # Prepare the data outcome_data <- c(rep(1, 17), rep(2, 21), rep(3, 15), rep(4, 21), rep(5, 20), rep(6, 6)) N <- length(outcome_data) data_jags <- list(outcome = outcome_data, N = N) # Initial values (adjust as needed) inits_jags <- list( list(alpha = rep(1, 6), eta = 1), list(alpha = runif(6, 0.1, 2), eta = 5) ) # Compile the model model_jags <- jags.model( file = "hierarchical_dice_model.jag", data = data_jags, n.chains = 2, n.adapt = 1000 ) # Sampling samples_jags <- coda.samples( model = model_jags, variable.names = c("prob_simplex", "alpha", "eta"), n.iter = 4000 ) # Summary of the results cat("\nJAGS Sampling Results Summary:\n") summary(samples_jags) # Extract posterior samples (prob_simplex) prob_simplex_posterior_jags <- as.matrix(samples_jags[, grep("prob_simplex", varnames(samples_jags))]) head(prob_simplex_posterior_jags) # Plotting (example: posterior distribution of probabilities for each outcome) cat("\nPosterior Distribution Plots for Each Outcome:\n") par(mfrow = c(2, 3)) for (i in 1:6) { plot(prob_simplex_posterior_jags[, i], type = "l", main = paste("Prob[", i, "]"), xlab = "Iteration", ylab = "Probability") abline(h = 1/6, col = "red", lty = 2) } dice_prob_mean=prob_simplex_posterior_jags colors <- c("skyblue", "lightcoral", "lightgreen", "gold", "lightsalmon", "lightcyan") for (i in 1:ncol(dice_prob_mean)) { BEST::plotPost(dice_prob_mean[, i], compVal=1/6, xlab=paste("pip ", i), xlim=c(0, 0.4), main="", col=colors[i], border="black") } http://rio2016.5ch.net/test/read.cgi/math/1723152147/816
で作ったらコンパイルに時間がかかる簡単なモデルはの方がいい離散変数も扱えるし
上
下
前
次
1-
新
書
関
写
板
覧
索
設
栞
歴
あと 186 レスあります
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
ぬこの手
ぬこTOP
0.045s