高校数学の質問スレ(医者・東大卒専用) Part438 (991レス)
上下前次1-新
抽出解除 レス栞
リロード規制です。10分ほどで解除するので、他のブラウザへ避難してください。
240: 2024/10/26(土)09:11:01.76 ID:DYbBtbTY(1/2) AAS
"
ある政党に100人の議員がいる。
個々の議員が裏金議員である可能性には何の情報もないためその確率を一様分布と仮定する。
無作為に10人を選んで調べたところ9人が裏金議員であった。
100人中の裏金議員の数の期待値と95%信頼区間を算出せよ。
算出法は好みの手法でよい。
"
rm(list=ls())
n100=100
n10=10
n9=9
m=n100/2
sd=sqrt(n100/12)
fp=\(n) pnorm(n,m,sd)-pnorm(n-1,m,sd)
pn=sapply(0:n100,fp)
sim=\(){
u=sample(0:n100,1,prob=pn)
u10=sum(sample(1:0,n10,replace=TRUE,prob=c(u,100-u)))
c(u,u10)
}
k=1e6
res=t(replicate(k,sim()))
ans=res[res[,2]==n9,][,1]
BEST::plotPost(ans)
241: 2024/10/26(土)11:11:45.76 ID:DYbBtbTY(2/2) AAS
中心極限定理を使わずに算出
rm(list=ls())
n100=100
n10=10
n9=9
sim=\(){
u=sum(runif(n100))
u10=sum(sample(0:1,n10,replace=TRUE,prob = c(n100-u,u)))
c(u,u10)
}
k=1e6
res=t(replicate(k,sim()))
ans=res[res[,2]==n9,][,1]
hist(ans,freq=F,col=2,ann=F,axes=F) ; axis(1)
summary(ans)
HDInterval::hdi(ans)
BEST::plotPost(ans,xlab='n',showMode = T)
273: 2024/10/30(水)10:53:16.76 ID:1cUZWH52(1/2) AAS
バイト先で
最近の作業仮説
セクハラ認定したがるのはブサイク女か、持てない男である。
という話をして、
ここでセクハラ親父とか言われないのは美人揃いだからだね、と付言したら、
内視鏡スキルも容姿も高偏差値のナースから
センセ、そんなこと言っちゃだめですよと言われた。
顔には「もっと言って」と書いてあった。
新年から勤務日を増やしてくれと言われた職場。
287(1): 2024/10/31(木)23:22:27.76 ID:19VVcDLX(1/2) AAS
>>285
9レス全部スルーされてるねww
302(1): 2024/11/08(金)22:01:35.76 ID:cKORtqw5(1) AAS
>>300
∃は存在さえ示せればいい(例外がいくらあっても1個でも該当すればいい)
f(x) = 0 (何受け取っても0を返す関数)
-2 < x < 4 , f(-1) = 0 -- OK
-2 < x < 4 , f(-3) = 0 -- NG
∀は全てのなので、どんな場合も成り立たないといけない(1個でも例外があればNG)
f(x) = -x (xの正負を逆転させる関数)
-2 < x < 4 , f(-1) = 1 > 0 -- OK
1 < x < 4 , f(2) = -2 > 0 -- NG
308: 2024/11/13(水)12:48:17.76 ID:mLwXKDzl(2/4) AAS
乱数発生によるシミュレーションで理論値を検証
f[n_] :=(
b=Range[4];
Boole@ContainsAll[RandomChoice[b->b,n],b]
)
sim[n_,k_:10^5] :=(
N@Mean@Table[f[n],k]
)
DiscretePlot[sim[n],{n,41,45}]
333(2): 2024/11/22(金)16:33:49.76 ID:2M9XV7Pv(1) AAS
"
西暦2025年から西暦10000年まで2月29日が日曜日になることは何回あるか?
現行のグレゴリオ暦を用いて計算せよ。
"
library(lubridate)
wday(ymd("2016-2-29"),label=TRUE)
wday(ymd("2015-2-29"),label=TRUE)
str=as.character(2025:10000)
f=\(s) wday(ymd(paste0(s,"-2-29")))
re=sapply(str,f)
sum(re[!is.na(re)]==1)
833: 05/11(日)21:13:09.76 ID:2CgV4g4d(1) AAS
# データ設定
n_placebo <- 1000; eff_placebo <- 24
n_old <- 1000; eff_old <- 40
n_new <- 1000; eff_new <- 25
# 有効率
p_placebo <- eff_placebo / n_placebo
p_old <- eff_old / n_old
p_new <- eff_new / n_new
# 比較:旧薬 vs 偽薬(有意差)
m1 <- matrix(c(eff_old, n_old - eff_old, eff_placebo, n_placebo - eff_placebo), nrow = 2)
test1 <- prop.test(m1, correct = FALSE)
# 比較:新薬 vs 偽薬(有意差なし)
m2 <- matrix(c(eff_new, n_new - eff_new, eff_placebo, n_placebo - eff_placebo), nrow = 2)
test2 <- prop.test(m2, correct = FALSE)
# 比較:旧薬 vs 新薬(非劣性検定)
# 非劣性マージン
M <- -0.10
# 差(新薬 - 旧薬)
diff <- p_new - p_old
# 標準誤差(差の95%信頼区間に使用)
se <- sqrt(p_new*(1 - p_new)/n_new + p_old*(1 - p_old)/n_old)
z <- qnorm(0.025, lower.tail = FALSE)
lower_CI <- diff - z * se
# 非劣性判定
non_inferior <- lower_CI > M
# 結果表示
cat("=== 旧薬 vs 偽薬 ===\n")
print(test1)
cat("\n=== 新薬 vs 偽薬 ===\n")
print(test2)
cat("\n=== 非劣性検定(旧薬 vs 新薬) ===\n")
cat(sprintf("差(新薬 - 旧薬) = %.3f\n", diff))
cat(sprintf("95%% CI = [%.3f, %.3f]\n", diff - z*se, diff + z*se))
cat(sprintf("非劣性マージン = %.3f\n", M))
cat(sprintf("非劣性判定: %s\n", ifelse(non_inferior, "非劣性あり", "非劣性なし")))
850: 05/25(日)06:42:37.76 ID:P4nhnL8B(4/6) AAS
# If verbose flag is TRUE, plot the Beta distribution and annotate results
if (verbose) {
# Generate x values from 0 to 1 for plotting the density
x <- seq(0, 1, length.out = 1000)
# Compute Beta density values at x
y <- dbeta(x, alpha, beta)
# Color bars within the credible interval [lower, upper] as "lightcoral",
# others as light gray ("gray70")
col <- ifelse(x >= lower & x <= upper, "lightcoral", "gray70")
# Plot histogram-like vertical lines representing the Beta density
plot(x, y, type = "h", col = col, lwd = 2,
main = sprintf("Beta(%.2f, %.2f) Distribution\n[%s, %s] with %.0f%% Probability Mass",
alpha, beta, fractionStr(lower), fractionStr(upper), credMass * 100),
xlab = "x", ylab = "Density", bty = "n")
# Add vertical dashed line for the mean, colored skyblue
abline(v = mean, col = "skyblue", lwd = 1, lty = 2)
# Add vertical dashed line for the mode if defined, colored dark green
if (!is.na(mode)) {
abline(v = mode, col = "darkgreen", lwd = 1, lty = 2)
}
# Prepare legend labels for mean, mode (if exists), and credible interval
labels <- c(
paste0("Mean = ", round(mean, 3)),
if (!is.na(mode)) paste0("Mode = ", round(mode, 3)) else NULL,
paste0("95% Credible Interval [", fractionStr(lower), ", ", fractionStr(upper), "]")
)
# Corresponding colors for legend items
colors <- c(
"skyblue",
if (!is.na(mode)) "darkgreen" else NULL,
"lightcoral"
)
# Line types for legend items (dashed lines for mean and mode, none for credible interval)
ltys <- c(2, if (!is.na(mode)) 2 else NULL, NA)
# Plot characters for legend (none for lines, solid square for interval)
pchs <- c(NA, if (!is.na(mode)) NA else NULL, 15)
# Add legend at the top of the plot with no box, scaled text size
legend("top", legend = labels, col = colors, bty = "n", cex = 0.9,
lty = ltys, pch = pchs)
}
# Return a named vector of calculated parameters and statistics
c(alpha = alpha, beta = beta, mean = mean, mode = mode)
}
970: 07/04(金)16:51:52.76 ID:iaGT2Y/9(1) AAS
おーい尿瓶ジジイ生きてるかー?
975: 07/12(土)20:32:45.76 ID:gl7vYwO/(1) AAS
次スレ誘導すらないのに早漏が過ぎる
上下前次1-新書関写板覧索設栞歴
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ
ぬこの手 ぬこTOP 0.034s