高校数学の質問スレ(医者・東大卒専用) Part438 (899レス)
高校数学の質問スレ(医者・東大卒専用) Part438 http://rio2016.5ch.net/test/read.cgi/math/1723152147/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
798: 132人目の素数さん [sage] 2025/04/29(火) 10:05:00.96 ID:pY4WJf3b alphaResult = FindRoot[ CDF[BetaDistribution[{x, 5*x}], 1/5] - CDF[BetaDistribution[{x, 5*x}], 1/7] == 0.95, {x, 15} (* 初期値を設定 *) ]; alpha = x /. alphaResult; beta = 5 * alpha; fp[ones_] := CDF[BetaDistribution[{alpha + ones, beta}], 1/7] + (1 - CDF[BetaDistribution[{alpha + ones, beta}], 1/5]); ones = 1; Until[fp[ones] >= 0.5, ones++ ]; Print[ones] http://rio2016.5ch.net/test/read.cgi/math/1723152147/798
799: 132人目の素数さん [sage] 2025/04/29(火) 10:38:26.36 ID:pY4WJf3b questtion="良品サイコロは1の目の出る確率の95%信頼区間が[1/7,1/5]に収まるサイコロと定義する。それ以外はFランサイコロと呼ぶ。 チンパンフェチが発狂してサイコロを齧ってしまった。 このサイコロが良品のままかFランかを調べたい。 (1)2回投げたらどちらも1の目がでたときこのサイコロがFランである確率を求めよ。 (2)最初から何回1の目が続いてでたらFランである確率が0.5を超えるか? 計算に必要な条件は適宜決定してよい。 " alpha=uniroot(function(x) pbeta(1/5,x,5*x)-pbeta(1/7,x,5*x) - 0.95,c(1,500))$root beta=5*alpha fp=\(ones) pbeta(1/7,alpha+ones,beta) + pbeta(1/5,alpha+ones,beta,lower=FALSE) fp(2) ones=1 while(fp(ones)<0.5) ones=ones+1 ones http://rio2016.5ch.net/test/read.cgi/math/1723152147/799
800: 132人目の素数さん [sage] 2025/04/29(火) 18:09:40.80 ID:pY4WJf3b library(RcppAlgos) library(fmsb) library(matrixStats) N <- 50 # Generate all combinations cm <- comboGeneral(0:N, 3, repetition = FALSE) # Pre-allocate n_vec <- rep(N, 3) success <- cm failure <- matrix(n_vec, nrow = nrow(cm), ncol = 3, byrow = TRUE) - cm # Modified fast Fisher function - correct implementation fast_fisher <- function(success, failure) { # Initialize p-value matrix pvals <- matrix(NA_real_, nrow = nrow(success), ncol = 3) # Perform pairwise comparisons for (i in 1:nrow(success)) { # 1 vs 2 pvals[i,1] <- fisher.test(matrix(c(success[i,1], failure[i,1], success[i,2], failure[i,2]), nrow = 2))$p.value # 1 vs 3 pvals[i,2] <- fisher.test(matrix(c(success[i,1], failure[i,1], success[i,3], failure[i,3]), nrow = 2))$p.value # 2 vs 3 pvals[i,3] <- fisher.test(matrix(c(success[i,2], failure[i,2], success[i,3], failure[i,3]), nrow = 2))$p.value } # Bonferroni adjustment pmin(pvals * 3, 1) # Cap at 1 after adjustment } # Run with timing system.time({ # Overall Fisher tests overall_p <- apply(cbind(success, failure), 1, function(x) { fisher.test(matrix(x, nrow = 2))$p.value }) # Pairwise Fisher tests pairwise_p <- fast_fisher(success, failure) min_pairwise_p <- rowMins(pairwise_p, na.rm = TRUE) # Filter condition keep <- overall_p > 0.05 & min_pairwise_p < 0.05 result <- cm[keep, ] }) # Print first few results head(result) nrow(result) # Number of qualifying combinations http://rio2016.5ch.net/test/read.cgi/math/1723152147/800
802: 132人目の素数さん [sage] 2025/04/29(火) 21:05:19.52 ID:pY4WJf3b 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) " http://rio2016.5ch.net/test/read.cgi/math/1723152147/802
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
1.437s*