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

332: 2024/11/21(木)18:36:44.68 ID:Ci8ztJhi(1) AAS
尿瓶ジジイって論破されて発狂してそれもまた論破されてダンマリ決め込んでまた復活の繰り返しだな
555: 01/12(日)10:55:46.68 ID:qiFin7nw(1) AAS
【臨床応用問題】
下記のデータから適合する分布を選びそのパラメータを算出せよ。
画像リンク


算出例

AICやBICで判定すると非負量を定義域にする分布ではWeibull分布が最良だった。
そのパラメータは
shape scale
6.404264 1.551445
インフルエンザの潜伏期は形状母数k=2.0,尺度母数θ=1.0のガンマ分布(青色)に従うとする。
画像リンク


【臨床応用問題】
発熱外来では呼吸器症状を呈するインフルエンザと消化器症状を呈するノロウイルス感染に二分されたとする。
発熱外来で働く職員が同時に両方のウイルスに感染したときに同じ日に呼吸器症状と消化器症状が出現する確率を求めよ。

library(fitdistrplus)
set.seed(2025)
noro=c(
runif(2,0,24),
runif(2,25,28),
runif(16,29,32),
runif(16,33,36),
runif(14,37,40),
runif(2,41,44),
runif(5,45,48)
)/24
fit=fitdist(noro,'weibull') ; fit
gofstat(fit)
plot(fit)
hist(noro,freq=F,main="",col=4,breaks = 'scott')
fit$estimate
curve(dweibull(x,shape=fit$estimate[1],scale=fit$estimate[2]),add=TRUE,lwd=2)
par=fit$estimate ; par

Noro=rweibull(k,shape=par[1],scale=par[2])
plotPost(Noro,freq=FALSE,main='Norovirus',col=7)
curve(dweibull(x,shape=fit$estimate[1],scale=fit$estimate[2]),add=TRUE)

Flu=rgamma(k,shape=2,scale=1)
par(mfrow=c(3,1))
plotPost(Flu,col=4)
plotPost(Noro,col=2)
plotPost(Flu-Noro,col=7,compVal = 0)
mean(abs(Flu-Noro) < 1)
556: 01/13(月)05:38:55.68 ID:cjaPfdCl(1) AAS
画像リンク

609
(2): 01/23(木)14:37:17.68 ID:S3e4bqGA(1) AAS
m=j=4種類, k=5人,
1人ごとの確率は p_i=0.1i={0.1, 0.2, 0.3, 0.4}
として、期待値の式を整理し
Wolfram Alphaに入力するとこうなる

外部リンク:www.wolframalpha.com

期待値の計算結果は 約51.685
…同じ問題の式を前にも書き込んだ気がする

次は中央値が知りたい、ということは
シミュレーションの結果と照合したいのかな
同じ式をそのまま使うと、計算量が
さらに大きくなりそう
866: 06/05(木)13:25:27.68 ID:tGlaBVfa(1) AAS
> stancode(fit)
// generated with brms 2.22.0
functions {
/* compute monotonic effects
* Args:
* scale: a simplex parameter
* i: index to sum over the simplex
* Returns:
* a scalar between 0 and rows(scale)
*/
real mo(vector scale, int i) {
if (i == 0) {
return 0;
} else {
return rows(scale) * sum(scale[1:i]);
}
}
}
data {
int<lower=1> N; // total number of observations
array[N] int Y; // response variable
int<lower=1> K; // number of population-level effects
matrix[N, K] X; // population-level design matrix
int<lower=1> Kc; // number of population-level effects after centering
int<lower=1> Ksp; // number of special effects terms
int<lower=1> Imo; // number of monotonic variables
array[Imo] int<lower=1> Jmo; // length of simplexes
array[N] int Xmo_1; // monotonic variable
vector[Jmo[1]] con_simo_1; // prior concentration of monotonic simplex
int prior_only; // should the likelihood be ignored?
}
transformed data {
matrix[N, Kc] Xc; // centered version of X without an intercept
vector[Kc] means_X; // column means of X before centering
for (i in 2:K) {
means_X[i - 1] = mean(X[, i]);
Xc[, i - 1] = X[, i] - means_X[i - 1];
}
}
parameters {
vector[Kc] b; // regression coefficients
real Intercept; // temporary intercept for centered predictors
simplex[Jmo[1]] simo_1; // monotonic simplex
vector[Ksp] bsp; // special effects coefficients
}
transformed parameters {
real lprior = 0; // prior contributions to the log posterior
lprior += normal_lpdf(b[1] | 0.15, 0.3);
lprior += normal_lpdf(b[2] | 0.08, 0.3);
lprior += normal_lpdf(b[3] | 0.8, 0.3);
lprior += normal_lpdf(b[4] | 0.5, 0.3);
lprior += normal_lpdf(Intercept | -4, 2);
lprior += dirichlet_lpdf(simo_1 | con_simo_1);
lprior += normal_lpdf(bsp[1] | -0.5, 0.3);
}
model {
// likelihood including constants
if (!prior_only) {
// initialize linear predictor term
vector[N] mu = rep_vector(0.0, N);
mu += Intercept;
for (n in 1:N) {
// add more terms to the linear predictor
mu[n] += (bsp[1]) * mo(simo_1, Xmo_1[n]);
}
target += bernoulli_logit_glm_lpmf(Y | Xc, mu, b);
}
// priors including constants
target += lprior;
}
generated quantities {
// actual population-level intercept
real b_Intercept = Intercept - dot_product(means_X, b);
}
931
(1): 06/22(日)16:10:21.68 ID:AY7cZjkg(7/10) AAS
>>930
そこまで非常識ではありませんよ
傑作質問が解かれないことに悲しみを覚えているだけです
前次1-
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ

ぬこの手 ぬこTOP 0.035s