高校数学の質問スレ(医者・東大卒専用) Part438 (899レス)
高校数学の質問スレ(医者・東大卒専用) Part438 http://rio2016.5ch.net/test/read.cgi/math/1723152147/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
レス栞
847: 132人目の素数さん [sage] 2025/05/25(日) 04:22:37.55 ID:P4nhnL8B # dbeta(L,a,b) == dbbeta(U,a,b) # Solve[L^(a-1)(1-L)^(b-1)==U^(a-1)(1-U)^(b-1), b] L=1/7 U=1/5 credMass = 0.95 f = function(a) 1 + ((a - 1) * log(U / L)) / log((1 - L) / (1 - U)) g = function(a) pbeta(U,a,f(a)) - pbeta(L,a,f(a)) - credMass (re=uniroot(g,c(1,1e5))) a=re$root b=f(a) c(a,b) curve(g(x),1,1.5*a,bty="l") ; abline(h=0,lty=3) a/(a+b) # mean (a-1)/(a-1+b-1) # mode library(LearnBayes) beta.select(list(x=1/7,p=0.025),list(x=1/5,p=0.975)) http://rio2016.5ch.net/test/read.cgi/math/1723152147/847
849: 132人目の素数さん [sage] 2025/05/25(日) 06:42:27.34 ID:P4nhnL8B >>847 このプロトタイプをAIに与えて描画機能やコメントをつけてもらった。 beta.parameter <- function(lower, upper, credMass = 0.95, verbose = FALSE) { # Helper function to convert decimal numbers to fraction strings using MASS::fractions fractionStr <- function(x) { as.character(MASS::fractions(x)) } # Function to compute beta parameter (beta) based on alpha, # derived from the condition on the shape of the distribution between lower and upper f <- function(alpha) { 1 + ((alpha - 1) * log(upper / lower)) / log((1 - lower) / (1 - upper)) } # Root-finding function: difference between desired credible mass # and the Beta CDF probability between lower and upper with parameters (alpha, f(alpha)) g <- function(alpha) { pbeta(upper, alpha, f(alpha)) - pbeta(lower, alpha, f(alpha)) - credMass } # Find the root of g(alpha) = 0 over the interval [1, 1e5] # to find the alpha value that satisfies the credible mass condition re <- uniroot(g, c(1, 1e5)) alpha <- re$root beta <- f(alpha) # Calculate the mean of the Beta distribution mean <- alpha / (alpha + beta) # Calculate the mode if defined (alpha > 1 and beta > 1), # otherwise set mode to NA as it is undefined mode <- if (alpha > 1 && beta > 1) { (alpha - 1) / (alpha + beta - 2) } else { NA } http://rio2016.5ch.net/test/read.cgi/math/1723152147/849
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
1.763s*