高校数学の質問スレ(医者・東大卒専用) Part438 (991レス)
前次1-
抽出解除 レス栞

リロード規制です。10分ほどで解除するので、他のブラウザへ避難してください。
91: 2024/08/19(月)21:25:54.52 ID:fCkpErGW(1) AAS
スノのいいドラマは被らないとこでライブ配信やって下げるのに
ワーキングプアしてるのか
お前らの
180: 2024/08/27(火)06:18:32.52 ID:uadWa+Us(1) AAS
尿瓶ジジイまた措置入院かよ?
249
(1): 2024/10/27(日)05:57:28.52 ID:SNtImSnv(1/2) AAS
(*
ある政党に100人の議員がいる。
何人が裏金議員であるには何の情報もないため
0〜100人である確率は同じと家庭する。
即ち、0人である確率も99人である確率も1/101とする。
無作為に10人を選んで調べたところ9人が裏金議員であった。
100人中の裏金議員の数の期待値と95%信頼区間を算出せよ。
*)

n100=100;
n10=10;
n9=9;
(* P[9|m] *)
p9m[m_] := Binomial[m,n9] Binomial[n100-m,n10-n9]/Binomial[100,10]
P9m=Table[p9m[m],{m,0,100}];
(* P[m|9] *)
pm9[m_] := p9m[m]/(n100+1) / Total[P9m];
auc=Total@Table[pm9[m],{m,0,n100}];
pdf[m_]:=pm9[m]/auc
Sum[x*pdf[x],{x,0,n100}]

Table[pdf[x],{x,1,100}] // ListPlot
Plot[pdf[x],{x,0,100}]

p=Table[pdf[x],{x,1,100}];
ps=ReverseSort[p];
Boole[#<0.95]& /@ Accumulate[ps] // Total
i=Reverse[Ordering[p]][[1;;34]];
{Min[i],Max[i]}
p[[i]] // Total // N
j=Reverse[Ordering[p]][[1;;35]];
{Min[j],Max[j]}
p[[j]] // Total // N
490
(1): 2024/12/30(月)10:41:19.52 ID:dmM3LvbP(1/2) AAS
>>482
自分の問題すら碌に解けないチンパンジーだったみたい
793: 04/18(金)12:53:56.52 ID:XpMQ9r6R(1) AAS
# Required package
library(HDInterval)

# Function to estimate alpha and beta of a Beta distribution
# from given HPI [L, U] and mean m
estimate_beta_params_from_HPI <- function(L, U, m, conf = 0.95, verbose = TRUE) {
# Initial guesses for alpha and beta
alpha0 <- m * 10
beta0 <- (1 - m) * 10

# Objective function: minimize error between estimated HPI/mean and given values
objective_fn <- function(par) {
a <- par[1]
b <- par[2]
if (a <= 0 || b <= 0) return(Inf)
hpi <- hdi(qbeta, shape1 = a, shape2 = b, credMass = conf)
est_mean <- a / (a + b)
hpi_error <- (hpi[1] - L)^2 + (hpi[2] - U)^2
mean_error <- (est_mean - m)^2
return(hpi_error + mean_error * 10) # Penalize deviation in mean
}

# Optimization
res <- optim(c(alpha0, beta0), objective_fn, method = "L-BFGS-B",
lower = c(0.001, 0.001))

alpha_hat <- res$par[1]
beta_hat <- res$par[2]

# Validate result
estimated_mean <- alpha_hat / (alpha_hat + beta_hat)
estimated_hpi <- hdi(qbeta, shape1 = alpha_hat, shape2 = beta_hat, credMass = conf)

if (verbose) {
cat("---- Result ----\n")
cat(sprintf("Estimated alpha: %.4f\n", alpha_hat))
cat(sprintf("Estimated beta : %.4f\n", beta_hat))
cat(sprintf("→ Mean : %.4f (target: %.4f)\n", estimated_mean, m))
cat(sprintf("→ %.0f%% HPI : [%.4f, %.4f] (target: [%.4f, %.4f])\n",
conf * 100, estimated_hpi[1], estimated_hpi[2], L, U))
}

return(list(alpha = alpha_hat,
beta = beta_hat,
mean = estimated_mean,
hpi = estimated_hpi))
}

# --- Example usage ---

# Suppose we are given:
# - Mean = 0.6
# - 95% HPI = [0.45, 0.75]
result <- estimate_beta_params_from_HPI(L = 0.45, U = 0.75, m = 0.6)
802: 04/29(火)21:05:19.52 ID:pY4WJf3b(4/4) AAS
options(warn = -1)

library(RcppAlgos)
N=50
alpha=0.01
cm=comboGeneral(0:N,3,repetition=FALSE)
f=\(x,Yates=FALSE){
n=rep(N,3)
pc=chisq.test(rbind(x,n-x),correct=Yates)$p.value
pps=as.vector(pairwise.prop.test(x,n,correct=Yates,
p.adj="bon")$p.value)
minp=min(pps,na.rm=TRUE)
# pf>0.05 & minp<0.05
c(pc,minp)
}
f(c(18,25,33))

"
re=t(apply(cm,1,f))
ans=cm[apply(re,1,function(x) x[1]>alpha & x[2]<alpha),]
head(ans);tail(ans)
mid=round(nrow(ans)/2)
ans[(mid-3):(mid+3),]
ansp=t(apply(ans,1,f))
head(ansp) ; tail(ansp)
P_all=ansp[,1]
P_pair=ansp[,2]
plot(P_all,P_pair,pch=16,byt='l')
hist(P_all)
hist(P_pair)

summary(P_all)
summary(P_pair)
"
912
(1): 06/22(日)11:13:13.52 ID:lVTJ2xwJ(1) AAS
>909の計算ができないようなFランの方は投稿をご遠慮ください。
935
(2): 06/22(日)17:17:38.52 ID:2CFzB4x4(3/3) AAS
>>934
何故出題スレを使わないのですか?
前次1-
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ

ぬこの手 ぬこTOP 0.142s