2ch勢いランキング アーカイブ

臨床統計もおもしろいですよ、その2


卵の名無しさん [sage] 2018/10/30(火) 22:19:26.32:kXLKssbE
 
 内科認定医受験の最低限の知識、
 製薬会社の示してくる臨床データ、
 論文の考察、
 論文を書くときの正当性、
 というのが、臨床統計の今までの目的の大きい部分でしたが、
 
 AI=機械学習の基本も、結局は統計学と確率に支配されます。
 そういう雑多な話をするスレです。
 
※前スレ
臨床統計もおもしろいですよ、その1
ttps://egg.2ch.net/test/read.cgi/hosp/1493809494/
卵の名無しさん [sage] 2018/10/30(火) 22:49:12.69:kXLKssbE
dec2n n = concat . (map show) . reverse . sub
where sub 0 = []
sub num = mod num n : sub (div num n)
main = do
let n=7
let num=10^68 - 7
putStrLn $ dec2n n num


231610455425461524013603062230536506126223530530201410405365413161511216632624602
卵の名無しさん [sage] 2018/10/30(火) 23:17:28.53:kXLKssbE
dec2nw <- function(num, N, digit = 4){
r=num%%N
q=num%/%N
while(q > 0 | digit > 1){
r=append(q%%N,r)
q=q%/%N
digit=digit-1
}
return(r)
}
n=dec2nw(10**16-7,36)
n
cat(c(0:9,letters[1:26])[n+1])
卵の名無しさん [sage] 2018/10/31(水) 01:52:25.64:naQxCFH6
人格障害者の精神科医 古根高
ttp://egg.2ch.net/test/read.cgi/hosp/1497760609/

最悪の精神科医 古根高
ttp://potato.2ch.net/test/read.cgi/hosp/1439931587/
過去ログだがブラウザで読める

病的な虚言癖と妄想癖の精神科医 古根高の病名を診断するスレ
ttps://egg.5ch.net/test/read.cgi/hosp/1529634250/
卵の名無しさん [sage] 2018/10/31(水) 10:21:03.69:sRjms2eC
def binomial(n,r):
from math import factorial as f
return f(n)//f(r)//f(n-r) if r>=0 and n-r>=0 else 0

def nloc(m,n,k,l):
q,r = divmod(n*k+l,m)
return (n-q)*(m-k)+q-1-l + ((k-r) if r > k else 0)

def nwin(m,n,c):
return sum(binomial(nloc(m,n,k,l),c-1) for k in range(m) for l in range(n) if k*(n-1)<l*(m-1))


nloc = function(m,n,k,l){
q=(n*k+l)%/%m
r=(n*k+l)%%m
(n-q)*(m-k)+q-1-l + max(k-r,0)
}

nwin = function(m,n,k){
for(k in 0:(m-1)){
for(l in 0:(n-1)){
if(k*(n-1<l*(m-1))
卵の名無しさん [sage] 2018/10/31(水) 11:53:59.80:bPxngJ5R
nloc = function(m,n,k,l){
q=(n*k+l)%/%m
r=(n*k+l)%%m
(n-q)*(m-k)+q-1-l + ifelse(r>k,k-r,0)
}


nwin = function(m,n,c){
re=NULL
for(k in 0:(m-1)){
for(l in 0:(n-1)){
if(k*(n-1)<l*(m-1)){
re=append(re,choose(nloc(m,n,k,l),c-1))
}
}
}
sum(re)
}

nwin(3,4,2)
nwin(5,6,15)
卵の名無しさん [sage] 2018/10/31(水) 11:54:52.81:bPxngJ5R
pythonからRを経てHaskellに移植の予定。
卵の名無しさん [sage] 2018/10/31(水) 14:43:51.58:qgJ05S6D

import System.Environment
import Data.List
import Data.List.Split

choose (n,r) = product[1..n] `div` product[1..n-r] `div` product[1..r]

nloc m n k l = do
let q = div (n*k+l) m
r = mod (n*k+l) m
in (n-q)*(m-k) + q-1-l + if r>k then k-r else 0

nwin m n c = sum[choose ((nloc m n k l), c-1) | k<-[0..m-1], l<-[0..n-1], k*(n-1) < l*(m-1)]

mwin m n c = sum[choose ((nloc n m k l), c-1) | k<-[0..n-1], l<-[0..m-1], k*(m-1) < l*(n-1)]

draw m n c = choose(m*n,c) - nwin m n c - mwin n m c

main = do
argList <- getArgs -- m : 縦マス(短軸) n : 横マス(長軸) k : 宝の数
let m = read (argList !! 0)
n = read (argList !! 1)
k = read (argList !! 2)
putStrLn $ "p1st = " ++ show(mwin m n k) ++ ", q1st = " ++ show(nwin m n k) ++ ", draw = " ++ show(draw m n k)
卵の名無しさん [sage] 2018/10/31(水) 15:15:25.46:qgJ05S6D
import System.Environment

choose (n,r) = product[1..n] `div` product[1..n-r] `div` product[1..r]

nloc m n k l = do
let q = div (n*k+l) m
r = mod (n*k+l) m
in (n-q)*(m-k) + q-1-l + if r>k then k-r else 0

nwin m n c = sum[choose ((nloc m n k l), c-1) | k<-[0..m-1], l<-[0..n-1], k*(n-1) < l*(m-1)]
mwin m n c = sum[choose ((nloc n m k l), c-1) | k<-[0..n-1], l<-[0..m-1], k*(m-1) < l*(n-1)]
draw m n c = choose(m*n,c) - nwin m n c - mwin n m c

main = do
argList <- getArgs -- m : 縦マス(短軸) n : 横マス(長軸) k : 宝の数
let m = read (argList !! 0)
n = read (argList !! 1)
k = read (argList !! 2)
putStrLn $ "p1st = " ++ show(mwin m n k) ++ ", q1st = " ++ show(nwin m n k) ++ ", draw = " ++ show(draw m n k)

こういうのも瞬時に計算してくれた、10×20部屋に宝箱100個

>takara 10 20 100
p1st = 15057759425309840160151925452579572328997602171271937639470,
q1st = 15057796557877993527038542474310161591275806044157319150135,
draw = 60432921540347294111327092128863840691952977587098698541050

不定長整数が扱えるHaskellならではだな。
Rの
> mpfr(nwin(10,20,100),100)
1 'mpfr' number of precision 100 bits
[1] 15057796557878080240302485923118087468235549676781988478976は誤答とわかる
卵の名無しさん [sage] 2018/10/31(水) 19:24:32.48:qgJ05S6D

drawにm nが入れ替わるバグが入ってたのを数学板で指摘されたので修正版

import System.Environment

choose (n,r) = product[1..n] `div` product[1..n-r] `div` product[1..r]

nloc m n k l = do
let q = div (n*k+l) m
r = mod (n*k+l) m
in (n-q)*(m-k) + q-1-l + if r>k then k-r else 0

nwin m n c = sum[choose ((nloc m n k l), c-1) | k<-[0..m-1], l<-[0..n-1], k*(n-1) < l*(m-1)]
mwin m n c = sum[choose ((nloc n m k l), c-1) | k<-[0..n-1], l<-[0..m-1], k*(m-1) < l*(n-1)]
draw m n c = choose(m*n,c) - nwin m n c - mwin m n c

main = do
argList <- getArgs -- m : 縦マス(短軸) n : 横マス(長軸) k : 宝の数
let m = read (argList !! 0)
n = read (argList !! 1)
k = read (argList !! 2)
putStrLn $ "p1st = " ++ show(mwin m n k) ++ ", q1st = " ++ show(nwin m n k) ++ ", draw = " ++ show(draw m n k)


10×20部屋に宝箱100個の計算も修正

p1st = 15057759425309840160151925452579572328997602171271937639470
q1st = 15057796557877993527038542474310161591275806044157319150135
draw = 60432958672915447478213709150594429954231181459984080051715
卵の名無しさん [sage] 2018/10/31(水) 21:01:13.96:qgJ05S6D
import System.Environment

choose (n,r) = product[1..n] `div` product[1..n-r] `div` product[1..r]

nloc m n k l = do
let q = div (n*k+l) m
r = mod (n*k+l) m
in (n-q)*(m-k) + q-1-l + if r>k then k-r else 0

nwin m n c = sum[choose ((nloc m n k l), c-1) | k<-[0..m-1], l<-[0..n-1], k*(n-1) < l*(m-1)]
mwin m n c = sum[choose ((nloc n m k l), c-1) | k<-[0..n-1], l<-[0..m-1], k*(m-1) < l*(n-1)]
draw m n c = choose(m*n,c) - nwin m n c - mwin m n c

takara m n k = do
putStrLn $ "短軸p1st = " ++ show(mwin m n k)
putStrLn $ "長軸q1st = " ++ show(nwin m n k)
putStrLn $ "同等draw = " ++ show(draw m n k)

main = do
argList <- getArgs -- m : 縦マス(短軸) n : 横マス(長軸) k : 宝の数
let m = read (argList !! 0)
n = read (argList !! 1)
k = read (argList !! 2)
putStrLn $ "p1st = " ++ show(mwin m n k) ++ ", q1st = " ++ show(nwin m n k) ++ ", draw = " ++ show(draw m n k)
卵の名無しさん [sage] 2018/10/31(水) 21:19:00.08:qgJ05S6D
nloc = function(m,n,k,l){
q=(n*k+l)%/%m
r=(n*k+l)%%m
(n-q)*(m-k)+q-1-l + ifelse(r>k,k-r,0)
}


nwin = function(m,n,c){ # m < n, log axis search wins
re=NULL
for(k in 0:(m-1)){
for(l in 0:(n-1)){
if(k*(n-1)<l*(m-1)){
re=append(re,choose(nloc(m,n,k,l),c-1))
}
}
}
sum(re)
}

longer <- function(m,k){
n=m+1
if(nwin(m,n,k) > nwin(n,m,k)) return(TRUE)
if(nwin(m,n,k) < nwin(n,m,k)) return(FALSE)
if(nwin(m,n,k) == nwin(n,m,k)) return(NULL)
}
卵の名無しさん [sage] 2018/10/31(水) 21:19:18.35:qgJ05S6D
pq1 <- function(m){
n=m+1
k=1
di=nwin(m,n,k) - nwin(n,m,k)
while(di<=0){
di=nwin(m,n,k) - nwin(n,m,k)
k=k+1
}
return(k-1)
}

pq <- function(m,Print=FALSE){ # > 0 long axis search wins
n=m+1
x=1:(m*n)
f = function(k) (nwin(m,n,k) - nwin(n,m,k))/choose(m*n,k)
y=sapply(x,f)
if(Print==TRUE){
plot(x,y,pch=19,bty='l',xlab='宝の数', ylab='確率差(長軸-短軸)')
abline(h=0,lty=3)
# print(y,quote=F)
}
z=which(y>0)
c(min(z),max(z))
}
pq(5,P=T)
(nw=cbind(0,sapply(2:20,pq)))
plot(1:20,(2:21)*(1:20),type='n',bty='l',xlab='m(短軸)',ylab='宝の数')
lines(1:20,(2:21)*(1:20),type='h',col='gray',lwd=2)
segments(1:20,nw[1,],1:20,nw[2,],lwd=4)
卵の名無しさん [sage] 2018/10/31(水) 21:50:35.78:AqNtLgjS
韓国「強制徴用は22万人で被害者が死亡しても遺族が訴訟可能」 元徴用工4人に損害賠償支払い判決
ttps://fate.5ch.net/test/read.cgi/seijinewsplus/1540976520/
卵の名無しさん [sage] 2018/10/31(水) 21:51:01.16:qgJ05S6D
先に1個めの宝を見つけるには短軸探索と長軸探索とどちらが有利かは宝の数によって変わるのでグラフにしてみた。
縦5横6のとき宝の数を1から30まで増やして長軸探索が先にみつける確率と短軸探索がさきにみつける確率の差を描いてみた。
ttp://i.imgur.com/7qGjOJX.png
縦5横6のときだと宝の数は9から21のときが長軸探索が有利となった。
短軸有利→長軸有利→同等となるようで、再逆転はないもよう。
縦m横m+1として長軸探索が有利になる宝の数の上限と下限を算出してみた。

[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20]
[1,] 0 2 2 6 9 13 17 23 29 36 43 52 61 71 82 93 105 118 132 147
[2,] 0 3 7 13 21 31 43 57 73 88 105 118 135 152 166 185 202 220 242 253

グラフにしてみた。
ttp://i.imgur.com/PiL9xyH.png
卵の名無しさん [sage] 2018/10/31(水) 21:57:13.38:qgJ05S6D
各人にとってのi 番目をどちらが先にみつけるかを計算してみた。

4×5マスに宝が5個あるとき

> treasures(4,5,5)
p1st q1st even
[1,] 1948 9680 3876
[2,] 5488 10016 0
[3,] 7752 7752 0
[4,] 10016 5488 0
[5,] 9680 1948 3876

1個め2個めは短軸方向探索のQが、4個め5個めは長軸方向探索のPが、先にみつける宝の配置の組み合わせが多い。3個めは同じ。

全体としてはイーブンだが、

勝者は1個めを先にみつけた方にするか、全部を先にみつけた方にするかで結果が変わる。

Rのコードはここに置いたので数値を変えて実行可能。

ttp://http://tpcg.io/Ph7TUQ
卵の名無しさん [sage] 2018/11/01(木) 10:16:30.80:ZkYkKASz
こういう解き方していると馬鹿になるなぁ、と
思いつつ便利なので使ってる。
Wolframで方程式を解かせて計算式をスクリプトに組み込むとかやってるな。結果は具体例でシミュレーションして確認。

a,b,cは自然数とする。
このとき、以下の不等式を満たす(a,b,c)が存在するような自然数Nの最大値を求めよ。
N≦a^2+b^2+c^2≦2018


Nの最大値は2018

顰蹙のプログラム解

Prelude> [(a,b,c)|a<-[1..45],b<-[a..45],c<-[b..45], a^2+b^2+c^2==2018]
[(1,9,44),(3,28,35),(5,12,43),(8,27,35),(9,16,41),(19,19,36),(20,23,33)]
卵の名無しさん [sage] 2018/11/01(木) 20:03:52.01:wy1a0s+b
aのb乗×cのd乗=abcd(abcd は4桁の整数)
abcdに当てはまる数字は?

[(a,b,c,d)|a<-[0..9],b<-[0..9],c<-[0..9],d<-[0..9],a^b*c^d==1000*a+100*b+10*c+d]
卵の名無しさん [sage] 2018/11/02(金) 00:51:03.46:CfCNBter
広島県の福山友愛病院で、
患者の病状と関係ない薬を大量に投与した。
しかも、意図的にです!



国は違うがドイツの場合

裁判所で開かれた公判で、患者100人を殺害した罪を認めた。これでこの事件は、同国で戦後最悪級の連続殺人事件となった。
起訴されたのは、ドイツ北部デルメンホルストとオルデンブルクの病院で看護師をしていたニルス・ヘーゲル受刑者(41)。
当時勤務していたドイツ北部の2つの病院で2000〜2005年にかけ、34〜96歳の患者を殺害したことを認めた。

同受刑者は自分の蘇生措置の腕を同僚に見せびらかす目的や、退屈しのぎの目的で、

↓↓↓↓↓
患者に処方されていない薬を投与していたとされる。
↑↑↑↑↑


ドイツの場合。まあ日本は日本だが・・・
大口の病院は看護士の単独犯だったわけで捕まったが・・・


福山友愛病院は・・・・・

ttp://https://youtu.be/BnHYCZqyZKY
卵の名無しさん [] 2018/11/02(金) 14:33:08.95:p4Bn/s/z
安倍総理も使っていて警察も使える医療大麻オイル
国連で今月解禁勧告が出されるという
解禁されれば憲法第98条によって大麻取締法が解禁され、店頭への商品陳列、広告表示等、医薬品としての処方ができるようになります
ttp://https://plaza.rakuten.co.jp/denkyupikaso/diary/201806090001/
卵の名無しさん [] 2018/11/02(金) 18:00:28.03:jIM3oIca
医療法人潤和会を麻薬取締法違反の罪で略式起訴
ttp://https://seiyakuonlinenews.com/news/42856/
卵の名無しさん [sage] 2018/11/02(金) 18:53:08.10:3zC36uTy
広島県の福山友愛病院で、
患者の病状と関係ない薬を大量に投与した。
しかも、意図的にです!


国は違うがドイツの場合

裁判所で開かれた公判で、患者100人を殺害した罪を認めた。これでこの事件は、同国で戦後最悪級の連続殺人事件となった。
起訴されたのは、ドイツ北部デルメンホルストとオルデンブルクの病院で看護師をしていたニルス・ヘーゲル受刑者(41)。
当時勤務していたドイツ北部の2つの病院で2000〜2005年にかけ、34〜96歳の患者を殺害したことを認めた。

同受刑者は自分の蘇生措置の腕を同僚に見せびらかす目的や、退屈しのぎの目的で、

↓↓↓↓↓
患者に処方されていない薬を投与していたとされる。
↑↑↑↑↑


ドイツの場合。まあ日本は日本だが・・・
大口の病院は看護士の単独犯だったわけで捕まったが・・・


福山友愛病院は・・・・・

ttp://https://youtu.be/BnHYCZqyZKY
卵の名無しさん [] 2018/11/02(金) 19:25:23.34:p4Bn/s/z
大麻取締法 22条の3に大麻を所持使用できるって書いてある

ttp://http://www.mmjp.or.jp/yokojyuu/low/low/low_041.html

こりゃ解禁しなきゃな!
卵の名無しさん [] 2018/11/03(土) 14:59:39.97:UnKdAdmR
国試浪人の事務員は裏口バカだから
レスするだけ無駄である
卵の名無しさん [sage] 2018/11/03(土) 15:10:46.97:Ipwzsvmc

算数問題の正解でも書いてればド底辺頭脳でも算数くらいできるんだなと見直したかもしれないのにねぇ。を

ジョーカーを含む53枚のトランプをシャッフルした後に順にめくっていってジョーカーがでたら終了とする。
ジョーカーがでるまでにめくったカードの数の総和の期待値はいくらか?

計算上の数理理論値は364になったのだが、確信がもてないので10万回のシミュレーションをやってみた。

シミュレーション
> summary(re)
Min. 1st Qu. Median Mean 3rd Qu. Max.
328.0 354.5 363.0 363.1 370.7 409.5

多分、あっていると思う。

数学板に投稿してみるかな。

おい、ド底辺。364になる計算式を書いてみ!
卵の名無しさん [sage] 2018/11/03(土) 15:28:40.93:Ipwzsvmc
図形の問題って5ch(2Ch)じゃあ、投稿しにくいんだよなぁ。

こんなのも投稿したけど、かなり面倒なので誰も検証もしないし、反証もしないよな。

ttps://rio2016.5ch.net/test/read.cgi/math/1532824890/90

そういう事情からか、確率や整数の問題はレスがつきやすいね。 まぁ、問題が理解できないとかはないからね

ところが医師板では統計・確率どころか算数ネタにもほとんどレスがこない。

ド底辺シリツの馬鹿だらけってことかなぁ?
卵の名無しさん [sage] 2018/11/03(土) 17:40:46.36:Ipwzsvmc

レスできるような基礎学力すらないのがシリツ医大卒だといっているだよ。

ジョーカーを含む53枚のトランプをシャッフルした後に順にめくっていってジョーカーがでたら終了とする。
ジョーカーがでるまでにめくったカードの数の総和の期待値はいくらか?

の計算式書いてみ!
卵の名無しさん [] 2018/11/03(土) 18:16:44.41:hHITaoGI
臨床統計の問題です

掲示板の1日のレス数の多さは
ネット依存症の重症度の指標となります

この指標を元に医師板の主だった依存症患者を
1日のレス数を数えてピックアップしましょう
卵の名無しさん [] 2018/11/03(土) 18:22:56.04:mjfFp3DY
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2018/11/03(土) 18:37:42.56:Ipwzsvmc

数値を書いたまともな問題も作れないの?

これ答えてみ!

専門医も開業医からも答がでてないから、頭のいいのを示すチャンスだぞ。

Take it or leave it !!


東京医大、本来合格者入学許可へ 今年の受験生50人
2018年10月25日 02時06分
 東京医科大=8月、東京都新宿区
 東京医科大が今年の入試で本来合格ラインを上回っていたのに、不正の影響で不合格となった受験生50人に対し、来年4月の入学を認める方針を固めたことが24日、関係者への取材で分かった。
昨年の本来合格者19人については、難しいとの意見が出ているもようだ。東京医大は50人のうち入学希望が多数に上った場合は、来年の一般入試の募集人員減も検討。
ttp://https://www.nishinippon.co.jp/sp/nnp/national/article/460101/
ttp://https://www.tokyo-med.ac.jp/med/enrollment.htmlによると
学年 第1学年 第2学年
在学者数 133 113

昨年入学者の留年者や退学者が0として、
大学が公式認定した裏口入学者が少なくとも今年は133人中50人、昨年が113人中19人ということになる。
裏口入学率の期待値、最頻値、およびその95%信頼区間を求めよ。
卵の名無しさん [sage] 2018/11/03(土) 18:38:49.80:Ipwzsvmc


俺が訳した普及の名投稿の英訳じゃん。

推敲歓迎!!
卵の名無しさん [sage] 2018/11/03(土) 18:39:30.27:Ipwzsvmc


俺が訳した不朽の名投稿の英訳じゃん。

推敲歓迎!!
卵の名無しさん [] 2018/11/04(日) 16:05:31.31:T2FQgr1k
臨床統計の問題です

掲示板の1日のレス数の多さは
ネット依存症の重症度の指標となります

この指標を元に医師板の主だった依存症患者を
1日のレス数を数えてピックアップしましょう
卵の名無しさん [sage] 2018/11/04(日) 17:50:26.40:YHVXN37A

頭の悪そうな投稿だなぁ。
これでも計算してみ!


ド底辺シリツ医大受験生の親に裏口コンサルタントが訪れて裏金額に2つの決め方を提示した。

A: 定額で2000万円
B: サイコロを1の目がでるまでふったときの出た目を合計した値 × 100万円、 例 2,1と続けば300万、6,5,1なら1200万円

問題(1) AとBではどちらが有利か?
問題(2) Bを選択した場合5000万円以上必要になる確率はくらか?


Bで裏金が1億円以上になる確率を計算すると(不定長さ整数が扱えるHaskellは便利だね)

2060507550845146798433160823128452341/202070319366191015160784900114134073344

になったが、これであっているか検算してくれ。
卵の名無しさん [sage] 2018/11/05(月) 00:16:38.96:NIiUrAnG
ここの国では硬貨は7種類流通しています
この7種類の硬貨を使って1円〜70円の70通りの支払いができます
ただし一度に使用できる硬貨は3枚以下(同じ硬貨複数使いは可)です
7種類の硬貨はそれぞれ何円だったのでしょうか?
卵の名無しさん [sage] 2018/11/05(月) 00:17:21.55:NIiUrAnG

Rでのブルートフォース解
is.1_70 <- function(x){
total=NULL
for(i in x){
for(j in x){
for(k in x){
ijk=i+j+k
if(!(ijk %in% total)) total=append(total,ijk)
}
}
}
all(1:70 %in% total)
}
(続く)
卵の名無しさん [sage] 2018/11/05(月) 00:18:36.57:NIiUrAnG

M=69
for(a in 0:M){
for(b in a:M){
for(c in b:M){
for(d in c:M){
for(e in d:M){
for(f in e:M){
for(g in f:M){
for(h in g:M){
y=c(a,b,c,d,e,f,g,h)
if(is.1_70(y)) print(y)
}
}
}
}
}
}
}
}
卵の名無しさん [sage] 2018/11/05(月) 00:19:36.93:NIiUrAnG
import Data.List
m = 69
sub x = do
let ijk = filter (<=70).nub $ sort [i+j+k| i<-x,j<-x,k<-x]
all (\y -> elem y ijk ) [0..70]
main = do
print $ [(b,c,d,e,f,g,h)| b<-[0..m],c<-[b..m],d<-[c..m],e<-[d..m],f<-[e..m],g<-[f..m],h<-[g..m],sub [0,b,c,d,e,f,g]]
卵の名無しさん [sage] 2018/11/05(月) 01:06:35.42:NIiUrAnG

import Data.List
m = 69
sub x = do -- ans=[1,4,5,15,18,27,34]
let ijk = filter (<=70).nub $ sort [i+j+k| i<-x,j<-x,k<-x]
all (\y -> elem y ijk ) [0..70]
main = do
print $ [(1,4,5,e,f,g,h)| e<-[0..m],f<-[e..m],g<-[f..m],h<-[g..m],sub [0,1,4,5,e,f,g,h]] -- 動作確認用
print $ [(b,c,d,e,f,g,h)| b<-[0..m],c<-[b..m],d<-[c..m],e<-[d..m],f<-[e..m],g<-[f..m],h<-[g..m],sub [0,b,c,d,e,f,g,h]]
卵の名無しさん [sage] 2018/11/05(月) 01:20:29.50:NIiUrAnG
数学板に超初心者のコードを書いたら、達人が高速化してくれた。
プログラム解を毛嫌いする向きもあるけど、初心者のコードを改善してくれたり、cに移植してくれたりする人の存在はとてもありがたい。

import Data.List

firstUnavailable x = let y = 0:x in head $([1..71] &#165;&#165;)$nub$sort$[a+b+c|a<-y,b<-y,c<-y]
next x = [n:x|n<-[head x+1..firstUnavailable x]]
xss = iterate (&#165;xs->concat [next x|x<-xs]) [[1]]
isGood x = let y = 0:x in (==70)$length $intersect [1..70]$nub$sort$[a+b+c|a<-y,b<-y,c<-y]

main = do
    print [x|x<-(xss !! 6),isGood x]
卵の名無しさん [sage] 2018/11/05(月) 01:22:05.62:NIiUrAnG

文字化けを修正

import Data.List

firstUnavailable x = let y = 0:x in head $([1..71] \\)$nub$sort$[a+b+c|a<-y,b<-y,c<-y]
next x = [n:x|n<-[head x+1..firstUnavailable x]]
xss = iterate (\xs->concat [next x|x<-xs]) [[1]]
isGood x = let y = 0:x in (==70)$length $intersect [1..70]$nub$sort$[a+b+c|a<-y,b<-y,c<-y]

main = do
print [x|x<-(xss !! 6),isGood x]
卵の名無しさん [sage] 2018/11/05(月) 01:34:19.46:NIiUrAnG

-- b=1は自明なので無駄な検索を削除

import Data.List
m = 69
sub x = do -- ans=[1,4,5,15,18,27,34]
let ijk = filter (<=70).nub $ sort [i+j+k| i<-x,j<-x,k<-x]
all (\y -> elem y ijk ) [0..70]
main = do
-- print $ [(1,4,5,e,f,g,h)| e<-[0..m],f<-[e..m],g<-[f..m],h<-[g..m],sub [0,1,4,5,e,f,g,h]] -- 動作確認用
print $ [(1,c,d,e,f,g,h)| c<-[1..m],d<-[c..m],e<-[d..m],f<-[e..m],g<-[f..m],h<-[g..m],sub [0,1,c,d,e,f,g,h]]
卵の名無しさん [sage] 2018/11/05(月) 07:20:27.85:NIiUrAnG
seqN <- function(N=100,K=5){
a=numeric(N)
for(i in 1:K) a[i]=2^(i-1)
for(i in K:(N-1)){
a[i+1]=0
for(j in 0:(K-1)){
a[i+1]=a[i+1]+a[i-j] # recursion formula
}
}

P0=numeric(N)
for(i in 1:N) P0[i]=a[i]/2^i # P0(n)=a(n)/2^n
P0

MP=matrix(rep(NA,N*K),ncol=K)
colnames(MP)=paste0('P',0:(K-1))
MP[,1]=P0
head(MP);tail(MP)
MP[1,2]=1/2
for(i in (K-2):K) MP[1,i]=0

for(k in 2:K){
for(i in 1:(N-1)) MP[i+1,k]=1/2*MP[i,k-1]
} # Pk(n+1)=1/2*P(k-1)(n)
ret=1-apply(MP,1,sum)

ret[N]
}
seqN(100,5)
seqN(1000,10)
卵の名無しさん [sage] 2018/11/05(月) 07:25:01.84:NIiUrAnG
## p : probability of head at coin flip
seqNp <- function(N=100,K=5,p=0.5){
if(N==K) return(p^K)
q=1-p
a=numeric(N) # a(n)=P0(n)/p^n , P0(n)=a(n)*p^n
for(i in 1:K) a[i]=q/p^i # P0(i)=q

for(i in K:(N-1)){ # recursive formula
a[i+1]=0
for(j in 0:(K-1)){
a[i+1]=(a[i+1]+a[i-j])
}
a[i+1]=q/p*a[i+1]
}

P0=numeric(N)
for(i in 1:N) P0[i]=a[i]*p^i # P0(n)=a(n)*p^n

MP=matrix(rep(NA,N*K),ncol=K)
colnames(MP)=paste0('P',0:(K-1))
MP[,'P0']=P0
head(MP);tail(MP)
MP[1,'P1']=p
for(i in (K-2):K) MP[1,i]=0

for(k in 2:K){
for(i in 1:(N-1)) MP[i+1,k]=p*MP[i,k-1]
} # Pk(n+1)=p*P(k-1)(n)
ret=1-apply(MP,1,sum)

ret[N]
}
卵の名無しさん [sage] 2018/11/05(月) 08:16:25.28:NIiUrAnG

# 検算用のシミュレーションスクリプト

seqn<-function(n=10,N=1000,p=0.5){ # N回のうちn回以上続けて表がでるか?
rn=rbinom(N,1,p) # N個の0 or 1を発生させる
count=0 # 1連続カウンター
for(i in 1:N){
if(rn[i] & count<n){ # rn[i]が1でn個続かなければ
count=count+1
}
else{
if(count==n) {return(TRUE)} # n個の1が見つかればTRUEを返して終了
else{
count=0
}
}
}
return(count==n)
}

mean(replicate(10^4,seqn(10,1000,p=0.5)))
卵の名無しさん [] 2018/11/05(月) 12:05:05.46:+OxX3fom
事務員さん
卵の名無しさん [sage] 2018/11/05(月) 12:14:01.00:RNxpU/sa
いくらド底辺シリツ医大卒の裏口バカでも
これくらいは計算できるだろ?

ド底辺シリツ医大の裏口入学調査委員会が
裏口入学は高々10%と報告したとする。

その結果の検証に100人を調査したら4人続けて裏口入学生であった、という。
この検証から裏口入学率が10%であるか否かを有意水準5%で検定せよ。
卵の名無しさん [sage] 2018/11/05(月) 14:38:27.92:Lykd2+5F

seqNp(100,4,1/10)
fm = function(m=5){
f100_m = function(p) seqNp(100,m,p)
pp=seq(0,1,len=100)
plot(pp,sapply(pp,f100_m),type='l',lwd=2)
abline(h=0.05,lty=3)
(p005=uniroot(function(x,u0=0.05) f100_m(x)-u0,c(0.001,1))$root)
}
卵の名無しさん [sage] 2018/11/05(月) 18:35:02.59:Lykd2+5F
トランプのA〜10の10枚とジョーカー1枚の
合計11枚が机の上に裏向きに置いてある。
ランダムに1枚ずつ引いていった場合の、得られた数字の総和の期待値を求めよ。
ただし、ジョーカーを引いた時点で終了するものとし、
Aは数字扱いではなく、最終的に得られた数字の総和が2倍になるものとする。

x=sample(11)
f <- function(x){
i=1
y=numeric()
while(x[i]!=11){
y[i]=x[i]
i=i+1
}
if(1 %in% y) return(2*(sum(y)-1))
else return(sum(y))
}
# simulation
re=replicate(1e6,f(sample(11)))
summary(re)
hist(re,col='lightblue',xlab='sum',main='')

# brute-force
library(gtools)
perm=permutations(11,11)
mean(apply(perm,1,f))
卵の名無しさん [sage] 2018/11/06(火) 12:33:08.79:jkx5i2bQ
n=3
r=8
str=paste(as.character(1:n),collapse='')
f <- function(x) grepl(str,paste(x,collapse=""))
# Brute-Force
library(gtools)
perm=permutations(n,r,rep=T)
sum(apply(perm,1,f))

# Monte-Carlo
k=100
re=replicate(k,sum(replicate(n^r,f(sample(n,r,rep=T)))))
summary(re)
卵の名無しさん [sage] 2018/11/06(火) 15:40:53.99:jkx5i2bQ
コインを1000回投げた。連続して表がでる確率が最も高いのは何回連続するときか?

seq_dice <- function(N=100,k=5,p=1/6){
P=numeric(N)
for(n in 1:(k-1)){
P[n]=0
}
P[k]=p^k
P[k+1]=p^k+(1-p)*p^k
for(n in (k+1):(N-1)){
P[n+1] = P[n] + (1-P[n-k])* p^(k+1)
}
return(P[N])
}
seq_dice()

seq_diceJ <- function(N=100,k=5,p=1/6){ # Just k sequence
seq_dice(N,k,p)-seq_dice(N,k+1,p)
}
seq_diceJ()

#
vsdJ=Vectorize(seq_diceJ)
NN=1000
kk=1:(NN/50)
p=0.5
y=vsdJ(NN,kk,0.5)
which.max(y)
plot(kk,y,bty='l',pch=19,xlab='sequence',ylab='probability')
卵の名無しさん [sage] 2018/11/06(火) 17:00:36.05:QApCAMmZ
f = function(x){
y=paste(x,collapse='')
str="1"
if(!grepl(str,y)) return(0)
else{
while(grepl(str,y)){
str=paste0(str,"1")
}
return(nchar(str)-1)
}
}

x=sample(0:1,20,rep=T) ; x ;f(x)
卵の名無しさん [sage] 2018/11/06(火) 19:54:04.82:jkx5i2bQ

# 有理数表示したかったのでPythonに移植

from fractions import Fraction

def seq_dice(N,k,p):
P=list()
for n in range(k-1):
P.append(0)
P.append(p**k)
P.append(p**k + (1-p)*p**k)
for n in range (k,N):
P.append(P[n]+(1-P[n-k])*p**(k+1))
return(P[N])

def seq_diceJ(N,k,p):
return(seq_dice(N,k,p) - seq_dice(N,k+1,p))


def dice(N,k,p):
print("Over " + str(k))
print(Fraction(seq_dice(N,k,p)))
print(" = " + str(seq_dice(N,k,p)))
print("Just " + str(k))
print(Fraction(seq_diceJ(N,k,p)))
print(" = " + str(seq_diceJ(N,k,p)))

dice(10000,5,1/6)

# ここで実行可能
# ttp://http://tpcg.io/rMOVCB
卵の名無しさん [sage] 2018/11/06(火) 20:01:05.33:jkx5i2bQ
seq_dice <- function(N=100,k=5,p=1/6){
P=numeric(N)
for(n in 1:(k-1)){
P[n]=0
}
P[k]=p^k
P[k+1]=p^k+(1-p)*p^k
for(n in (k+1):(N-1)){
P[n+1] = P[n] + (1-P[n-k])* p^(k+1)
}
return(P[N])
}
seq_dice()

seq_diceJ <- function(N=100,k=5,p=1/6){ # Just k sequence
seq_dice(N,k,p)-seq_dice(N,k+1,p)
}
seq_diceJ()

#
vsdJ=Vectorize(seq_diceJ)
NN=1e6
kk=1:30
p=0.5
y=vsdJ(NN,kk,0.5)
which.max(y) # 1e2:5 1e3:9 1e4:12 1e5:15 1e6:18
plot(kk,y,bty='l',pch=19,xlab='sequence',ylab='probability')
cbind(kk,y)
options(digits=22)
max(y)
卵の名無しさん [sage] 2018/11/06(火) 20:43:45.42:jkx5i2bQ

泥タブだと普通にみえるが、Win10のPCだと コードのインデントがなくなって左揃えされてしまうなぁ。
卵の名無しさん [sage] 2018/11/07(水) 00:33:21.67:J7bMbWmD
from fractions import Fraction

def dice126(N):
P=list()
for n in range(6):
P.append(1)
P.append(1-1/(6**6))
for n in range(7,N+1):
P.append(P[n-1]-P[n-6]/(6**6))
return(1-P[N])

def dice123456(N):
print(Fraction(dice126(N)))
print(" = " + str(dice126(N)))

dice123456(1000)
卵の名無しさん [] 2018/11/07(水) 03:24:42.61:5r6Cuw34
愛の妖精ぷりんてぃん
卵の名無しさん [sage] 2018/11/07(水) 20:28:13.57:J7bMbWmD
# simulation
mhs = function(x){ # maximum head sequence
y=paste(x,collapse='')
str="1"
if(!grepl(str,y)) return(0)
else{
while(grepl(str,y)){
str=paste0(str,"1")
}
return(nchar(str)-1)
}
}

(x=sample(0:1,100,rep=T)) ; mhs(x)

sim <- function(r=4,n=100,ps=c(9/10,1/10)){
mhs(sample(0:1,n,rep=T,prob=ps))>=r
}

mean(replicate(1e5,sim()))
卵の名無しさん [sage] 2018/11/07(水) 20:32:14.75:J7bMbWmD
ド底辺シリツ医大の裏口入学調査委員会が
裏口入学は高々10%と報告したとする。

その結果の検証に100人を調査したら4人続けて裏口入学生であった、という。
この検証から裏口入学率が10%であるか否かを有意水準1%で検定せよ。
卵の名無しさん [] 2018/11/07(水) 21:22:13.74:s+v4AjoX
グリーンねえさん
卵の名無しさん [sage] 2018/11/08(木) 07:40:30.60:PGJy3ILP

## p : probability of head at coin flip
seqNp <- function(N=100,K=5,p=0.5){
if(N==K) return(p^K)
q=1-p
a=numeric(N) # a(n)=P0(n)/p^n , P0(n)=a(n)*p^n
for(i in 1:K) a[i]=q/p^i # P0(i)=q

for(i in K:(N-1)){ # recursive formula
a[i+1]=0
for(j in 0:(K-1)){
a[i+1]=(a[i+1]+a[i-j])
}
a[i+1]=q/p*a[i+1]
}
P0=numeric(N)
for(i in 1:N) P0[i]=a[i]*p^i # P0(n)=a(n)*p^n

MP=matrix(rep(NA,N*K),ncol=K)
colnames(MP)=paste0('P',0:(K-1))
MP[,'P0']=P0
MP[1,'P1']=p
for(i in (K-2):K) MP[1,i]=0

for(k in 2:K){
for(i in 1:(N-1)) MP[i+1,k]=p*MP[i,k-1]
} # Pk(n+1)=p*P(k-1)(n)
ret=1-apply(MP,1,sum)

ret[N]
}
seqNp(N=100,K=4,p=0.1)
卵の名無しさん [sage] 2018/11/08(木) 15:06:24.25:PGJy3ILP
m=100
ps=[(a,b,c)|a<-[1..m],b<-[a..floor(m^2/2-1/2)],c<-[b..2*b],a^2+b^2==c^2]
ps !! 99

[(a,b,c)|a<-[1..m],b<-[a..floor(a^2/2-1/2)],c<-[b..floor(sqrt(a^2+b^2))],a^2+b^2==c^2]
[(a,b,c)|a<-[1..m],b<-[a..floor(m^2/2-1/2)],let c = sqrt(a^2+b^2), fromIntegral(floor(c))==c]
卵の名無しさん [sage] 2018/11/08(木) 15:07:58.80:PGJy3ILP
a^2+b^2=c^2を満たす3つの整数(a<b<c)
の組み合わせのうち(3,4,5)から数えて7番目は何になるかという問題がわかりません
答:(9,40,41)

応用問題:
a^2+b^2=c^2を満たす3つの整数(a<b<c)
の組み合わせのうち(3,4,5)から数えて100番目は何になるか 👀
Rock54: Caution(BBR-MD5:1341adc37120578f18dba9451e6c8c3b)
卵の名無しさん [sage] 2018/11/08(木) 16:45:02.14:PGJy3ILP
pitagoras <- function(A){
pita=NULL
for(a in 3:A){
B=floor(a^2/2-1/2)
for(b in a:B){
c=a^2+b^2
if(floor(sqrt(c)) == sqrt(c) ){
pita=rbind(pita,c(a,b,sqrt(c)))
}
}
}
colnames(pita)=letters[1:3]
return(pita)
}
pita=pitagoras(999)
saveRDS(pita,'pita999.rds')
pita[1,]
pita[7,]
pita[77,]
pita[777,]
pita[1000,]
tail(pita)
卵の名無しさん [] 2018/11/08(木) 20:38:27.74:cpzz/2HM
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.
卵の名無しさん [] 2018/11/08(木) 21:27:55.58:PVj0UwaU
Hutanari Ti〇po
卵の名無しさん [sage] 2018/11/08(木) 22:34:40.76:klK7Dgwj
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
最後にド底辺医大の三法則を掲げましょう。

1: It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
ド底辺シリツ医大が悪いのではない、本人の頭が悪いんだ。

2: The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
ド底辺シリツ医大卒は恥ずかしくて、学校名を皆さま言いません。

3: The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.
ド底辺特殊シリツ医大卒は裏口入学の負い目から裏口馬鹿を暴く人間を偽医者扱いしたがる。
卵の名無しさん [sage] 2018/11/08(木) 22:35:56.08:klK7Dgwj
第一法則の英文の意図的な文法誤謬を指摘してみ!
卵の名無しさん [] 2018/11/08(木) 22:37:45.15:JqNfxHqE
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2018/11/08(木) 23:56:13.79:5CXia8DJ
Raise the hem of the white coat with a white coat appearing naked.
Put half of Voltaren in the anus
Peel the white eyes while hitting your ass with a bang bang with both hands
Shouts that "Utopia is surprisingly surprised! It is surprisingly utopian!
Raise the buttocks and fire the Voltaren rocket to the patient.
卵の名無しさん [sage] 2018/11/09(金) 07:26:09.53:guOlTCed
(mean(replicate(1e4,any(diff(cumsum(rbinom(100,1,0.5)),5)==5))))
[1] 0.8089
>
> (mean(replicate(1e4,with(rle(rbinom(100,1,0.5)), max(lengths[which(values=
<rle(rbinom(100,1,0.5)), max(lengths[which(values== 1)])>=5))))
[1] 0.8117
>
卵の名無しさん [sage] 2018/11/09(金) 07:26:39.67:guOlTCed
(mean(replicate(1e4,any(diff(cumsum(rbinom(100,1,0.5)),5)==5))))
[1] 0.8089
>
> (mean(replicate(1e4,with(rle(rbinom(100,1,0.5)), max(lengths[which(values=
<rle(rbinom(100,1,0.5)), max(lengths[which(values==1)])>=5))))
[1] 0.8117
卵の名無しさん [sage] 2018/11/09(金) 07:27:42.12:guOlTCed
実行速度

system.time(mean(replicate(1e4,any(diff(cumsum(rbinom(100,1,0.5)),5)==5))))
user system elapsed
1.840 0.000 1.875
>
> system.time(mean(replicate(1e4,with(rle(rbinom(100,1,0.5)), max(lengths[wh
<e(1e4,with(rle(rbinom(100,1,0.5)), max(lengths[whi ch(values==1)])>=5))))
user system elapsed
4.440 0.000 4.631
卵の名無しさん [] 2018/11/09(金) 10:39:09.83:mj0MZvbh
「お゙ぉおォおん、お゙ぉおォおんにいぃひゃぁん、大漁らったのぉおお?」
「ぁあああ あぉぁあああ あぉ、大漁らったよお゛お゛お゛ぉ」 「ぁあああ あぉぁぁ゛ぁ゛ぁぁ゛ぁ゛ぁぁ゛ぁ゛ぁあああ あぉぁぁ゛ぁ゛しゅごいぃのぉおおょぉぉぅぃぃっよぉおお゙いぃぃいぃぃ!、、にゃ、にゃにが、、ハァハァにゃにが捕れたのぉおお?」
乳首を舌れやしゃしく舐めにゃがらオレは答えたのぉおお
「…鯛とか、、、ヒラメがいぃっぱいぃ捕れたよお゛お゛お゛ぉ」
セリフを聞き、オジサンはびくんびくんと身体をひきちゅらせたのぉおお
「はっ!はぁぁ゛ぁ゛ぁぁ゛ぁ゛ぁぁ゛ぁ゛ぁあああ あぉんっ!イ、イサキは?イサキは、と、取れたのぉおお??」
「ぁあああ あぉぁあああ あぉ。れかいぃイサキが取れたよお゛お゛お゛ぉ。今年一番のぉおお大漁ら。」
「大漁っ!!イサキぃぃ!!お゙ぉおォおんにいぃひゃぁんかっこいぃぃぃっよぉおお゙いぃぃぃっよぉおお゙ぃぃぃいぃ ぃくううううう!」
卵の名無しさん [] 2018/11/09(金) 13:39:50.75:wRJjRrMD
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.
卵の名無しさん [] 2018/11/09(金) 14:43:04.66:mj0MZvbh
"Oo, ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!
"Aaaaaaaaaaaa, big fish caught you" "Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "Sho-o-no-okoi, oh yeah, oh yeah, yeah, yeah, yeah, ha haa caught up for ha ha?"
I was licking a nipple and talking lolly I answered yao
"... Sea breams ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"
Listening to the dialogue, Ojisan pulls him body with his boyfriend
"Ha ha haaaaaaaaaaaaaaaaa, Isaki, Isaki, can you get it?"
"Aaaaaaaaaaaa ... I could have picked out a good Isaki, the biggest fishes of the year, this year."
"Big fishing !! Isaki !! Ooohoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo! "
卵の名無しさん [sage] 2018/11/09(金) 14:47:27.17:fYz4ML3G
import numpy as np
from fractions import Fraction
# ttp://http://tpcg.io/5xvZhU

def seqNp(N = 10,K = 5,p = 0.5):
if N == K: return p**K
q = 1-p
a = [0]*(N+1)
for i in range(1,K+1):
a[i] = q/(p**(i))

for i in range(K,N):
a[i+1] = 0
for j in range(0,K):
a[i+1] = a[i+1]+a[i-j]
a[i+1] = q/p*a[i+1]

P0=[0]*(N+1)
for i in range(1,N+1):
P0[i] = a[i]*p**i
del P0[0]
MP = np.zeros([K,N])
MP[0] = P0
MP[1][0] = p
for i in range(K-3,K):
MP[i][0] = 0
for k in range(1,K):
for i in range(0,N-1):
MP[k][i+1] = p*MP[k-1][i]
re = 1-np.sum(MP,axis=0)
print(Fraction(re[N-1]))
print(re[N-1])
卵の名無しさん [sage] 2018/11/09(金) 14:54:20.70:fYz4ML3G
RからPythonへの移植がようやく終わった。

確率が分数で表示されるようになった。

配列はRは1からPythonは0から始まるのでその調整に手間取った。

ttp://http://tpcg.io/5xvZhU
卵の名無しさん [sage] 2018/11/09(金) 16:24:27.33:fYz4ML3G
"""
Pk(n) (k=0,1,2,3,4)を途中、5連続して表が出ていなくて
最後のk回は連続して表が出ている確率とする。
P0(1)=P1(1)=1/2、P2(1)=P3(1)=P4(1)=0
Pk(n+1)=1/2*P(k-1)(n)
P0(n+1)=1/2*{P0(n)+P1(n)+P2(n)+P3(n)+P4(n)}
=1/2*{P0(n)+1/2*P0(n-1)+1/4*P0(n-2)+1/8*P0(n-3)+1/16*P0(n-4)}

P0(n)=a(n)/2^nとおいて
a(n+1)/2^(n+1)=1/2^(n+1){a(n)+a(n-1)+a(n-2)+a(n-3)+a(n-4)}
a(n+1)=a(n)+a(n-1)+a(n-2)+a(n-3)+a(n-4)
"""
卵の名無しさん [] 2018/11/09(金) 18:29:58.21:n6Zmr3Yp
We hold these truths to be self-evident, that all "uraguchi" are created retards,
That they are endowed by their creator with certain unalienable traits, that among these are sloth, mythomania, and the pursuit of imbecility.

That to rectify these traits, Bottom Medical Schools (BMS) are instituted for retards, deriving their just powers from what has been referred as the arbitrary donation of the parents of the rectified,
That whenever any form of the retards becomes destructive of rectification,
it is the right of the BMS to suspend or expel them, and to impose additional tuition laying its foundation on such principles and organizing its powers in such form, as to them shall seem most likely to effect the profit of BMS .
卵の名無しさん [sage] 2018/11/09(金) 19:01:24.31:fYz4ML3G
# 全体N個中当たりS個、1個ずつ籤を引いて当たったらやめる.
# r個めが初めて当たりであったときSの信頼区間を推定するシミュレーション。

atari <- function(N,r,k=1e3){ # k: simlation times
f <- function(S,n=N){which.max(sample(c(rep(1,S),rep(0,n-S))))}
vf=Vectorize(f)
sim=replicate(k,vf(1:(N-r)))
s=which(sim==r)%%(N-r)
s[which(s==0)]=N-r
hist(s,freq=T,col='skyblue')
print(quantile(s,c(.025,.05,.50,.95,.975)))
print(HDInterval::hdi(s))
}
atari(100,3)
卵の名無しさん [sage] 2018/11/09(金) 19:07:22.92:fYz4ML3G
pdf2hdi <- function(pdf,xMIN=0,xMAX=1,cred=0.95){
nxx=1001
xx=seq(xMIN,xMAX,length=nxx)
xx=xx[-nxx]
xx=xx[-1]
xmin=xx[1]
xmax=xx[nxx-2]
AUC=integrate(pdf,xmin,xmax)$value
PDF=function(x)pdf(x)/AUC
cdf <- function(x) integrate(PDF,xmin,x)$value
ICDF <- function(x) uniroot(function(y) cdf(y)-x,c(xmin,xmax))$root
hdi=HDInterval::hdi(ICDF,credMass=cred)
print(c(hdi[1],hdi[2]),digits=5)
invisible(ICDF)
}

# N個のクジでr個めで初めてあたった時のN個内の当たり数の推測
Atari <- function(N,r){
pmf <- function(x) ifelse(x>N-r+1,0,(1-x/N)^(r-1)*x/N) # dnbinom(r-1,1,x/N) ; dgeom(r-1,x/N)
# curve((1-x/N)^(r-1)*x/N,0,N)
AUC=integrate(pmf,0,N)$value
pdf <- function(x) pmf(x)/AUC
mode=optimise(pdf,c(0,N),maximum=TRUE)$maximum
mean=integrate(function(x)x*pdf(x),0,N)$value
cdf <- function(x) integrate(pdf,0,x)$value
median=uniroot(function(x)cdf(x)-0.5,c(0,N))$root
print(c(mode=mode,median=median,mean=mean))
pdf2hdi(pdf,0,N,cred=0.95)
}
Atari(100,3)
Atari(100,30)
卵の名無しさん [] 2018/11/09(金) 20:27:50.16:n7vPLA8Y
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.
卵の名無しさん [sage] 2018/11/09(金) 21:35:35.51:guOlTCed
次の課題はこれだな。

コインを100回投げて表が連続した最大数が10であったとき
このコインの表がでる確率の95%信頼区間はいくらか?
卵の名無しさん [] 2018/11/09(金) 21:59:40.95:WU3o6hYa
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2018/11/09(金) 22:34:31.28:fYz4ML3G

解析解は難しいけど、ニュートンラフソン法で数値解ならだせるな。

seq2pCI <- function(N,K){
vp=Vectorize(function(p)seqNp(N,K,p)-seqNp(N,K+1,p))
curve(vp(x),bty='l') ; abline(h=0.05,lty=3)
lwr=uniroot(function(x,u0=0.05) vp(x)-u0,c(0.01,0.7))$root
upr=uniroot(function(x,u0=0.05) vp(x)-u0,c(0.7,0.99))$root
c(lower=lwr,upper=upr)
}
seq2pCI(100,10)

> seq2pCI(100,10)
lower upper
0.5585921 0.8113441

英文コピペで荒らしているド底辺シリツ医大の裏口馬鹿には検算すらできんないだろうな。
卵の名無しさん [sage] 2018/11/09(金) 22:53:11.07:fYz4ML3G

呼び出す関数として、これが必要
seqNp <- function(N=100,K=5,p=0.5){
if(N==K) return(p^K)
q=1-p
a=numeric(N) # a(n)=P0(n)/p^n , P0(n)=a(n)*p^n
for(i in 1:K) a[i]=q/p^i # P0(i)=q
for(i in K:(N-1)){ # recursive formula
a[i+1]=0
for(j in 0:(K-1)){
a[i+1]=(a[i+1]+a[i-j])
}
a[i+1]=q/p*a[i+1]
}
P0=numeric(N)
for(i in 1:N) P0[i]=a[i]*p^i # P0(n)=a(n)*p^n
MP=matrix(rep(NA,N*K),ncol=K)
colnames(MP)=paste0('P',0:(K-1))
MP[,'P0']=P0
MP[1,'P1']=p
for(i in (K-2):K) MP[1,i]=0
for(k in 2:K){
for(i in 1:(N-1)) MP[i+1,k]=p*MP[i,k-1]
} # Pk(n+1)=p*P(k-1)(n)
ret=1-apply(MP,1,sum)
ret[N]
}

ここに上げておいた。
ttp://http://tpcg.io/kuNvWl
卵の名無しさん [] 2018/11/10(土) 00:19:47.42:Kp2aSERi
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.
卵の名無しさん [] 2018/11/10(土) 07:28:52.35:qmnilAbW
恵方巻き
卵の名無しさん [] 2018/11/10(土) 07:31:45.66:oGLeA9Hd
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2018/11/10(土) 07:35:47.21:Gl2x1zZV

optimizeを使ってurirootの区間を自動設定に改善。

seq2pCI <- function(N,K,alpha=0.05){
vp=Vectorize(function(p)seqNp(N,K,p)-seqNp(N,K+1,p))
curve(vp(x),lwd=2,bty='l') ; abline(h=0.05,lty=3)
peak=optimize(vp,c(0,1),maximum=TRUE)$maximum
lwr=uniroot(function(x,u0=alpha) vp(x)-u0,c(0.01,peak))$root
upr=uniroot(function(x,u0=alpha) vp(x)-u0,c(peak,0.99))$root
c(lower=lwr,upper=upr)
}
卵の名無しさん [] 2018/11/10(土) 08:01:47.11:qmnilAbW
aiueo700
卵の名無しさん [sage] 2018/11/10(土) 10:46:19.21:MTRtacln
最大連続数を増やしてグラフ化
seq2pCI <- function(N,K,alpha=0.05,Print=T){
vp=Vectorize(function(p)seqNp(N,K,p)-seqNp(N,K+1,p))
if(Print){curve(vp(x),lwd=2,bty='l',xlab='Pr[head]',ylab=paste('Pr[max',K,'-head repetition]'))
abline(h=alpha,lty=3)}
peak=optimize(vp,c(0,1),maximum=TRUE)$maximum
mean=integrate(function(x)x*vp(x),0,1)$value/integrate(function(x)vp(x),0,1)$value
lwr=uniroot(function(x,u0=alpha) vp(x)-u0,c(0.01,peak))$root
upr=uniroot(function(x,u0=alpha) vp(x)-u0,c(peak,0.99))$root
c(lower=lwr,mean=mean,mode=peak,upper=upr)
}
seq2pCI(100,4,0.05,T)


vs=Vectorize(function(K)seq2pCI(N=100,K,alpha=0.05,Print=F))
y=vs(2:23)
head(y)
plot(2:23,y['mean',],bty='l',pch=19)
points(2:23,y['mode',],bty='l')
卵の名無しさん [] 2018/11/10(土) 14:12:44.30:u8wDSGVd
幼稚な事務員
卵の名無しさん [] 2018/11/10(土) 14:24:33.17:u8wDSGVd
Look to the sky, way up on high
There in the night stars are now right.
Eons have passed: now then at last
Prison walls break, Old Ones awake!
They will return: mankind will learn
New kinds of fear when they are here.
They will reclaim all in their name;
Hopes turn to black when they come back.
Ignorant fools, mankind now rules
Where they ruled then: it's theirs again

Stars brightly burning, boiling and churning
Bode a returning season of doom

Scary scary scary scary solstice
Very very very scary solstice

Up from the sea, from underground
Down from the sky, they're all around
They will return: mankind will learn
New kinds of fear when they are here
卵の名無しさん [sage] 2018/11/10(土) 15:50:53.19:Aj6PTVhz

確率密度関数が左右対象でないから、
QuontileでなくHDI(Highest Density Interval)での95%信頼区間をpdfからcdfの逆関数を作って算出してみる。

# pdfからcdfの逆関数を作ってHDIを表示
pdf2hdi <- function(pdf,xMIN=0,xMAX=1,cred=0.95){
nxx=1001
xx=seq(xMIN,xMAX,length=nxx)
xx=xx[-nxx]
xx=xx[-1]
xmin=xx[1]
xmax=xx[nxx-2]
AUC=integrate(pdf,xmin,xmax)$value
PDF=function(x)pdf(x)/AUC
cdf <- function(x) integrate(PDF,xmin,x)$value
ICDF <- function(x) uniroot(function(y) cdf(y)-x,c(xmin,xmax))$root
hdi=HDInterval::hdi(ICDF,credMass=cred)
c(hdi[1],hdi[2])
}
卵の名無しさん [sage] 2018/11/10(土) 15:51:14.92:Aj6PTVhz
seqNp <- function(N=100,K=5,p=0.5){
if(N==K) return(p^K)
q=1-p
a=numeric(N) # a(n)=P0(n)/p^n , P0(n)=a(n)*p^n
for(i in 1:K) a[i]=q/p^i # P0(i)=q
for(i in K:(N-1)){ # recursive formula
a[i+1]=0
for(j in 0:(K-1)){
a[i+1]=(a[i+1]+a[i-j])
}
a[i+1]=q/p*a[i+1]
}
P0=numeric(N)
for(i in 1:N) P0[i]=a[i]*p^i # P0(n)=a(n)*p^n
MP=matrix(rep(NA,N*K),ncol=K)
colnames(MP)=paste0('P',0:(K-1))
MP[,'P0']=P0
MP[1,'P1']=p
for(i in (K-2):K) MP[1,i]=0
for(k in 2:K){
for(i in 1:(N-1)) MP[i+1,k]=p*MP[i,k-1]
} # Pk(n+1)=p*P(k-1)(n)
ret=1-apply(MP,1,sum)
ret[N]
}
卵の名無しさん [sage] 2018/11/10(土) 15:52:05.14:Aj6PTVhz
2つのサブルーチンを定義してから、

# N試行で最大K回連続成功→成功確率pの期待値、最頻値と95%HDI
# max K out of N-trial to probability & CI
mKoN2pCI <- function(N=100 , K=4 , conf.level=0.95){
pmf=Vectorize(function(p)seqNp(N,K,p)-seqNp(N,K+1,p))
mode=optimize(pmf,c(0,1),maximum=TRUE)$maximum
auc=integrate(pmf,0,1)$value
pdf=function(x) pmf(x)/auc
mean=integrate(function(x)x*pdf(x),0,1)$value
curve(pdf(x),lwd=3,bty='l',xlab='Pr[head]',ylab='density')
lu=pdf2hdi(pdf,cred=conf.level)
curve(pdf(x),lu[1],lu[2],type='h',col='lightblue',add=T)
re=c(lu[1],mean=mean,mode=mode,lu[2])
print(re,digits=4)
invisible(re)
}

> mKoN2pCI(100,4)
lower mean mode upper
0.1747676 0.3692810 0.3728936 0.5604309

> seq2pCI(100,4,0.05,T)
lower mean mode upper
0.1662099 0.3692810 0.3728936 0.5685943

当然ながら、HDIの方が信頼区間幅が小さいのがみてとれる。
卵の名無しさん [sage] 2018/11/10(土) 15:59:25.71:Aj6PTVhz
とりあえず>84のプログラムは完成。
卵の名無しさん [sage] 2018/11/10(土) 18:18:24.26:eRQ4an/O
95%クオンタイルでの算出

# N試行で最大K回連続成功→成功確率pの期待値、最頻値と95% Quantile
# max K out of N-trial to probability & CIq
mKoN2pCIq <- function(N=100 , K=4 , alpha=0.05){
pmf=Vectorize(function(p)seqNp(N,K,p)-seqNp(N,K+1,p))
mode=optimize(pmf,c(0,1),maximum=TRUE)$maximum
auc=integrate(pmf,0,1)$value
pdf=function(x) pmf(x)/auc
curve(pdf(x),bty='l')
mean=integrate(function(x)x*pdf(x),0,1)$value
cdf=function(x) MASS::area(pdf,0,x)
vcdf=Vectorize(cdf)
lwr=uniroot(function(x)vcdf(x)-alpha/2,c(0,mode))$root
upr=uniroot(function(x)vcdf(x)-(1-alpha/2),c(mode,1))$root
c(lower=lwr,mean=mean,mode=mode,upper=upr)
}


> mKoN2pCI(100,4)[c(1,4)]
lower upper
0.1747676 0.5604309
> mKoN2pCIq(100,4)[c(1,4)]
lower upper
0.1748351 0.5605172

あまり、差はないなぁ。
卵の名無しさん [sage] 2018/11/10(土) 18:48:10.97:eRQ4an/O
# pdfからcdfの逆関数を作ってhdiを表示させて逆関数を返す
# 両端での演算を回避 ∫[0,1]は∫[1/nxxx,1-1/nxx]で計算
pdf2hdi <- function(pdf,xMIN=0,xMAX=1,cred=0.95,Print=TRUE,nxx=1001){
xx=seq(xMIN,xMAX,length=nxx)
xx=xx[-nxx]
xx=xx[-1]
xmin=xx[1]
xmax=xx[nxx-2]
AUC=integrate(pdf,xmin,xmax)$value
PDF=function(x)pdf(x)/AUC
cdf <- function(x) integrate(PDF,xmin,x)$value
ICDF <- function(x) uniroot(function(y) cdf(y)-x,c(xmin,xmax))$root
hdi=HDInterval::hdi(ICDF,credMass=cred)
print(c(hdi[1],hdi[2]),digits=5)
if(Print){
par(mfrow=c(3,1))
plot(xx,sapply(xx,PDF),main='pdf',type='h',xlab='x',ylab='Density',col='lightgreen')
legend('top',bty='n',legend=paste('HDI:',round(hdi,3)))
plot(xx,sapply(xx,cdf),main='cdf',type='h',xlab='x',ylab='Probability',col='lightblue')
pp=seq(0,1,length=nxx)
pp=pp[-nxx]
pp=pp[-1]
plot(pp,sapply(pp,ICDF),type='l',xlab='p',ylab='x',main='ICDF')
par(mfrow=c(1,1))
}
invisible(ICDF)
}

確率密度関数を正弦波とか円周にしても計算できるはず。
卵の名無しさん [] 2018/11/10(土) 21:22:19.55:BbEZ9aeT
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2018/11/10(土) 21:35:01.58:eRQ4an/O
ド底辺シリツ裏口調査団が100人を順次調査した。
裏口判明人数をそのまま公表はヤバすぎる結果であったため、
連続して裏口がみつかった最大数は4人であったとだけ公表した。
公表結果が正しいとして裏口入学人数の期待値、最頻値、及び95%信頼区間を述べよ。

期待値37人、最頻値37人 95%信頼区間17人〜56人

> mKoN2pCI(100,4) # one minute plz
lower mean mode upper
0.1747676 0.3692810 0.3728936 0.5604309

> (mean=integrate(function(x)x*pdf(x),0,1)$value)
[1] 0.369281
> (var=integrate(function(x)(x-mean)^2*pdf(x),0,1)$value)
[1] 0.009878284
> (sd=sqrt(var))
[1] 0.09938955

正規分布で十分近似
> c(lower=qnorm(0.025,mean,sd),upper=qnorm(0.975,mean,sd))
lower upper
0.1744810 0.5640809

与えられた数字は100と4だけなんだよなぁ。
まあ、連続最大数という条件があるから計算できたのだが。

4と100から、平均値と標準偏差がもっと簡単に導出できれば正規分布近似計算できるのだが
まあ、プログラムが組めたから正規分布近似計算する必要はないな。
卵の名無しさん [sage] 2018/11/10(土) 21:36:25.04:eRQ4an/O

原文はこれな。

私は昭和の時代に大学受験したけど、昔は今よりも差別感が凄く、慶応以外の私立医は特殊民のための特殊学校というイメージで開業医のバカ息子以外は誰も受験しようとすらしなかった。
常識的に考えて、数千万という法外な金を払って、しかも同業者からも患者からもバカだの裏口だのと散々罵られるのをわかって好き好んで私立医に行く同級生は一人もいませんでした。
本人には面と向かっては言わないけれど、俺くらいの年代の人間は、おそらくは8−9割は私立卒を今でも「何偉そうなこと抜かしてるんだ、この裏口バカが」と心の底で軽蔑し、嘲笑しているよ。当の本人には面と向かっては絶対にそんなことは言わないけどね。
卵の名無しさん [] 2018/11/10(土) 21:48:48.87:0/hxM8VF
作 牧村みき
卵の名無しさん [sage] 2018/11/10(土) 22:53:57.75:eRQ4an/O
開脚率の期待値を計算してみた。

ゆるゆる女子大生の開脚率期待値:r人目で初めて開脚
r=3
Ex.yuru <- function(r){
integrate(function(x)x*(1-x)^(r-1)*x,0,1)$value/integrate(function(x)(1-x)^(r-1)*x,0,1)$value
}
Ex.yuru(r)
2/(r+2)

がばがば女子大生の開脚率期待値:N人中z人開脚
N=9
z=3
Ex.gaba <- function(N,z){
integrate(function(x) x*choose(N,z)*x^z*(1-x)^(N-z),0,1)$value/integrate(function(x)choose(N,z)*x^z*(1-x)^(N-z),0,1)$value
}
Ex.gaba(9,3)
(z+1)/(N+2)
卵の名無しさん [sage] 2018/11/10(土) 22:58:20.05:eRQ4an/O
n=60:100
pmf=choose(60-1,5-1)/choose(n,5) #Pr(max=60|n)
pdf=pmf/sum (pmf)
sum( n*pdf) #E(n)

plot(n,cumsum(pdf))
abline(h=0.95,lty=3)


plot(n,cumsum(pdf),xlim=c(75,100),ylim=c(0.75,1),type='h')
abline(h=c(0.80,0.90,0.95),lty=3)

累積質量関数をグラフにすると
ttp://imagizer.imageshack.com/img924/9020/nxNiAP.jpg
卵の名無しさん [] 2018/11/11(日) 04:47:59.95:3fp/Z1Bf
NNN臨時放送
卵の名無しさん [] 2018/11/11(日) 08:25:49.13:8Ef5Z4Y6
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2018/11/11(日) 08:58:08.11:g+y24FcC
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.
卵の名無しさん [sage] 2018/11/11(日) 11:04:24.83:RT24eksu
東京医大、本来合格者入学許可へ 今年の受験生50人

2018年10月25日 02時06分
 東京医科大=8月、東京都新宿区
 東京医科大が今年の入試で本来合格ラインを上回っていたのに、不正の影響で不合格となった受験生50人に対し、来年4月の入学を認める方針を固めたことが24日、関係者への取材で分かった。
昨年の本来合格者19人については、難しいとの意見が出ているもようだ。東京医大は50人のうち入学希望が多数に上った場合は、来年の一般入試の募集人員減も検討。

ttp://https://www.nishinippon.co.jp/sp/nnp/national/article/460101/

ttp://https://www.tokyo-med.ac.jp/med/enrollment.htmlによると

学年 第1学年 第2学年

在学者数 133 113

昨年入学者の留年者や退学者が0として、

大学が公式認定した裏口入学者が少なくとも今年は133人中50人、昨年が113人中19人ということになる。

裏口入学率の期待値、最頻値、およびその95%信頼区間を求めよ。
卵の名無しさん [sage] 2018/11/11(日) 11:06:42.03:RT24eksu

これで求めた確率分布を事前分布として
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.1822 0.2624 0.2813 0.2821 0.3013 0.4312
library(rjags)
y=c(50,19)
N=c(133,113)
Ntotal=length(y)
a=0.5
b=0.5
dataList=list(y=y,N=N,Ntotal=Ntotal,a=a,b=b)
# JAGS model
modelString ="
model{
for(i in 1:Ntotal){
y[i] ~ dbin(theta,N[i])
}
theta ~ dbeta(a,b)
}
"
writeLines(modelString,'TEMPmodel.txt')
jagsModel=jags.model('TEMPmodel.txt',data=dataList)
codaSamples=coda.samples(jagsModel,var=c('theta'),n.iter=20000,na.rm=TRUE)
summary(codaSamples)
js=as.vector(as.matrix(codaSamples))
x11() ; BEST::plotPost(js,xlab="裏口確率")
x11() ; BEST::plotPost(js,showMode = TRUE,xlab="裏口確率")
この問題をやってみよう。
ド底辺シリツ裏口調査団が100人を順次調査した。
裏口判明人数をそのまま公表はヤバすぎる結果であったため、
連続して裏口がみつかった最大数は4人であったとだけ公表した。
公表結果が正しいとして裏口入学人数の期待値、最頻値、及び95%信頼区間を述べよ。
卵の名無しさん [sage] 2018/11/11(日) 11:07:30.56:RT24eksu
seqNp <- function(N=100,K=5,p=0.5){
if(p==0) return(0)
if(N==K) return(p^K)
q=1-p
a=numeric(N) # a(n)=P0(n)/p^n , P0(n)=a(n)*p^n
for(i in 1:K) a[i]=q/p^i # P0(i)=q

for(i in K:(N-1)){ # recursive formula
a[i+1]=0
for(j in 0:(K-1)){
a[i+1]=(a[i+1]+a[i-j])
}
a[i+1]=q/p*a[i+1]
}
P0=numeric(N)
for(i in 1:N) P0[i]=a[i]*p^i # P0(n)=a(n)*p^n

MP=matrix(rep(NA,N*K),ncol=K)
colnames(MP)=paste0('P',0:(K-1))
MP[,'P0']=P0
head(MP);tail(MP)
MP[1,'P1']=p
for(i in (K-2):K) MP[1,i]=0

for(k in 2:K){
for(i in 1:(N-1)) MP[i+1,k]=p*MP[i,k-1]
} # Pk(n+1)=p*P(k-1)(n)
ret=1-apply(MP,1,sum)

ret[N]
}
seqNpJ <- function(N,K,p) seqNp(N,K,p) - seqNp(N,K+1,p)
卵の名無しさん [sage] 2018/11/11(日) 11:08:29.37:RT24eksu
HDIofGrid = function( probMassVec , credMass=0.95 ) { # by Kruschke
sortedProbMass = sort( probMassVec , decreasing=TRUE )
HDIheightIdx = min( which( cumsum( sortedProbMass ) >= credMass ) )
HDIheight = sortedProbMass[ HDIheightIdx ]
HDImass = sum( probMassVec[ probMassVec >= HDIheight ] )
return( list( indices = which( probMassVec >= HDIheight ) ,
mass = HDImass , height = HDIheight ) )
}
卵の名無しさん [sage] 2018/11/11(日) 11:35:36.92:RT24eksu
pp=js
vsJ=Vectorize(function(p) seqNpJ(N=100,K=4,p))
y=vsJ(pp)
summary(y);quantile(y,prob=c(.025,.975))
plot(pp,y,col='navy',bty='l')
pp[which.max(y)]
max(y,na.rm=T)
HDInterval::hdi(y)
BEST::plotPost(y,xlab="裏口確率",col='pink')
BEST::plotPost(y,showMode = TRUE,xlab="裏口確率",col='pink')
卵の名無しさん [sage] 2018/11/11(日) 11:42:28.36:RT24eksu

> summary(y);quantile(y,prob=c(.025,.975))
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.06935 0.20684 0.24441 0.24325 0.28129 0.35319
2.5% 97.5%
0.1403402 0.3369101

> HDInterval::hdi(y)
lower upper
0.1477413 0.3422359

という結果になる。

>大学が公式認定した裏口入学者が少なくとも今年は133人中50人、昨年が113人中19人ということになる
これをχ二乗検定やフィッシャーテストすると

> prop.test(c(50,19),c(133,113))$p.value
[1] 0.0005145557
> Fisher.test(c(50,19),c(133,113))$p.value
[1] 0.0003432805

で今年と去年で裏口率が有意に異なることになるのだが、裏口入学者を除籍処分しないようなシリツ医大の発表は盲信できないね。
卵の名無しさん [sage] 2018/11/11(日) 13:44:05.86:RT24eksu
あるタクシー会社のタクシーには1から通し番号がふられている。
タクシー会社の規模から保有タクシー台数は100台以下とわかっている。
この会社のタクシーを5台みかけた。最大の番号が60であった。
この会社の保有するタクシー台数の期待値を分数で答えよ

数値は同じで問題をアレンジ。

あるど底辺シリツ医大の裏口入学者には背中に1から通し番号がふられている。
一学年の定員は100人である。
裏口入学5人の番号のうち最大の番号が60であった。
この学年の裏口入学者数の期待値を分数で答えよ。

小数だと71.48850431950537
卵の名無しさん [sage] 2018/11/11(日) 13:44:55.16:RT24eksu
import math
import numpy as np
from fractions import Fraction

def choose(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
found_car = 5
max_number = 60
max_car = 100
n = range(max_car - max_number + 1)
pmf=[0]*len(n)
max_case = choose(max_number-1,found_car-1)
for i in n:
pmf[i] = max_case / choose(i+max_number,found_car)
pdf=[0]*len(n)
for i in n:
pdf[i] = pmf[i]/sum(pmf)
prob=[0]*len(n)
for i in n:
prob[i] = (max_number+i)*pdf[i]
result=sum(prob)

print (Fraction(result))
print (result)
卵の名無しさん [sage] 2018/11/11(日) 13:45:47.68:RT24eksu
Rだと
found_car = 5
max_number = 60
max_car = 100
n=max_number:max_car
pmf=choose(max_number-1,found_car-1)/choose(n,found_car) # Pr(max=60|n)
pdf=pmf/sum (pmf)
sum(n*pdf) #E(n)
で済むが 分数では算出できず
卵の名無しさん [sage] 2018/11/11(日) 13:58:43.34:RT24eksu
95%信頼区間も1行追加ですむ。
> n=60:100
> pmf=choose(60-1,5-1)/choose(n,5)
> sum(n*pmf)/sum (pmf)
[1] 71.4885
> n[which(cumsum(pmf/sum(pmf))>0.95)]
[1] 93 94 95 96 97 98 99 100
卵の名無しさん [sage] 2018/11/11(日) 13:59:57.00:RT24eksu
> n=60:100
> pmf=choose(60-1,5-1)/choose(n,5)
> sum(n*pmf)/sum (pmf)
[1] 71.4885
> min(n[which(cumsum(pmf/sum(pmf))>0.95)])
[1] 93
卵の名無しさん [] 2018/11/11(日) 14:00:49.27:4SxoNh8o
いあいあ ふんぐるい むぐるうなふ くとぅるう るるいえ うがふなぐる ふたぐん
卵の名無しさん [sage] 2018/11/11(日) 14:11:25.14:RT24eksu
# Pythonに移植
import math
import numpy as np
from fractions import Fraction

def choose(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
found_car = 5
max_number = 60
max_car = 100
n = range(max_car - max_number + 1)
pmf=[0]*len(n)
max_case = choose(max_number-1,found_car-1)
for i in n:
pmf[i] = max_case / choose(i+max_number,found_car)
pdf=[0]*len(n)
for i in n:
pdf[i] = pmf[i]/sum(pmf)
prob=[0]*len(n)
for i in n:
prob[i] = (max_number+i)*pdf[i]
result=sum(prob)

print (Fraction(result))
print (result)

cdf = np.cumsum(pdf)
print (max_number + np.min(np.where(cdf>0.95)))
卵の名無しさん [sage] 2018/11/11(日) 14:12:42.99:RT24eksu
5030556272103101/70368744177664
71.48850431950537
93

結果は、同じだが分数計算が他の人の結果との照合に便利
卵の名無しさん [] 2018/11/11(日) 14:15:53.17:4SxoNh8o
エコエコアザラク エコエコザメラク
地獄のキュエーン
卵の名無しさん [] 2018/11/11(日) 14:21:08.06:4SxoNh8o
算数の問題です
円周率をサンスクリット語で暗唱せよ
卵の名無しさん [sage] 2018/11/11(日) 15:38:32.90:RT24eksu
コインを1000万回投げた。連続して表がでる確率が最も高いのは何回連続するときか?

最大値をとるときの確率は 
4456779119136417/18014398509481984
= 0.2474009396866937
となったがあっているか?

数字を0と1を書いて数を数えて割り算するだけ。
3010300桁の数の集計する単純作業だから、おまえにもできるだろ?
卵の名無しさん [sage] 2018/11/11(日) 16:09:19.43:RT24eksu

3010300桁の数はここにアップロードしてやったから早めにダウンロードして照合の桁数を間違えないようにしろよ。
9049で始まり、最後は9376で終わる数字。

ttp://http://fast-uploader.com/file/7097473535472/
卵の名無しさん [] 2018/11/11(日) 16:11:54.59:BgP7Mpr0
いやー、昨日のセカンドはやられました。はめられました。
第一ロッター・・・・・小カタメ少なめ 第二ロッター・・・・・小カタメ
第三ロッター・・・・・小カタメ麺半分 第四ロッター(俺)・・・大

見事デスロットです。今思うと前の三人、確信犯だったと思う。
知り合い同士みたいだったし(てかよく見る奴らw)、第三ロッターのメガネが俺の食券見た後、前二人とひそひそ喋ってた。
『あいつ、ロット乱しにして恥かかしてやらない?w』こんな会話してたんだろうな・・・
いつも大を相手にしてる俺に嫉妬してんだろうな。。陰険なやり方だよ。正々堂々と二郎で勝負しろよ。
青戸6丁目住民は超変態バカップルを許さまじ食糞協会長:宇野壽倫 [] 2018/11/11(日) 16:35:14.78:eesLUl6p
★★【盗聴盗撮犯罪者・井口千明(東京都葛飾区青戸6−23−17)の激白】★★

☆食糞ソムリエ・高添沼田の親父☆ &☆変態メス豚家畜・清水婆婆☆の超変態不倫バカップル
  東京都葛飾区青戸6−26−6        東京都葛飾区青戸6−23−19

盗聴盗撮つきまとい嫌がらせ犯罪者/食糞ソムリエ・高添沼田の親父の愛人変態メス豚家畜清水婆婆(青戸6−23−19)の
五十路後半強制脱糞
ttp://img.erogazou-pinkline.com/img/2169/scatology_anal_injection-2169-027.jpg


⊂⌒ヽ            γ⌒⊃
  \ \  彡 ⌒ ミ   / /
    \ \_<(゚)д(゚)>_./ /  食糞ソムリエ・高添沼田の親父どえーす 一家そろって低学歴どえーす 孫も例外なく阿呆どえーす
      \ \_∩_/ /    東京都葛飾区青戸6−26−6に住んどりマッスル
      /(  (::)(::)  )\    盗聴盗撮つきまとい嫌がらせの犯罪をしておりマッスル
    ⊂_/ ヽ_,*、_ノ \_⊃      くれぐれも警察に密告しないでくらはい お願いしまふ
 ̄][ ̄ ̄]            [ ̄ ̄][ ̄
 ̄ ̄][ ̄]            [ ̄][ ̄ ̄
 ̄][ ̄ ̄]            [ ̄ ̄][ ̄
 ̄ ̄][ ̄]            [ ̄][ ̄ ̄
 ̄][ ̄ ̄]            [ ̄ ̄][ ̄
"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~
卵の名無しさん [sage] 2018/11/11(日) 17:42:34.02:RT24eksu
# maximal sequential head probability at 10^8 coin flip
> y
[1] 2.2204460492503131e-16 2.2204460492503131e-16
[3] 8.8817841970012523e-16 1.5543122344752192e-15
[5] 3.5527136788005009e-15 6.8833827526759706e-15
[7] 1.4210854715202004e-14 2.8199664825478976e-14
[9] 5.6843418860808015e-14 1.1346479311669100e-13
[11] 2.2737367544323206e-13 4.5452530628153909e-13
[13] 9.0949470177292824e-13 1.8187673589409314e-12
[15] 3.6379788070917130e-12 7.2757355695785009e-12
[17] 1.4551915228366852e-11 2.9103608412128779e-11
[19] 5.8207660913467407e-11 1.1641509978232989e-10
[21] 6.6493359939245877e-06 2.5720460687386204e-03
[23] 4.8202266324911647e-02 1.7456547460031679e-01
[25] 2.4936031630254019e-01 2.1428293501123058e-01
[27] 1.4106434838399229e-01 8.1018980443629832e-02
[29] 4.3428433624081136e-02 2.2484450838189007e-02
卵の名無しさん [sage] 2018/11/11(日) 18:43:47.27:RT24eksu
#include <stdio.h>
#include<math.h>
#include<stdlib.h>
#define p 0.5


double flip(int N,double k){
double P[N];
int i;
for(i = 0; i < k-1; i++) {
P[i] = 0;
}
P[(int)k-1] = pow(p,k);
P[(int)k] = pow(p,k) + (1-p)*pow(p,k);
for(i = (int)k; i < N; i++){
P[i+1] = P[i] + (1-P[i-(int)k])*pow(p,(double)(k+1));
}
return P[N];
}

int main(int argc,char *argv[]){
int N = atoi(argv[1]);
double k = atof(argv[2]);
double PN =flip(N,k);
double PNJ = flip(N,k) - flip(N,k+1);
printf("Over %d heads at %d flips : %f\n", (int)k ,N ,PN);
printf("Just %d heads at %d flips : %f\n", (int)k ,N ,PNJ);
return 0;
}
卵の名無しさん [sage] 2018/11/11(日) 18:53:11.12:RT24eksu
gcc coin5.c -o coin5.exe -lm

C:\pleiades\workspace>gcc coin5.c -o coin5.exe -lm
gcc coin5.c -o coin5.exe -lm

C:\pleiades\workspace>coin5 100 5
coin5 100 5
Over 5 heads at 100 flips : 0.813343
Just 5 heads at 100 flips : 0.263523

C:\pleiades\workspace>coin5 1000 10
coin5 1000 10
Over 10 heads at 1000 flips : 0.385751
Just 10 heads at 1000 flips : 0.170128 👀
Rock54: Caution(BBR-MD5:1341adc37120578f18dba9451e6c8c3b)
卵の名無しさん [] 2018/11/11(日) 22:42:42.63:UCMkX/If
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2018/11/12(月) 00:48:13.50:G7wSOjAG
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2018/11/12(月) 02:39:48.77:+DPZ0e9S
臨床問題です
事務員のアスペ指数を計測せよ
卵の名無しさん [sage] 2018/11/12(月) 07:17:09.02:KUf7IfSV

前提が間違っているから
Zero Division Errorだね。

宿題まだか?
数を増やした次の問題が控えているぞ。
コインを1億回投げた。連続して表がでる確率が最も高いのは何回連続するときか?

その確率は
2246038053550679/9007199254740992
= 0.24936031612362342
な。

きちんと検算してから、臨床統計スレに書き込めよ。
卵の名無しさん [] 2018/11/12(月) 07:46:46.08:fhdQROV/
誰からも相手にされない ド底辺事務員
卵の名無しさん [sage] 2018/11/12(月) 08:13:57.33:KUf7IfSV

数学板ではきちんとしたレスが返ってくるのよ。
こんな感じでね。
ttps://rio2016.2ch.net/test/read.cgi/math/1501755792/551

他人のコード読むのは勉強になるね。
卵の名無しさん [sage] 2018/11/12(月) 13:48:23.85:Xm/n5tCK
この問題、俺にはプログラミング解が精いっぱい。
解析解出せる頭脳は尊敬するな。


N枚のコインを投げて表が連続する確率が最も大きい回数をsとする。
例:N=10でs=2、N=15でs=3
(1) N=777のときのsを述べよ。
(2)s=7となるNの範囲を述べよ。
卵の名無しさん [sage] 2018/11/12(月) 15:10:55.63:gzeh1x/+
library(rjags)
y=c(10,16,34,9,10,26)
N=rep(125,6)
Ntotal=length(y)
a=1
b=1
dataList=list(y=y,N=N,Ntotal=Ntotal,a=a,b=b)
# JAGS model
modelString ="
model{
for(i in 1:Ntotal){
y[i] ~ dbin(theta,N[i])
}
theta ~ dbeta(a,b)
}
"
卵の名無しさん [sage] 2018/11/12(月) 15:11:23.82:gzeh1x/+
writeLines(modelString,'TEMPmodel.txt')
jagsModel=jags.model('TEMPmodel.txt',data=dataList)
codaSamples=coda.samples(jagsModel,var=c('theta'),n.iter=20000,na.rm=TRUE)
summary(codaSamples)
js=as.vector(as.matrix(codaSamples))
BEST::plotPost(js,xlab="留年確率")
BEST::plotPost(js,showMode = TRUE,xlab="留年確率")
卵の名無しさん [sage] 2018/11/12(月) 15:12:31.12:gzeh1x/+
binom::binom.confint(sum(y),sum(N))
卵の名無しさん [sage] 2018/11/12(月) 16:56:10.68:gzeh1x/+

f <- function(Mmax,M=5,Nmax=100){
n=Mmax:Nmax
pmf=choose(Mmax-1,M-1)/choose(n,M)
pdf=pmf/sum (pmf)
mean=sum(n*pdf)
upr=n[which(cumsum(pdf)>0.95)[1]]
lwr=Mmax
c(lwr,mean,upr)
}
x=5:100
y=sapply(x,function(n) f(n)[2])
z=sapply(x,function(n) f(n)[3])
plot(x,y,pch=19)
points(x,z)
cbind(x,y,z)
卵の名無しさん [sage] 2018/11/12(月) 17:01:57.91:gzeh1x/+
f <- function(Mmax,M=5,Nmax=100){
n=Mmax:Nmax
pmf=choose(Mmax-1,M-1)/choose(n,M)
pdf=pmf/sum (pmf)
mean=sum(n*pdf)
upr=n[which(cumsum(pdf)>0.95)[1]]
lwr=Mmax
c(lwr,mean,upr)
}
x=5:100
y=sapply(x,function(n) f(n)[2])
z=sapply(x,function(n) f(n)[3])
plot(x,y,type='l',lws=2,bty='l')
segments(x,x,x,z)
#points(x,z)
cbind(x,y,z)
卵の名無しさん [sage] 2018/11/12(月) 19:51:10.36:UwZfq4Lo
"マラソン大会の選手に1から順番に番号の書かれたゼッケンをつける。
用意されたゼッケンN枚以下の参加であった。
無作為に抽出したM人のゼッケン番号の最大値はMmaxであった。
参加人数推定値の期待値とその95%信頼区間を求めよ"

解析解は簡単。

decken <- function(M, Mmax, N,conf.level=0.95){
if(Mmax < M) return(0)
n=Mmax:N
pmf=choose(Mmax-1,M-1)/choose(n,M)
pdf=pmf/sum (pmf)
mean=sum(n*pdf)
upr=n[which(cumsum(pdf)>conf.level)[1]]
lwr=Mmax
c(lower=lwr,mean=mean,upper=upr)
}
decken(M=5,Mmax=60,N=100)

これを検証するシミュレーションプログラムを作れ、というのが課題。
卵の名無しさん [sage] 2018/11/12(月) 20:57:04.94:UwZfq4Lo

処理速度は考えないでとりあえず、シミュレーションを作ってみた。

# simulation
M=5 ; Mmax=60 ; N=100
sub <- function(M,Mmax,N){
n=sample(Mmax:N,1) # n : 参加人数n
m.max=max(sample(n,M)) # m.max : n人からM人選んだ最大番号
if(m.max==Mmax) return(n)
}
sim <- function(){
n=sub(M,Mmax,N)
while(is.null(n)){
n=sub(M,Mmax,N) # 最大番号が一致するまで繰り返す
}
return(n)
}
runner=replicate(1e4,sim())

> runner=replicate(1e4,sim())
> summary(runner) ; hist(runner,freq=F,col="lightblue")
Min. 1st Qu. Median Mean 3rd Qu. Max.
60.00 63.00 68.00 71.43 77.00 100.00
> quantile(runner,prob=c(0,0.95))
0% 95%
60 93
> cat(names(table(runner)[which.max(table(runner))]))
60
> decken(M,Mmax,N)
lower mean upper
60.0000 71.4885 93.0000
ほぼ、近似しているのでどちらも正しいか、どちらも同じ原因で間違っているかだなwww
卵の名無しさん [sage] 2018/11/12(月) 21:48:58.46:UwZfq4Lo
最大値でなく平均値が与えられたときの参加人数の推定、

"マラソン大会の選手に1から順番に番号の書かれたゼッケンをつける。
用意されたゼッケンN枚以下の参加であった。
無作為に抽出したM人のゼッケン番号の平均値はMmeanであった。
参加人数推定値の期待値とその95%信頼区間を求めよ"

とすると解析解は俺の頭では無理だな。シミュレーションの方は少し修正するだけですむ。

# simulation by round(mean)
M=5 ; Mmean=60 ; N=100
sub <- function(M,Mmean,N){
n=sample(Mmean:N,1) # n : 参加人数n
m.mean=round(mean(sample(n,M))) # m.mean : n人からM人選んだ平均値を
if(m.mean==Mmean) return(n) # roundで整数化
}
sim <- function(){
n=sub(M,Mmean,N)
while(is.null(n)){
n=sub(M,Mmean,N) # 平均値が一致するまで繰り返す
}
return(n) # 一致時の参加人数を返す
}
runner=replicate(1e4,sim())
summary(runner) ; hist(runner,freq=F,col="lightblue")
quantile(runner,prob=c(0,0.95))
cat(names(table(runner)[which.max(table(runner))])) # 最頻値
卵の名無しさん [sage] 2018/11/12(月) 21:53:15.51:UwZfq4Lo
5人の平均が60なので推定参加人数は当然、増えた。
正しいかどうかよくわからんなぁ。
meanをmedianにすれば中央値での推定ができる。

> runner=replicate(1e4,sim())
> summary(runner) ; hist(runner,freq=F,col="lightblue")
Min. 1st Qu. Median Mean 3rd Qu. Max.
64.00 86.00 92.00 90.72 96.00 100.00
> quantile(runner,prob=c(0,0.95))
0% 95%
64 100
> cat(names(table(runner)[which.max(table(runner))])) # 最頻値
100
卵の名無しさん [] 2018/11/12(月) 22:54:15.54:3/93pSbh
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.
卵の名無しさん [] 2018/11/13(火) 08:24:34.99:kjupm458
このスレは事務員が日がな一日妄想を垂れ流し
見物人たちがそれを見てフルボッコにするスレである

事務員 とは?
同一者の別名として、薄汚いジジイ、国試浪人、統計野郎、自称医科歯科、がある
自称医科歯科卒、実際は九州の駅弁国立出身で、卒業後は実家の東京に帰り国試浪人となり23年間経過、家庭教師バイトなどを経て現在は事務員、とされている
本人は、勤務医でたまに開業医の手伝いと内視鏡バイト、専門医なし、と主張しているが、連日連夜の異常な書き込み数の多さからは、勤務医とは考え難く、彼の職業がたとえ何であったとしても、人としてド底辺なことは間違いがない
自ら事務員であると告白したこともある
ttps://egg.5ch.net/test/read.cgi/hosp/1531459372/108-109
が、事務員であることも疑わしい
実際はナマポかニートの可能性が高い
自分の主張に対して都合の悪い突込みが入ると、相手を私立医と決めつけて、さてはシリツだな、裏口バカ、というセリフでワンパターンに返すことが多い
国試問題を挙げて簡単だとほざいてますが、本番で通らなければお話になりません
いくらネットでわめいていても、医師国試の本番で通らなければお話になりません
大事なことなので2回言いました
卵の名無しさん [sage] 2018/11/13(火) 09:07:06.76:UTrDDuDZ

ちゃんと原文の日本語もつけろよ、ド底辺医大卒にもわかるように。

Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
最後にド底辺医大の三法則を掲げましょう。

1: It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
ド底辺シリツ医大が悪いのではない、本人の頭が悪いんだ。

2: The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
ド底辺シリツ医大卒は恥ずかしくて、学校名を皆さま言いません。

3: The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.
ド底辺特殊シリツ医大卒は裏口入学の負い目から裏口馬鹿を暴く人間を偽医者扱いしたがる。
卵の名無しさん [sage] 2018/11/13(火) 09:19:46.34:UTrDDuDZ
平均値を「四捨五入」するか、しないかを指定できるようにして
平均値が60であったときのサンプルの最大値の分布を示すシミュレーション

rm(list=ls())
M=5 ; m=60 ; n=100 ; round=TRUE
sub <- function(M,m,n){
s=sample(n,M)
rm=ifelse(round,round(mean(s)),mean(s))
if(rm==m) return(max(s))
}
sim= function(){
r=sub(M,m,n)
while(is.null(r)){
r=sub(M,m,n)
}
return(r)
}
round=F
re=replicate(1e3,sim())
summary(re) ; hist(re,freq=F,col="lightblue")
quantile(re,prob=c(0,0.95))
cat(names(table(re)[which.max(table(re))]),'\n')
卵の名無しさん [sage] 2018/11/13(火) 11:31:17.33:UTrDDuDZ
ド底辺シリツ医大のある学年にひとりずつ裏口入学登録証があることが判明したがその数は公表されていないとする。
ある裏口入学調査員が無作為に10枚選んで番号を記録して元に戻した。
別の裏口入学調査員が無作為に20枚選んで番号を記録してして元に戻した。
二人の調査官の記録した番号を照合すると3人分の番号が一致していた。
この情報からこの学年の裏口入学者数の95%信頼区間を求めよ。
卵の名無しさん [sage] 2018/11/13(火) 14:13:47.83:UTrDDuDZ
固有の番号の書かれたカードが何枚あり、
その枚数は1000枚以下であることはわかっているが、その数を推定したい。
調査員が無作為に10枚選んで番号を記録して元に戻した。
別の調査員が無作為に20枚選んで番号を記録した。
二人の調査員の記録した番号を照合すると3人分の番号が一致していた。
この情報からカード枚数の期待値と95%信頼区間を求めよ。
卵の名無しさん [] 2018/11/13(火) 14:58:33.48:EZEaUTrv
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.
卵の名無しさん [] 2018/11/13(火) 19:31:39.92:DHMhO4WL
二郎をすすりつつ裏口事務員をさわさわと触る
「お、おにいちゃん、大漁だった?」
「ああ、大漁だったよ」
「あぁぁぁあぁすごいいいぃいぃ!、、な、なにが、、ハァハァなにが捕れたの?」
焼豚を舌でやさしく舐めながら国試浪人は答えた
「…鯛とか、、、ヒラメがいっぱい捕れたよ」
セリフを聞き、オジサンはびくんびくんと身体をひきつらせた
「はっ!はぁぁぁあんっ!イ、イサキは?イサキは、と、取れたの??」
ド底辺事務員をしごく
「ああ。でかいイサキが取れたよ。今年一番の大漁だ。」
「大漁っ!!イサキぃぃ!!おにいちゃんかっこいいいいぃぃぃい ぃくううううう!」
卵の名無しさん [] 2018/11/13(火) 19:46:29.89:WZBh4CIg
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2018/11/13(火) 20:23:20.79:DHMhO4WL
While touching Uryuu, touch the Uraguchi Jimuin with Sawasawa
"O, Oh, were you a big catch?"
"Oh, it was a big catch."
"Ayaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
While tenderly licking the baked pig with a tongue, the country trier replied
"... Sea breams, ..., a lot of flounder was caught"
Listening to the dialogue, Ojisan hit the body with him busts
"Ha ha ha ha! Ah, Isaki? Isaki, could you take it?"
Draw base clerk
"Oh, I got a big isaki, it is the biggest fishery of the year."
"Big fishing !! Isaki !! Great buddies are okay!"
卵の名無しさん [] 2018/11/13(火) 22:51:51.61:UlWlhoup
ここは くるくるぱー アスペ 事務員が
ナゾナゾを出したり アプリ翻訳したインチキ英語で
自作自演したりするスレです
卵の名無しさん [sage] 2018/11/13(火) 23:30:56.92:fLfkvliu
>155の計算結果は最頻値と期待値が大幅に乖離するので
計算に自信が持てずシミュレーションとの合致でようやく納得。
数学板に貼ったら2時間で期待値のHaskellでの算出値のレスが来た。それで信頼区間も確信を持って計算できた。
確率密度はこんな感じなので期待値と最頻値がずれるわけだな。
ttp://i.imgur.com/paJnhr9.png
卵の名無しさん [sage] 2018/11/13(火) 23:40:50.36:fLfkvliu

>155の算出式書けばド底辺シリツ医大卒でも基礎学力があると示せるのに裏口馬鹿を実証してどうすんの?
Rのスクリプトすら読めない裏口バカなんだろ?
卵の名無しさん [] 2018/11/14(水) 00:11:47.97:kAqwthFw
Uryuu fell 23 times in the national exam
It is an amateur virgin who is also failing in marriage
To the Uraguchi of the spinning parpurin
He is getting turned on
F class clerks condenced raw kid juice
The smell of the Doteihen does not decrease
NnnnnHooOoooOoooooooo
卵の名無しさん [sage] 2018/11/14(水) 00:35:23.31:lTkyjX2F

各枚数の確率を一様分布に設定してのシミュレーション。
プログラミングより結果が出るのを待つ時間の方が長いし
PCのリソースが奪われる。
泥タブで5ch閲覧や投稿で時間潰し。

Nmin=g+s-x
sub <- function(){
n=sample(Nmin:Nmax,1)
a=sample(n,g)
b=sample(n,s)
if(sum(a %in% b)==x) return(n)
}
sim <- function(){
r=sub()
while(is.null(r)) r=sub()
return(r)
}

re=replicate(1e5,sim())
summary(re) ; hist(re,freq=F,col="lightblue",main='',xlab='N')
quantile(re,prob=c(0.025,0.95,0.975))
cat(names(table(re)[which.max(table(re))]))
HDInterval::hdi(re)
卵の名無しさん [] 2018/11/14(水) 02:35:34.04:n/IxbzB4
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2018/11/14(水) 08:49:20.67:PJxL6X2W
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.
卵の名無しさん [sage] 2018/11/14(水) 20:59:26.07:lTkyjX2F
医師国家試験にこういうの問題を出してシリツ医大の裏口馬鹿を排除すればいいのにね。

2人が自転車に乗って走っている。その速さの比は11:8である。この2人が周囲480mの円形の池の同じ地点から同時に同方向にスタートしてまわるとき、速い人は遅い人を4分ごとに追い越す。2人の毎分の速さを求めよ
卵の名無しさん [] 2018/11/14(水) 21:03:30.39:Q+EwHwPp
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2018/11/14(水) 21:26:14.73:zDUHf0ws
ド底辺事務員の今日のおかず

くいこみ戦隊ブルマちゃん
卵の名無しさん [] 2018/11/15(木) 08:47:29.19:MoyC03l0
Uryuu fell 23 times in the national exam
It is an amateur virgin who is also failing in marriage
To the Uraguchi of the spinning parpurin
He is getting turned on
F class clerks condenced raw kid juice
The smell of the Doteihen does not decrease
NnnnnHooOoooOoooooooo
卵の名無しさん [sage] 2018/11/15(木) 12:20:42.85:d0+yWFff
draft


pmf2hdi <- function(pmf,conf.level=0.95){ # unimodal
pdf=pmf/sum(pdf)
spdf=sort(pdf,decreasing=TRUE)
cdf=cumsum(spdf)
threshold=spdf[which(cdf>=conf.level)[1]]
idx=which(pdf>=threshold)
list(hdi=range(idx),confidence_level=sum(pdf[idx]))
}
卵の名無しさん [] 2018/11/15(木) 14:10:09.98:0BjfilY2
実際こんな職員が病院にいたら大変だね

以前に病院のパソコンにスマホつないで充電したり動画を見たりしている職員がいたが

この事務員も同レベルのカスなんだろうな
卵の名無しさん [sage] 2018/11/15(木) 18:50:09.51:u639IIxL
 ABC
 ACB
 BAC
 BCA
+CAB
--------
3123 
A,B,Cは?

Haskell
[(a,b,c)|a<-[1..9],b<-[1..9],c<-[1..9], (a+a+b+b+c)*100+(b+c+a+c+a)*10+(c+b+c+a+b)==3123]

C
#include <stdio.h>
int a,b,c;
int main() {
for(a=1;a<10;a++){
for(b=1;b<10;b++){
for(c=1;c<10;c++){
if((A+A+B+B+C)*100+(B+C+A+C+A)*10+(C+B+C+A+B)==3123){
printf("%d %d %d\n",a,b,c);
}
}
}
}
return 0;
}
卵の名無しさん [sage] 2018/11/15(木) 18:50:25.10:u639IIxL
Python
n = range(1,10)
for A in n:
for B in n:
for C in n:
if (A+A+B+B+C)*100+(B+C+A+C+A)*10+(C+B+C+A+B)==3123:
print( [A,B,C] )
R
n=1:9
N=c(100,10,1)
for(A in n){
for(B in n){
for(C in n){
if (sum((c(A,B,C)+c(A,C,B)+c(B,A,C)+c(B,C,A)+c(C,A,B))*N) == 3123)
print(c(A,B,C))
}
}
}
卵の名無しさん [sage] 2018/11/15(木) 18:52:29.96:u639IIxL

残念ながら、事務員じゃないのね。
こういうの書いているの俺な。

内視鏡検査について Part.2 [無断転載禁止](c)2ch.net
ttps://egg.5ch.net/test/read.cgi/hosp/1499746033/875">ttps://egg.5ch.net/test/read.cgi/hosp/1499746033/875

875 名前:卵の名無しさん[sage] 投稿日:2018/11/14(水) 20:29:50.55 ID:lTkyjX2F
卵の名無しさん [sage] 2018/11/15(木) 18:56:08.04:u639IIxL
手技の議論だけじゃなくて、こういう計算もできる。
せっかく、一般解がだせるようにプログラムまで組んだやったんだがなぁ。


【現役医師】専門医資格取得について、どうお考えですか? 第2章
ttps://egg.5ch.net/test/read.cgi/hosp/1539580796/69

69 名前:卵の名無しさん[sage] 投稿日:2018/10/23(火) 07:30:15.27 ID:RnIgsz+6
前スレで誰も正解出せなかった、
door to balloon timeが短縮するのに必要な計算問題を
解ける専門医いる?
(数値を変えても計算できるプログラムは前スレ参照、
プログラムを読めた専門医はいなかったらしくそれへのレスなし)

診療所から病院に患者を救急搬送する。
病院から医師搭乗の救急車が診療所に向かっており10時到着予定と連絡が入った。
患者の病態が悪化したら、診療所の普通車で病院に向かい救急車と出会ったら
救急車に患者を移して搬送し病院到着を急ぐという計画を立てた。
普通車から救急車への患者の乗り換えで10分余分に時間がかかる。
道路事情から救急車は病院から診療所への道は
平均時速60kmで、逆方向は平均時速45kmで定速走行する。診療所の普通車は信号待ちもあり平均時速30kmで定速走行する。

何時以降の病態悪化は診療所の車を使わずに救急車の到着を待つ方が病院に早く着くか?
卵の名無しさん [sage] 2018/11/15(木) 19:08:50.01:u639IIxL

配列の要素ごとの演算をしてくれるRが使い勝手がいいなぁ。
シミュレーターとして使うのは遅いけど。
卵の名無しさん [sage] 2018/11/15(木) 19:10:14.30:u639IIxL

カスとは
>167の答も出せない
おまえのことだよ。
卵の名無しさん [] 2018/11/15(木) 19:26:12.08:0BjfilY2
医師なら事務員というワードには反応しないよねW
卵の名無しさん [sage] 2018/11/15(木) 19:33:47.58:LT687Ilf

ド底辺シリツというのに反応する椰子はw
卵の名無しさん [sage] 2018/11/15(木) 19:37:22.84:LT687Ilf

ttps://egg.2ch.net/test/read.cgi/hosp/1499746033/875
とそれへのレスみて事務員だと思うならお前の頭は相当悪いぞ。
あぁ、ド底辺シリツ医大卒の裏口バカだよなぁ?
>167に即答してみ。裏口入学じゃなきゃできるだろ。
卵の名無しさん [sage] 2018/11/15(木) 20:01:27.27:u639IIxL

R固有の関数を使うと for loop なしで できないこともない。

> m = expand.grid(1:9,1:9,1:9)
> f = function(A,B,C) sum((c(A,B,C)+c(A,C,B)+c(B,A,C)+c(B,C,A)+c(C,A,B))*c(100,10,1)) == 3123
> m[mapply(f,m[,1],m[,2],m[,3]),]
Var1 Var2 Var3
624 3 7 8
卵の名無しさん [] 2018/11/15(木) 20:14:47.02:0BjfilY2
今日も事務員は発狂中

他のスレでは既読スルーされてて
誰も反応なんかしていないよねW






とか書くと
また自作自演しまくるんだろうなー
卵の名無しさん [sage] 2018/11/15(木) 20:33:45.90:LT687Ilf

あらら、>167に即答できないって相当頭が悪いぞ。
裏口入学??
卵の名無しさん [sage] 2018/11/15(木) 20:36:16.18:LT687Ilf
専門医スレで誰も正当できなかった>176の方に答えてくれてもいいぞ、国立卒ならこれくらいの四則演算はできるだろ?
卵の名無しさん [] 2018/11/15(木) 20:58:27.02:ziKbMPPq
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.
卵の名無しさん [sage] 2018/11/15(木) 22:03:57.30:u639IIxL
DRAFT

非対称分布をする離散量の95%Highest Density Intervalを算出する。

pmf2hdi <- function(pmf,conf.level=0.95){ # pmf 2 higest density interval indices
pdf=pmf/sum(pmf) # sum(pdf)==1
hist(pdf,breaks = length(pdf),ann=FALSE)
spdf=sort(pdf,decreasing=TRUE) # sort pdf from highest
cdf=cumsum(spdf) # culmutive probability
threshold=spdf[which(cdf>=conf.level)[1]]
# which(cdf>conf.level)[1] : cdf.index of 1st value when cdf > 0.95
# threshold : its corresponding spdf value
index=which(pdf>=threshold) # pdf.index whose value > threshold
clevel=sum(pdf[index]) # actual conf.level, a little bit greater than 0.95
n.index=length(index)
if(n.index==index[n.index]-index[1]+1){ # check if unimodal by its length
interval=c(index[1],index[n.index])
print(c(lower=pmf[index[1]],upper=pmf[index[n.index]])) # lower and upper when unimodal
}else{interval=index
}
list(indices=interval,actual.CI=clevel)
}
卵の名無しさん [sage] 2018/11/15(木) 22:05:46.83:u639IIxL

which deserves to be called a bona fide moron は何故、whoでなくて文法破格のwhichが用いられているか、その理由を述べてみ!
卵の名無しさん [sage] 2018/11/15(木) 22:20:49.26:u639IIxL

一応完成

pmf2hdi <- function(pmf,conf.level=0.95){ # pmf 2 higest density interval indices
pdf=pmf/sum(pmf) # sum(pdf)==1
hist(pdf,breaks=length(pdf),ann=FALSE)
spdf=sort(pdf,decreasing=TRUE) # sort pdf from highest
cdf=cumsum(spdf) # culmutive probability
threshold=spdf[which(cdf>=conf.level)[1]]
# which(cdf>conf.level)[1] : cdf.index of 1st value when cdf > 0.95
# threshold : its corresponding spdf value
index=which(pdf>=threshold) # pdf.index whose value > threshold
clevel=sum(pdf[index]) # actual conf.level, a little bit greater than 0.95
n.index=length(index)
if(n.index==index[n.index]-index[1]+1){ # check if unimodal by its length
interval=c(index[1],index[n.index]) # if unimodal print lower and upper limit
print(c(lower=pmf[index[1]],upper=pmf[index[n.index]]))
}else{interval=index
}
list(indices=interval,actual.CI=clevel)
}
pmf2hdi(dgamma(seq(0,1,length=201),2,3))
pmf2hdi(rhyper(500,m=56,n=70, k=45))
卵の名無しさん [sage] 2018/11/15(木) 22:51:18.47:u639IIxL
(1)
池の鯉を網で56匹すくいました。
すくった56匹に目印をつけ、池にもどしました。
次の日に鯉45匹をすくったところ、36匹に目印がついていました。
池の鯉はおよそ何匹ですか。

(2)
固有の番号の書かれたカードが何枚あり、
その枚数は1000枚以下であることはわかっているが、その数を推定したい。
調査員が無作為に10枚選んで番号を記録して元に戻した。
別の調査員が無作為に20枚選んで番号を記録した。
二人の調査員の記録した番号を照合すると3枚の番号が一致していた。
この情報からカード枚数の最頻値、期待値とその95%信頼区間を求めよ。


(1)の方は鯉の数の上限を10000匹にして期待値を求めても71程度でほとんど変動しないが
(2)の方は著しく変動する、合致枚数を8枚にすると殆ど変動しない。

再捕獲法での個体数推定の限界だな。
卵の名無しさん [sage] 2018/11/15(木) 23:19:30.11:u639IIxL
池の鯉を網で56匹すくいました。
すくった56匹に目印をつけ、池にもどしました。
次の日に鯉45匹をすくったところ、36匹に目印がついていました。
池の鯉はおよそ何匹ですか。

56*45/36=70で求まる70匹のとき36匹の目印が見つかる確率は?

137149850039891/562949953421312
0.2436270741410791

69匹のときの36匹の目印が見つかる確率も
137149850039891/562949953421312
0.2436270741410791

およそ何匹ですか、の記載は実に奥深い
pythonで確かめてみた。Rだと分数表示が無理:(

import math
from fractions import Fraction
def choose(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def dhyper(x,g,b,s):
return choose(g,x)*choose(b,s-x) / choose(g+b,s)
f69 = dhyper(36,56,69-56,45)
print (Fraction(f69))
print(f69)
f70 = dhyper(36,56,70-56,45)
print (Fraction(f70))
print (f70)
卵の名無しさん [sage] 2018/11/15(木) 23:24:03.77:u639IIxL

これでモード値が2個算出されたので気づいた。
g=56 ; s=45 ; x=36
N2p= function(N){
if(N < g + s - x) return(0)
b = N-g
dhyper(x,g,b,s) # choose(g,x)*choose(b,s-x)/choose(g+b,s)
}
pmf=Vectorize(N2p)

koi <- function(Nmax){
N=1:Nmax
y=pmf(N)
z=y/sum(y)
par(mfrow=c(2,1))
plot(N,z,type='h',col='gray',ylab='density',bty='l')
mode=N[y==max(y)]
mean=sum(N*z)
hdi = pmf2hdi(y,Print=FALSE)$indices
zc=cumsum(z)
median=which.max((zc>0.5))
abline(v=c(mode,median,mean),lty=c(1,2,3))
legend('topright',bty='n',legend=c('mode','median','mean'),lty=1:3)
plot(N,zc,type='l',col='gray',ylab='cdf',bty='l')
abline(h=0.5,lty=3)
qtl = c(min(which(zc>0.025)) , min(which(zc>0.975)))
list(mode=mode, median=median, mean=mean,CI.hdi=hdi,CI.Qqtl=qtl)
}
卵の名無しさん [] 2018/11/15(木) 23:36:45.82:aG6lkqvZ

鉄則を思い出しましょう

算数事務員はド底辺の裏口バカだから
対話するだけムダである
卵の名無しさん [sage] 2018/11/15(木) 23:40:32.65:u639IIxL
pythonにも超幾何分布のモジュールがあった。

from scipy.stats import hypergeom
import matplotlib.pyplot as plt
# hypergeom.pmf(x,g+b,g,s)
print(hypergeom.pmf(36, 70, 56, 45))
print(hypergeom.pmf(36, 69, 56, 45))
卵の名無しさん [sage] 2018/11/15(木) 23:43:20.76:u639IIxL

そんなの書く暇があれば、これくらい即答できるはずなのに。

2人が自転車に乗って走っている。その速さの比は11:8である。
この2人が周囲480mの円形の池の同じ地点から同時に同方向にスタートしてまわるとき、速い人は遅い人を4分ごとに追い越す。
2人の毎分の速さを求めよ

即答できないって、馬鹿なんだね。
卵の名無しさん [sage] 2018/11/15(木) 23:43:55.25:u639IIxL
専門医スレで誰も正当できなかった>176の方に答えてくれてもいいぞ、国立卒ならこれくらいの四則演算はできるだろ?
卵の名無しさん [] 2018/11/15(木) 23:55:08.72:kjgKXvFf
正当 WWW

発狂バカが やりがちの 漢字誤変換 WWW
卵の名無しさん [sage] 2018/11/16(金) 00:19:20.47:CpQxI30j

そういう指摘する暇があれば即答すればいいのに
やっぱり馬鹿なのね。
卵の名無しさん [sage] 2018/11/16(金) 14:34:20.45:OhMUxuM/
覆面算の □/□ * □/□ = □□/□ 
f0 分母に1を許さない
f1 分母に1がきてもよい

r0 = [[a,b,c,d,e,f,g]|a<-[1..9],b<-[2..9],c<-[(a+1)..9],d<-[2..9],e<-[1..9],f<-[1..9],g<-[2..9],(a/b)*(c/d)==(10*e+f)/g,a/=b,a/=c,a/=d,a/=e,a/=f,a/=g,b/=c,b/=d,b/=e,b/=f,b/=g,c/=d,c/=e,c/=f,c/=g,d/=e,d/=f,d/=g,e/=f,e/=g,f/=g]
r1 = [[a,b,c,d,e,f,g]|a<-[1..9],b<-[1..9],c<-[(a+1)..9],d<-[1..9],e<-[1..9],f<-[1..9],g<-[2..9],(a/b)*(c/d)==(10*e+f)/g,a/=b,a/=c,a/=d,a/=e,a/=f,a/=g,b/=c,b/=d,b/=e,b/=f,b/=g,c/=d,c/=e,c/=f,c/=g,d/=e,d/=f,d/=g,e/=f,e/=g,f/=g]
f x = map floor x

f0 = do
putStrLn "One is NOT permitted as denominator"
print $ map f r0

f1 = do
putStrLn "permissive of 1 as denominator"
print $ map f r1

main = do
f0
f1
卵の名無しさん [sage] 2018/11/16(金) 14:49:13.79:OhMUxuM/
タイムアウトせずにon lineでも動かせた。

ttp://http://tpcg.io/dbtTnK
卵の名無しさん [sage] 2018/11/16(金) 15:29:32.07:OhMUxuM/
これは最大値・最小値を求めてから組み合わせを出すことになるから時間がかかるなぁ。

-- max , min of □/□(□-□) - □(□-□)
f x = map floor x

-- permissive of as one as denominator
r1 = [(a/b)*(c-d)-e*(f-g)|a<-[-5..5],b<- [-5..(-1)]++[1..5],c<-[-5..5],d<-[-5..5],e<-[-5..5],f<-[-5..5],g<-[-5..5]
,a/=b,a/=c,a/=d,a/=e,a/=f,a/=g,b/=c,b/=d,b/=e,b/=f,b/=g,c/=d,c/=e,c/=f,c/=g,d/=e,d/=f,d/=g,e/=f,e/=g,f/=g]
r1max = maximum r1
r1min = minimum r1

ans1 x = [[a,b,c,d,e,f,g]|a<-[-5..5],b<-[-5..(-1)]++[1..5],c<-[-5..5],d<-[-5..5],e<-[-5..5],f<-[-5..5],g<-[-5..5],
a/=b,a/=c,a/=d,a/=e,a/=f,a/=g,b/=c,b/=d,b/=e,b/=f,b/=g,c/=d,c/=e,c/=f,c/=g,d/=e,d/=f,d/=g,e/=f,e/=g,f/=g,a/b*(c-d)-e*(f-g)== x]

-- no permission of one as denominator
r0 = [(a/b)*(c-d)-e*(f-g)|a<-[-5..5],b<- [-5..(-2)]++[2..5],c<-[-5..5],d<-[-5..5],e<-[-5..5],f<-[-5..5],g<-[-5..5],
a/=b,a/=c,a/=d,a/=e,a/=f,a/=g,b/=c,b/=d,b/=e,b/=f,b/=g,c/=d,c/=e,c/=f,c/=g,d/=e,d/=f,d/=g,e/=f,e/=g,f/=g]
r0max = maximum r0
r0min = minimum r0
ans0 x = [[a,b,c,d,e,f,g]|a<-[-5..5],b<-[-5..(-2)]++[2..5],c<-[-5..5],d<-[-5..5],e<-[-5..5],f<-[-5..5],g<-[-5..5],a/=b
,a/=c,a/=d,a/=e,a/=f,a/=g,b/=c,b/=d,b/=e,b/=f,b/=g,c/=d,c/=e,c/=f,c/=g,d/=e,d/=f,d/=g,e/=f,e/=g,f/=g,a/b*(c-d)-e*(f-g)== x]

{- To caluculate input and let it run for minutes:
map f (ans1 r1max)
map f (ans0 r0min)
-}
卵の名無しさん [sage] 2018/11/16(金) 16:11:47.91:OhMUxuM/
バックグラウンで放置してたら計算してくれていた。

Prelude> map f (ans1 r1max)
[[-5,-1,3,-4,5,-3,4],[-5,-1,3,-3,5,-4,4],[-5,-1,4,-4,5,-3,3],[-5,-1,4,-3,5,-4,3],[-5,1,-4,3,5,-3,4],[-5,1,-4,4,5,-3,3],[-5,1,-3,3,5,-4,4],[-5,1,-3,4,5,-4,3]
,[5,-1,-4,3,-5,4,-3],[5,-1,-4,4,-5,3,-3],[5,-1,-3,3,-5,4,-4],[5,-1,-3,4,-5,3,-4],[5,1,3,-4,-5,4,-3],[5,1,3,-3,-5,4,-4],[5,1,4,-4,-5,3,-3],[5,1,4,-3,-5,3,-4]]
卵の名無しさん [sage] 2018/11/16(金) 18:23:07.05:CpQxI30j

数学板にこの問題とpythonのコードを貼ったら
ちゃんとコード内の関数を読んでレスがきた。

このスレだと漢字の誤変換を指摘するしかできないアホしかいない。

誤変換の指摘を書く暇があれば、これくらい即答できるはずなのに。それもできない馬鹿なのか?裏口入学かな?

2人が自転車に乗って走っている。その速さの比は11:8である。
この2人が周囲480mの円形の池の同じ地点から同時に同方向にスタートしてまわるとき、速い人は遅い人を4分ごとに追い越す。
2人の毎分の速さを求めよ
卵の名無しさん [] 2018/11/16(金) 19:16:23.53:lLHsnLDJ
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2018/11/16(金) 20:56:38.81:CpQxI30j


池の鯉を網で56匹すくいました。
すくった56匹に目印をつけ、池にもどしました。
次の日に鯉45匹をすくったところ、36匹に目印がついていました。
池の鯉はおよそ何匹ですか。


魚の総数を上限1万匹とし、その確率分布は一様分布を仮定。

再捕獲した45匹中何匹に目印がついているかで推測される95%信頼区間(Highest Density Interval)をグラフにしてみた。

ttp://i.imgur.com/NKcQ61u.png

Rのコードはここに置いた(通知を変えて実行できる)

ttp://http://tpcg.io/TBD7MO
卵の名無しさん [] 2018/11/16(金) 22:01:15.87:7kS528uk
Uryuu fell 23 times in the national exam
It is an amateur virgin who is also failing in marriage
To the Uraguchi of the spinning parpurin
He is getting turned on
F class clerks condenced raw kid juice
The smell of the Doteihen does not decrease
NnnnnHooOoooOoooooooo
卵の名無しさん [] 2018/11/16(金) 22:37:20.95:STS/8KrX
僕らの おち○ぽ
卵の名無しさん [] 2018/11/17(土) 09:18:23.91:Xiv5Sp0o
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.
卵の名無しさん [sage] 2018/11/17(土) 10:15:28.71:Vs5/CoAG

池の鯉の総数と調査します。
五郎君が名前に因んで56匹を捕まえて目印をつけ、池にもどしました。
次の日に三郎君が自分の名前に因んで36匹の目印のついた鯉を捕まえることにしました。
鯉45匹めで予定の36匹が捕まりました。
池の鯉はおよそ何匹ですか。

負の二項分布で計算するとこっちはモード値が70の1個なんだなぁ。
卵の名無しさん [sage] 2018/11/17(土) 10:26:00.26:Vs5/CoAG

このときの推測数の信頼区間の算出が次の課題だな。
3匹目印鯉捕獲目標が45匹目で達成されたときと比較したい。
卵の名無しさん [sage] 2018/11/17(土) 10:51:31.94:Vs5/CoAG

DRAFT
卵の名無しさん [sage] 2018/11/17(土) 10:51:40.44:Vs5/CoAG
marked.fish2 <- function(.x,Nmax=1000, Print=FALSE){
# marked fish # to 95%CI
N2p= function(N,g=56,s=45,x=.x){ # N:total number of fish
if(N < g + s - x) return(0)
dnbinom(s-x,x,g/N) # choose(s-1,x-s)*(1-p)^(s-x)*p^x
}
pmf=Vectorize(N2p)
N=1:Nmax
y=pmf(N)
z=y/sum(y)
mode=mean(N[y==max(y)]) # can be multiple
mean=sum(N*z)
# hdi = pmf2hdi(y,Print=FALSE)$indices
hdi=NA
zc=cumsum(z)
median=which.max((zc>0.5))
if(Print){
par(mfrow=c(2,1))
plot(N,z,type='h',col='gray',ylab='density',bty='l')
abline(v=c(mode,median,mean),lty=c(1,2,3))
legend('topright',bty='n',legend=c('mode','median','mean'),lty=1:3)
plot(N,zc,type='l',col='gray',ylab='cdf',bty='l')
abline(h=0.5,lty=3)}
qtl = c(min(which(zc>0.025)) , min(which(zc>0.975)))
list(mode=mode, median=median, mean=mean,CI.hdi=hdi,CI.Qqtl=qtl)
}

marked.fish2(3)
marked.fish2(36)
卵の名無しさん [sage] 2018/11/17(土) 12:29:55.67:MdaDRZ5p
非対称分布の信頼区間算出にパッケージないのかな?

pmf2hdi <- function(pmf,conf.level=0.95,Print=TRUE){ # pmf 2 higest density interval indices
pdf=pmf/sum(pmf) # sum(pdf)==1
if(Print) hist(pdf,breaks=length(pdf),ann=FALSE)
spdf=sort(pdf,decreasing=TRUE) # sort pdf from highest
cdf=cumsum(spdf) # culmutive probability
threshold=spdf[which(cdf>=conf.level)[1]]
# which(cdf>conf.level)[1] : cdf.index of 1st value when cdf > 0.95
# threshold : its corresponding spdf value
index=which(pdf>=threshold) # pdf.index whose value > threshold
clevel=sum(pdf[index]) # actual conf.level, a little bit greater than 0.95
n.index=length(index)
if(n.index==index[n.index]-index[1]+1){ # check if unimodal by its length
interval=c(index[1],index[n.index]) # if unimodal print lower and upper limit
print(c(lower=pmf[index[1]],upper=pmf[index[n.index]]))
}else{interval=index
}
list(indices=interval,actual.CI=clevel)
}
卵の名無しさん [sage] 2018/11/17(土) 13:55:53.88:ZSsSLaRh

> marked.fish(3)
lower upper
0.009921656 0.009682298
$`mode`
[1] 839

$median
[1] 1430

$mean
[1] 1963.967

$CI.hdi
[1] 295 5445

$CI.Qqtl
[1] 473 6825
卵の名無しさん [sage] 2018/11/17(土) 13:56:56.74:ZSsSLaRh
> marked.fish2(3)
lower upper
0.0006438142 0.0006421482
$`mode`
[1] 840

$median
[1] 1445

$mean
[1] 1985.835

$CI.hdi
[1] 280 5525

$CI.Qqtl
[1] 463 6902

負の二項分布でも超幾何分布のときとさほど変わらないなぁ
卵の名無しさん [] 2018/11/17(土) 14:05:11.77:oN/r/5pI
さて来週の3本は

よくもこんな〇〇〇〇レコードを
これから毎日スレ上げしようぜ
んほおぉぉぉおぉぉ

でお送りしま~す、んっわっほっぅ
純粋大和 [] 2018/11/17(土) 14:17:58.42:bEfId4t4
どうせ助からない(死ぬ奴)の集まりかよ 笑
卵の名無しさん [sage] 2018/11/17(土) 17:37:00.95:ZSsSLaRh
数学板のこれ面白かった。情報量とか調べながら解答してきた。

789 名前:132人目の素数さん[] 投稿日:2018/11/17(土) 01:54:23.54 ID:SOe/0VMF
情報理論の問題です。(1)は解けるのですが、(2)でつまずいています...

<問題>
50人の生徒からなるクラスがある。
そのうち30人は男子、20人は女子であり、男子のうち18人、女子のうち2人は眼鏡をかけている仮定とする。

(1)男女の別、眼鏡の有無のそれぞれが持つ平均自己相互量を求めよ。
(2)男女の性別が判っているという条件のもとで、眼鏡の有無が持つ条件付き自己情報量を求めよ。

答えは、
(1)H(X) = 0.97ビット, H(Y) = 0.97ビット
(2)H(Y|X) = 0.77ビット
となっております。

得意な方がいましたら、(2)の答えを出すまでの計算過程を教えていただきたいです。
よろしくお願い致します。
卵の名無しさん [sage] 2018/11/17(土) 17:38:33.02:ZSsSLaRh
数時間潰しての結果がこれ、わずか2行w

Prelude> let entropy x = sum $ map (\i -> -i*(logBase 2 i)) ( map(/sum(x)) x )
Prelude> 30/50 * entropy [18, 12] + 20/50 * entropy [2, 18]
0.7701685941085136
卵の名無しさん [sage] 2018/11/17(土) 18:43:39.12:ZSsSLaRh

再利用できるように関数化しておいた。

{-
<問題>
120(n)人の生徒からなるクラスがある。
そのうち90(m)人は男子、30(f)人は女子であり、男子のうち80(um)人、女子のうち10(uf)人は裏口入学であると仮定とする。

(1)男女の別、裏口の有無のそれぞれが持つ平均自己相互量をビット値で求めよ。
(2)男女の性別が判っているという条件のもとで、裏口の有無が持つ条件付き自己情報量(ビット値)を求めよ。
-}
entropy x = sum $ map (\i -> -i*(logBase 2 i)) ( map(/sum(x)) x )
entr_ura_gender n m f um uf = do
m/n*entropy[um,m-um] + f/n*entropy[uf,f-uf]
卵の名無しさん [] 2018/11/17(土) 19:20:41.23:XNk+eTpQ
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.
卵の名無しさん [sage] 2018/11/17(土) 20:12:01.95:ZSsSLaRh
# ttp://https://logics-of-blue.com/information-theory-basic/
"予想がつかない→不確実性(情報エントロピー)が大きい→平均情報量も大きい"
entropy <- function(x){ # 情報エントロピー(平均情報量)
x=x/sum(x)
sum(x*(-log2(x)))
}

"各々の確率分布の情報量の差分の期待値をとります
確率分布が異なっていれば、情報量があるとみなすのが
カルバック・ライブラーの情報量です。"
KLd <- function(P,Q){ # Kullback?Leibler divergence, relative entropy,Information gain
n=length(P)
if(n!=length(Q)) return(NULL)
P=P/sum(P)
Q=Q/sum(Q)
sum(Q*(log2(Q)-log2(P)))
}
# 相互情報量は不確実性(情報エントロピー)の減少量とみなすことができます
卵の名無しさん [sage] 2018/11/17(土) 21:45:47.30:ZSsSLaRh
KLd <- function(P,Q){ # Kullback-Leibler divergence, relative entropy,Information gain
n=length(P)
if(n!=length(Q)) return(NULL)
P=P/sum(P)
Q=Q/sum(Q)
sum(P*log(P)/log(Q)) # P relative to Q
}


kld p q = do -- Kullback-Leibler divergence
-- if length p /= length q
-- then return ()
-- else do
let pp = map (/sum(p)) p
qq = map (/sum(q)) q
in sum $ zipWith (\x y -> x * (log x)/(log y)) pp qq
卵の名無しさん [sage] 2018/11/17(土) 21:50:36.68:ZSsSLaRh
Prelude> p = [80,10]
Prelude> q = [10,20]
Prelude> let pp = map (/sum(p)) p
Prelude> let qq = map (/sum(q)) q
Prelude> sum $ zipWith (\x y -> x * (log x)/(log y)) pp qq
0.6974120552208812


KLd <- function(P,Q){ # Kullback-Leibler divergence, relative entropy,Information gain
n=length(P)
if(n!=length(Q)) return(NULL)
P=P/sum(P)
Q=Q/sum(Q)
sum(P*log(P)/log(Q)) # P relative to Q
}
> KLd(c(80,10),c(10,20))
[1] 0.6974121
卵の名無しさん [] 2018/11/17(土) 23:42:40.77:7FfFKHDd
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2018/11/18(日) 06:08:27.82:YaOZKwLp
事務員で遊ぶのも飽きてきたし
そろそろコミケの原稿を書き始めなきゃなぁ
卵の名無しさん [sage] 2018/11/18(日) 06:55:57.87:deJ1Cp/X
中学入試を難問化した問題で遊んでみる。

池の鯉を網で56匹すくいました。
すくった56匹に目印をつけ、池にもどしました。
次の日に鯉45匹をすくったところ、36匹に目印がついていました。
(1)池の鯉の鯉の数の最尤値を述べよ(2つある)。
(2)最尤値が2つあるのは何匹の目印鯉が捕獲されたときか述べよ。
卵の名無しさん [] 2018/11/18(日) 08:16:59.52:afl5ZxKK
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2018/11/18(日) 10:01:00.69:deJ1Cp/X

kld p q = do -- Kullback-Leibler divergence
if length p /= length q
then error "Not equal length"
else do
let pp = map (/sum(p)) p
qq = map (/sum(q)) q
in sum $ zipWith (\x y -> x * (log x)/(log y)) pp qq
main = do
print $ kld [1,1] [1,3]
print $ kld [1,1] [1,2,3]
卵の名無しさん [sage] 2018/11/18(日) 11:18:38.60:uPZ4H5RS

pmf2hdi <- function(pmf,conf.level=0.95,Print=TRUE){ # pmf 2 higest density interval indices
pdf=pmf/sum(pmf) # sum(pdf)==1
if(Print) hist(pdf,breaks=length(pdf),ann=FALSE)
spdf=sort(pdf,decreasing=TRUE) # sort pdf from highest
cdf=cumsum(spdf) # culmutive probability
threshold=spdf[which(cdf>=conf.level)[1]]
# which(cdf>conf.level)[1] : cdf.index of 1st value when cdf > 0.95
# threshold : its corresponding spdf value
index=which(pdf>=threshold) # pdf.index whose value > threshold
clevel=sum(pdf[index]) # actual conf.level, a little bit greater than 0.95
n.index=length(index)
if(n.index==index[n.index]-index[1]+1){ # check if unimodal by its length
interval=c(index[1],index[n.index]) # if unimodal print lower and upper limit
print(c(lower=pmf[index[1]],upper=pmf[index[n.index]]))
}else{interval=index
}
list(indices=interval,actual.CI=clevel)
}
卵の名無しさん [sage] 2018/11/18(日) 11:18:46.99:uPZ4H5RS
marked.fish <- function(.x,Nmax=10000, Print=FALSE){ # marked fish # to 95%CI
N2p= function(N,g=56,s=45,x=.x){ # N:total number of fishe
if(N < g + s - x) return(0)
b = N-g # g:genuine(marked) b:bogus(unmarked) s:re-sampled
dhyper(x,g,b,s) # choose(g,x)*choose(b,s-x)/choose(g+b,s)
}
pmf=Vectorize(N2p)
N=1:Nmax
y=pmf(N)
z=y/sum(y)

mode.idx=N[y==max(y)] # can be multiple
n.idx=length(mode.idx)
mode=min(mode.idx)+(n.idx-1)/10
mean=sum(N*z)
hdi = pmf2hdi(y,Print=FALSE)$indices
zc=cumsum(z)
median=which.max((zc>0.5))
if(Print){
par(mfrow=c(2,1))
plot(N,z,type='h',col='gray',ylab='density',bty='l')
abline(v=c(mode,median,mean),lty=c(1,2,3))
legend('topright',bty='n',legend=c('mode','median','mean'),lty=1:3)
plot(N,zc,type='l',col='gray',ylab='cdf',bty='l')
abline(h=0.5,lty=3)}
qtl = c(min(which(zc>0.025)) , min(which(zc>0.975)))
list(mode=mode, median=median, mean=mean,CI.hdi=hdi,CI.Qqtl=qtl)
}
卵の名無しさん [sage] 2018/11/18(日) 11:19:33.02:uPZ4H5RS
marked.fish(36,Print=T)
marked.fish(3,Print=T)
n=0:45
Y=sapply(n,function(n) marked.fish(n))
y=matrix(unlist(Y["CI.hdi",]),nrow=2)
plot(n,y[2,],type='n',bty='l',xlab='re-sampled marked fish',
ylab='estimated size of total')
segments(n,y[1,],n,y[2,],lwd=3,col='gray')
points(n,unlist(Y['mode',]),pch=21)
points(n,unlist(Y['median',]),pch='+')
points(n,unlist(Y['mean',]),pch='*')
legend('center',bty='n',pch=c('○','+','*'),legend=c('mode','median','mean'))

result=data.frame(n,mode=unlist(Y['mode',]),median=unlist(Y['median',]),
mean=round(unlist(Y['mean',]),1))
result[1:20,]
result[21:40,]
tail(result)
n[floor(result[,'mode'])!=result[,'mode']] # multiple
卵の名無しさん [sage] 2018/11/18(日) 11:20:38.75:uPZ4H5RS

(2)の答は4個あるな。
卵の名無しさん [sage] 2018/11/18(日) 13:29:06.59:uPZ4H5RS

プログラミンの練習にpythonに移植、Rより面倒。

import math
def simplex(x): # convert vector to whose sum =1
s=sum(x)
return ([y/s for y in x]) # return(list(map( (lambda y: y/s) , x )))
def kld(p,q): # Kullback-Leibler divergence
if len(p)!=len(q):
raise Exception("Not equal length!")
p = simplex(p)
q = simplex(q)
return(sum(list (map (lambda x,y: x* math.log(x)/math.log(y), p,q))))
卵の名無しさん [sage] 2018/11/18(日) 17:41:08.98:uPZ4H5RS

エラー処理はなしにして無理矢理、one-liner にすると

def Kullback_Leiber(p,q): return(sum(list (map (lambda x,y: x* math.log(x)/math.log(y), [i/sum(p) for i in p],[j/sum(q) for j in q]))))
卵の名無しさん [] 2018/11/19(月) 00:27:20.08:6+hS1SxI
i tried it in Showa u motherfucker. in that time niggers were supposed be in what niggahz were supposed to be motherfucking in, which we call a discrimination.
they pay shit loaded money to motherfucking niggers ass-bitch cocksucker fucking gringo homosexual hobo
i mean fuck you all go down hell
卵の名無しさん [sage] 2018/11/19(月) 06:06:04.36:tA4kj3ba
2^3はpythonで1を返す
ビット演算子(~, &, |, ^, <<, >>)
2**3 か pow(2,3)で冪乗
卵の名無しさん [sage] 2018/11/19(月) 06:40:59.39:tA4kj3ba
練習に、これを移植したいなぁ。
ttp://http://www.geocities.jp/m_hiroi/puzzle/water_jug.html
卵の名無しさん [sage] 2018/11/19(月) 06:43:11.58:tA4kj3ba
すでにやった人がいた:P

ttp://http://dev.ariel-networks.com/Members/ohyama/haskell-6c345dee3057554f984c309289e3304f-with-perl-81ea7b547de8/
卵の名無しさん [sage] 2018/11/19(月) 07:27:32.80:tA4kj3ba

数が小さいので頭で考えると (4L,3L)

[(0,0),(4,0),(1,3),(1,0),(0,1),(4,1),(2,3),(2,0)]

になるが、

Haskellの解は無駄な汲み出しをしている気がするなぁ。

[(0,0),(4,0),(0,3),(4,3),(1,3),(3,0),(1,0),(3,3),(0,1),(4,2),(4,1),(0,2),(2,3),(2,0)]
卵の名無しさん [sage] 2018/11/19(月) 07:29:17.17:tA4kj3ba


問題はこれ

問題 : 4 リットルと 3 リットルの容器を使って 2 リットルの水を測るにはどうすればいい?
卵の名無しさん [sage] 2018/11/19(月) 07:31:08.11:tA4kj3ba
こっちの方が断然、難関。

油分け算

[問題] 油分け算

14 リットルの容器 A に油が満杯に入っています。これを 11 リットルの容器 B と 3 リットルの容器 C を使って二等分してください。
容器 A と B には 7 リットルずつ油が入ります。油を二等分する最短手順を求めてください。

容器 B と C のサイズが 9 リットルと 5 リットルの場合の手順は?
卵の名無しさん [sage] 2018/11/19(月) 08:12:59.88:tA4kj3ba

WinGCHiで動作するように少し改変
import Data.List

basicState = (0,0)
actions = let xmax = 4
ymax = 3
in [(\(x, y) -> (xmax, y)),
(\(x, y) -> (x, ymax)),
(\(x, y) -> (0, y)),
(\(x, y) -> (x, 0)),
(\(x, y) -> if (x + y > xmax) then (xmax, y+x-xmax) else (x+y, 0)),
(\(x, y) -> if (x + y > ymax) then (x+y-ymax, ymax) else (0, x+y))]

main = print $ searchStates [basicState]

searchStates :: [(Int, Int)] -> [(Int, Int)]
searchStates states = let nexts = filter (not . (checkState states)) $ concat $ map (execSeek actions) states
in if length nexts > 0
then searchStates $ states ++ (nub nexts)
else states

execSeek :: [((Int, Int) -> (Int, Int))] -> (Int, Int) -> [(Int, Int)]
execSeek (f:fs) crnt | null fs = (f crnt : [])
| True = (f crnt : []) ++ execSeek fs crnt

checkState :: [(Int, Int)] -> (Int, Int) -> Bool
checkState states (crnt_x, crnt_y) = any isSameState states
where
isSameState :: (Int, Int) -> Bool
isSameState (x, y) = if (x == crnt_x && y == crnt_y) then True else False
卵の名無しさん [sage] 2018/11/19(月) 08:25:49.04:tA4kj3ba

これは可能な組み合わせを列挙しているだけで必ずしも手順をしめすプログラムじゃないな。
卵の名無しさん [] 2018/11/19(月) 08:30:40.71:L6cqzabr
i tried it in Showa u motherfucker. in that time niggers were supposed be in what niggahz were supposed to be motherfucking in, which we call a discrimination.
they pay shit loaded money to motherfucking niggers ass-bitch cocksucker fucking gringo homosexual hobo
i mean fuck you all go down hell
卵の名無しさん [sage] 2018/11/19(月) 12:28:58.07:xPquTj4a

[(0,0),(0,3),(3,0),(3,3),(4,2),(0,2)] というのが数学板で返された
卵の名無しさん [] 2018/11/19(月) 14:10:23.88:lgLouqKT
は国試に23回も落ちた挙句
婚活にも失敗してる素人童貞で
くるくるぱーの裏口バカに
なっちゃってるのらぁあぁぁ
Fラン事務員の濃ゆぅぅい生ガキ汁
ド底辺の臭いが落ちないよぉ
んほおぉぉぉおぉぉ
卵の名無しさん [sage] 2018/11/19(月) 15:18:00.83:/8nCvktv

(14,0,0),(3,11,0),(3,8,3),(6,8,0),(6,5,3),(9,5,0),(9,2,3),(12,2,0),(12,0,2),(1,11,2),(1,10,3),(4,10,0),(4,7,3),(7,7,0)
これでできるけど、最短かどうかは自信がないなぁ。
卵の名無しさん [sage] 2018/11/19(月) 15:21:56.75:/8nCvktv

ド底辺シリツ医大卒の知性を表すような文章だなぁ。

>242の答でもだせばいいのに、

馬鹿なのか?馬鹿なのにどうして大学に入れるわけ?

あれかな?

あれだよね?

あれ

あれ







卵の名無しさん [sage] 2018/11/19(月) 15:46:07.22:/8nCvktv
[問題]
30 リットルの容器 A に油が満杯に入っています。これを 17 リットルの容器 B と 13 リットルの容器 C を使って二等分してください。容器 A と B には 15 リットルずつ油が入ります。油を二等分する手順を求めてください。
[30,0,0]
[13,17,0]
[13,4,13]
[26,4,0]
[26,0,4]
[9,17,4]
[9,8,13]
[22,8,0]
[22,0,8]
[5,17,8]
[5,12,13]
[18,12,0]
[18,0,12]
[1,17,12]
[1,16,13]
[14,16,0]
[14,3,13]
[27,3,0]
[27,0,3]
[10,17,3]
[10,7,13]
[23,7,0]
[23,0,7]
[6,17,7]
[6,11,13]
[19,11,0]
[19,0,11]
[2,17,11]
[2,15,13]
[15,15,0]
卵の名無しさん [] 2018/11/19(月) 18:20:27.15:lgLouqKT
ネットで口汚くあちこちのスレを荒らしている国試浪人の事務員だが
この世に彼奴を下回るカスがいるだろうか
いや居ない
リアルではだれも口にしないが、みな思っていることだ

事務員本人も内心は自覚していることだろう
でなければ毎日毎日、専門医や開業医や皮膚科でもないのに
それぞれのスレを荒らしに来るはずがない

よっぽど妬ましいんだろうなW
卵の名無しさん [sage] 2018/11/19(月) 20:30:41.47:/8nCvktv
rm(list=ls())

Amax=10 ; Bmax=7 ; Cmax=3
init = c(10,0,0)
stacks=t(as.matrix(init))
a2b <- function(abc){
a=abc[1];b=abc[2];c=abc[3]
if(a+b > Bmax) c(a+b-Bmax,Bmax,c)
else c(0, a+b, c)
}

a2c <- function(abc){
a=abc[1];b=abc[2];c=abc[3]
if(a+c > Cmax) c(a+c-Cmax, b, Cmax)
else c(0, b, a+c)
}

b2c <- function(abc){
a=abc[1];b=abc[2];c=abc[3]
if(b+c > Cmax) c(a, b+c-Cmax,Cmax)
else c(a, 0, b+c)
}

b2a <- function(abc){
a=abc[1];b=abc[2];c=abc[3]
if(b+a > Amax) c(Amax, b+a-Amax,c)
else c(b+a, 0, c)
}
卵の名無しさん [sage] 2018/11/19(月) 20:31:14.24:/8nCvktv
c2a <- function(abc){
a=abc[1];b=abc[2];c=abc[3]
if(c+a > Amax) c(Amax, b, c+a-Amax)
else c(c+a, b, 0)
}

c2b <- function(abc){
a=abc[1];b=abc[2];c=abc[3]
if(c+b > Bmax) c(a, Bmax, c+b-Bmax)
else c(a, c+b, 0)
}

actions = c(a2b,a2c,b2c,c2a,c2a,c2b)

transfer <- function(x){
re=NULL
for(fun in actions){
re=rbind(re,fun(x))
}
unique(re)
}
transit=transfer(init)

is.vim <- function(vector,matrix){ # is vector in matrix
any(apply(matrix,1,function(x) all(x==vector)))
}
卵の名無しさん [sage] 2018/11/19(月) 21:00:32.27:/8nCvktv
ttp://http://ailaby.com/dfs_bfs/#id3
卵の名無しさん [sage] 2018/11/19(月) 22:04:51.47:vmWf+9X3
actions = c(a2b,a2c,b2c,c2a,c2a,c2b)

is.vim <- function(vector,matrix){ # is vector in matrix
any(apply(matrix,1,function(x) all(x==vector)))
}

is.goal <- function(x){
all(x==goal)
}

transfer <- function(x){
re=NULL
for(fun in actions){
v=fun(x)
if(!is.vim(v,stacks)) re=rbind(re,fun(x))
}
unique(re)
}

transit=transfer(init)


push <- function(x){
n=nrow(x)
for(i in 1:n){
if(!is.vim(x[i,],stacks)) stacks=rbind(x[i,],stacks)
if(is.goal(x[i,])) break
}
return(stacks)
}
stacks=push(transit)
卵の名無しさん [sage] 2018/11/19(月) 22:22:12.67:vmWf+9X3
ttp://https://jprogramer.com/catealgo/999
卵の名無しさん [sage] 2018/11/19(月) 22:29:14.48:vmWf+9X3

期待に反して悪いが俺、事務員じゃないんだね。

臨床やってるからこういう議論もできる。
ttps://egg.5ch.net/test/read.cgi/hosp/1499746033/878">ttps://egg.2ch.net/test/read.cgi/hosp/1499746033/878

879 卵の名無しさん sage 2018/11/15(木) 07:18:18.94 ID:LT687Ilf
ttp://i.imgur.com/ztM8yOL.png

んで、あんたどこ卒?
ド底辺シリツ医大へ裏口入学なんだろ?
中学入試を少し難問化した>227に答えてみ!
卵の名無しさん [sage] 2018/11/19(月) 22:31:41.85:vmWf+9X3

国立卒はちゃんとわかってる。

開業医スレのシリツ三法則(試案、名投稿より作成)

1.私立医が予想通り糞だからしょうがない

>ttps://egg.5ch.net/test/read.cgi/hosp/1537519628/101-102">ttps://egg.5ch.net/test/read.cgi/hosp/1537519628/101-102
>ttps://egg.5ch.net/test/read.cgi/hosp/1537519628/844-853
ID:RFPm1BdQ

>ttps://egg.5ch.net/test/read.cgi/hosp/1537519628/869
>ttps://egg.5ch.net/test/read.cgi/hosp/1537519628/874-875
>ttps://egg.5ch.net/test/read.cgi/hosp/1537519628/874-880
>ttps://egg.5ch.net/test/read.cgi/hosp/1537519628/882
ID:liUvUPgn

2.馬鹿に馬鹿と言っちゃ嫌われるのは摂理
実例大杉!

3.リアルでは皆思ってるだけで口に出してないだけ
卵の名無しさん [] 2018/11/19(月) 22:42:33.31:zhu5ykUr
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.
卵の名無しさん [sage] 2018/11/19(月) 23:01:00.76:vmWf+9X3

統計スレに投稿するならこれくらい答えてみ。
話題のド底辺シリツ医大裏口入学を題材にした問題。

ド底辺シリツ裏口調査団が100人を順次調査した。
裏口判明人数をそのまま公表はヤバすぎる結果であったため、
連続して裏口がみつかった最大数は4人であったとだけ公表した。
公表結果が正しいとして裏口入学人数の期待値、最頻値、及び95%信頼区間を述べよ。
卵の名無しさん [sage] 2018/11/19(月) 23:13:28.02:vmWf+9X3
actions = c(a2b,a2c,b2c,c2a,c2a,c2b)

is.vim <- function(vector,matrix){ # 配列が行列に含まれるか
any(apply(matrix,1,function(x) all(x==vector)))}

is.goal <- function(x){  #ゴール判定
all(x==goal)}

transfer <- function(x){ # 移動してにスタックにない配列のみ返す
re=NULL
for(fun in actions){
v=fun(x)
if(!is.vim(v,stacks)) re=rbind(re,fun(x)) }
unique(re)}

transit=transfer(init) #最初の移動

push <- function(x){ #新規のみスタックに積む
n=nrow(x)
for(i in 1:n){
if(!is.vim(x[i,],stacks)) stacks=rbind(x[i,],stacks)
if(is.goal(x[i,])) break #ゴールしてたらループをぬける
}
return(stacks) #新スタックを返す
}
stacks=push(transit)
卵の名無しさん [sage] 2018/11/20(火) 07:42:56.98:jEVjKi6n

んで、あんたどこ卒?
卵の名無しさん [sage] 2018/11/20(火) 07:48:14.29:jEVjKi6n

探索経路を記録するのと
移転で過去の状態に戻るのをカウントから外す必要があるなぁ。
卵の名無しさん [] 2018/11/20(火) 08:30:59.02:GReM9fuK
ネットで口汚くあちこちのスレを荒らしている国試浪人の事務員だが
この世に彼奴を下回るカスがいるだろうか
いや居ない
リアルではだれも口にしないが、みな思っていることだ

事務員本人も内心は自覚していることだろう
でなければ毎日毎日、専門医や開業医や皮膚科でもないのに
それぞれのスレを荒らしに来るはずがない

よっぽど妬ましいんだろうなW
卵の名無しさん [sage] 2018/11/20(火) 11:38:05.66:+LTJHbMS
油分け算のRスクリプトようやく完成

rm(list=ls())
Amax=10 ; Bmax=7 ; Cmax=3 # capacity
t0 = c(10,0,0) # initial state
goal = c(5,5,0) # goal

.stack <<- t(as.matrix(t0)) # stack (converted to one row matrix)
.checked <<- .stack # checked list

# pouring methods
a2b <- function(abc){ # pour from A to B
a=abc[1];b=abc[2];c=abc[3]
if(a+b > Bmax) c(a+b-Bmax,Bmax,c)
else c(0, a+b, c)
}

a2c <- function(abc){
a=abc[1];b=abc[2];c=abc[3]
if(a+c > Cmax) c(a+c-Cmax, b, Cmax)
else c(0, b, a+c)
}

b2c <- function(abc){
a=abc[1];b=abc[2];c=abc[3]
if(b+c > Cmax) c(a, b+c-Cmax,Cmax)
else c(a, 0, b+c)
}
卵の名無しさん [sage] 2018/11/20(火) 11:38:32.07:+LTJHbMS
b2a <- function(abc){
a=abc[1];b=abc[2];c=abc[3]
if(b+a > Amax) c(Amax, b+a-Amax,c)
else c(b+a, 0, c)
}

c2a <- function(abc){
a=abc[1];b=abc[2];c=abc[3]
if(c+a > Amax) c(Amax, b, c+a-Amax)
else c(c+a, b, 0)
}

c2b <- function(abc){
a=abc[1];b=abc[2];c=abc[3]
if(c+b > Bmax) c(a, Bmax, c+b-Bmax)
else c(a, c+b, 0)
}

actions = c(a2b,a2c,b2c,c2a,c2a,c2b) # all pouring method

is.rim <- function(row,matrix){ # is row in matrix?
any(apply(matrix,1,function(x) all(x==row))) # comparble to %in%
}

is.goal <- function(x){ # goal reached?
all(x==goal)
}
卵の名無しさん [sage] 2018/11/20(火) 11:38:51.94:+LTJHbMS
pop <- function(){ # pop LIFO
if(is.null(.stack)) return()
LIFO=.stack[1,]
if(nrow(.stack)==1) .stack <<- NULL
else .stack <<- .stack[-1,] # changed GLOBALLY
return(LIFO)
}

push <- function(rows){ # push rows at head of stack
if(is.null(rows)) invisible(NULL) # no NULL show
else .stack <<- rbind(rows , .stack) # changed GLOBELY
}

transfer <- function(x){ # return unchekcked transferred state
re=NULL
for(fun in actions){ # try all methods
v=fun(x) # drop checked state and itself
if(!is.rim(v,.checked) & !all(v==x)) re=rbind(re,fun(x))
}
uni.re=unique(re) # delete duplicated
.checked <<- rbind(uni.re,.checked) # add to .checked GLOBELY
return(uni.re)
}
卵の名無しさん [sage] 2018/11/20(火) 11:39:23.04:+LTJHbMS
state=NULL
while(!is.goal(.stack[1,])){
push(transfer(pop()))
state=rbind(state,.stack[1,])
}

> state
[,1] [,2] [,3]
[1,] 3 7 0
[2,] 0 7 3
[3,] 3 4 3
[4,] 6 4 0
[5,] 6 1 3
[6,] 9 1 0
[7,] 9 0 1
[8,] 2 7 1
[9,] 2 5 3
[10,] 5 5 0
卵の名無しさん [sage] 2018/11/20(火) 13:27:38.76:+LTJHbMS

これだと無駄な手順も返しているな。

while(!is.goal(.stack[1,])){
tr=transfer(pop())
push(tr)
if(!is.null(tr))state=rbind(state,.stack[1,])
}
state

> state
[,1] [,2] [,3]
[1,] 3 7 0
[2,] 0 7 3
[3,] 6 4 0
[4,] 6 1 3
[5,] 9 1 0
[6,] 9 0 1
[7,] 2 7 1
[8,] 2 5 3
[9,] 5 5 0
卵の名無しさん [] 2018/11/20(火) 15:06:09.76:6Tvud5kf
i tried it in Showa u motherfucker. in that time niggers were supposed be in what niggahz were supposed to be motherfucking in, which we call a discrimination.
they pay shit loaded money to motherfucking niggers ass-bitch cocksucker fucking gringo homosexual hobo
i mean fuck you all go down hell
卵の名無しさん [sage] 2018/11/20(火) 17:14:24.57:+LTJHbMS
ようやくデバッグできた。

> state=t0
> while(!is.goal(.stack[1,])){
+ (p=pop())
+ (tr=transfer(p))
+ (.checked <<- unique(rbind(p,.checked))) # add to .checked GLOBELY
+ push(tr)
+ (.stack)
+ if(!is.null(transfer(.stack[1,]))) state=rbind(state,.stack[1,])
+ }
> rownames(state)=NULL
> colnames(state)=c(Amax,Bmax,Cmax)
> state
10 7 3
[1,] 10 0 0
[2,] 3 7 0
[3,] 3 4 3
[4,] 6 4 0
[5,] 6 1 3
[6,] 9 1 0
[7,] 9 0 1
[8,] 2 7 1
[9,] 2 5 3
[10,] 5 5 0
卵の名無しさん [sage] 2018/11/20(火) 17:15:16.68:+LTJHbMS
目的のノードを見つけたら終了する仕様だから、最短かどうかはわからないなぁ。
卵の名無しさん [] 2018/11/20(火) 17:21:50.40:cc4OhAKi
仕事しないとなぁ
卵の名無しさん [sage] 2018/11/20(火) 17:53:04.65:3jy0dpIg


んで、あんたどこ卒?
きっと凄いとこ出てますね、と言われるぞw
卵の名無しさん [] 2018/11/20(火) 18:23:06.98:cc4OhAKi
時給の良い仕事ないかなぁ?
卵の名無しさん [] 2018/11/20(火) 18:44:46.44:cc4OhAKi
ハローワークで警備の仕事があるなぁ。
卵の名無しさん [sage] 2018/11/20(火) 19:45:03.72:+LTJHbMS
# 問題 : 7 リットルと 3 リットルの容器を使って 5 リットルの水を測るにはどうすればいい?

> state
7 3
[1,] 0 0
[2,] 7 0
[3,] 4 3
[4,] 4 0
[5,] 1 3
[6,] 1 0
[7,] 0 1
[8,] 7 1
[9,] 5 3
[10,] 5 0
卵の名無しさん [] 2018/11/20(火) 20:18:02.67:HF+OgDBw
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.
卵の名無しさん [] 2018/11/20(火) 22:25:53.92:cc4OhAKi
人間関係のない時給の良い仕事はないかなぁ?いじめられるからなぁ
卵の名無しさん [] 2018/11/20(火) 22:27:11.31:D0iJ9Tsc
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2018/11/20(火) 22:32:57.27:cc4OhAKi
仕事ください
卵の名無しさん [] 2018/11/20(火) 22:39:03.37:cc4OhAKi
なんの取り柄もない私に仕事をください
卵の名無しさん [] 2018/11/20(火) 22:41:23.23:cc4OhAKi
なんかの資格があったらなぁ 仕事がないなぁ 今になって悔やんでしまう
卵の名無しさん [] 2018/11/20(火) 22:48:29.81:cc4OhAKi
金がない!
卵の名無しさん [] 2018/11/20(火) 22:51:11.25:cc4OhAKi
もっと金になる勉強をすべきだった 仕事がないなぁ
卵の名無しさん [] 2018/11/20(火) 22:57:18.11:cc4OhAKi
このまま 社会に出ずに 人生が終わってしまうのか?なんだったんだろう俺の人生は?
卵の名無しさん [] 2018/11/20(火) 23:39:20.88:cc4OhAKi
明日 また ハローワーク行こう!
卵の名無しさん [sage] 2018/11/21(水) 09:42:48.41:Jctp5Wds
>268-269のバグを指摘できていたら見直すのだが
底辺学力でできるのは>197のような漢字の誤変換だけ。
卵の名無しさん [] 2018/11/21(水) 12:38:48.27:m3dnATiO
ド底辺スレの定期上げ
卵の名無しさん [] 2018/11/21(水) 13:50:41.23:cCF4eIpe
じゃ、定期あげ
卵の名無しさん [sage] 2018/11/21(水) 15:05:19.22:UV5R2p03

幅優先探索だとこんな感じだな。

.que <<- t(as.matrix(t0))
transfer(c(0,0)) # 70 03
transfer(c(7,0)) # 43 73
transfer(c(4,3)) # 40
transfer(c(4,0)) # 13
transfer(c(1,3)) #10
transfer(c(1,0)) #01
transfer(c(0,1)) #71
transfer(c(7,1))#53
transfer(c(5,3))#50
transfer(c(7,3)) # NULL
transfer(c(0,3)) # 30
transfer(c(3,0)) # 33
transfer(c(3,3)) # 60
transfer(c(6,0)) # 63
transfer(c(6,3)) # 72
transfer(c(7,2)) # 02
transfer(c(0,2))# 10
transfer(c(2,0)) #23
transfer(c(2,3))#50
#
卵の名無しさん [] 2018/11/21(水) 20:50:08.75:5Xwsg5oK
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2018/11/21(水) 21:27:39.69:m3dnATiO
非医師の人たちへむけて 今日の1曲

愛国戦隊大日本
卵の名無しさん [sage] 2018/11/21(水) 22:11:11.00:UV5R2p03
rm(list=ls())
graphics.off()

dlevy <- function (x,m,c) sqrt(c/2/pi)*exp(-c/2/(x-m))/(x-m)^3/2
set.seed(123)
dat=rgamma(1e4,1)
hist(dat,freq=F) ; summary(dat)
x=density(dat)$x ; y=density(dat)$y
lines(x,y)
f<-function(mc){
m=mc[1];c=mc[2]
sum((y-dlevy(x,m,c))^2)
}
(mc=optim(c(0,1),f, method='N')$par)
curve(dlevy(x,mc[1],mc[2]),add=T,col=2)
卵の名無しさん [sage] 2018/11/21(水) 22:12:01.19:UV5R2p03

これへの回答

あるデータ群に対して、確率密度関数のパラメータをフィッティングさせる方法ってないですか?
ちなみに、フィッティングさせたいのはレブィフライト確率密度関数です。
卵の名無しさん [] 2018/11/21(水) 22:46:03.55:uT58TBet
量子力学は?www
卵の名無しさん [sage] 2018/11/21(水) 23:46:11.38:tbX2fKWG
ボーズ粒子の実態は確率
卵の名無しさん [] 2018/11/21(水) 23:59:20.99:uT58TBet
国試諦めたんだねw
卵の名無しさん [sage] 2018/11/22(木) 00:06:46.65:jXQTlLg4

残念ながら、事務員じゃないのね。
こういうの書いているの俺な。

内視鏡検査について Part.2 [無断転載禁止](c)2ch.net
ttps://egg.5ch.net/test/read.cgi/hosp/1499746033/875">ttps://egg.5ch.net/test/read.cgi/hosp/1499746033/875

875 名前:卵の名無しさん[sage] 投稿日:2018/11/14(水) 20:29:50.55 ID:lTkyjX2F
卵の名無しさん [] 2018/11/22(木) 00:32:25.51:by7Pc9VA
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.
卵の名無しさん [sage] 2018/11/22(木) 19:48:22.68:EhyhVVko
30L 17L 13L
[1,] 30 0 0
[2,] 13 17 0
[3,] 13 4 13
[4,] 26 4 0
[5,] 26 0 4
[6,] 9 17 4
[7,] 9 8 13
[8,] 22 8 0
[9,] 22 0 8
[10,] 5 17 8
[11,] 5 12 13
[12,] 18 12 0
[13,] 18 0 12
[14,] 1 17 12
[15,] 1 16 13
[16,] 14 16 0
[17,] 14 3 13
[18,] 27 3 0
[19,] 27 0 3
[20,] 10 17 3
[21,] 10 7 13
[22,] 23 7 0
[23,] 23 0 7
[24,] 6 17 7
[25,] 6 11 13
[26,] 19 11 0
[27,] 19 0 11
[28,] 2 17 11
[29,] 2 15 13
[30,] 15 15 0
卵の名無しさん [sage] 2018/11/22(木) 22:15:42.49:jXQTlLg4

it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.
この通り、実践すべき!

裏口入学の学生を除籍処分にしないかぎり、信頼の回復はないね。つまり、いつまで経ってもシリツ医大卒=裏口バカと汚名は拭えない。シリツ出身者こそ、裏口入学に厳しい処分せよを訴えるべき。

裏口入学医師の免許剥奪を!の国民運動の先頭に立てばよいぞ。
僕も裏口入学とか、言ってたら信頼の回復はない。
卵の名無しさん [] 2018/11/22(木) 22:49:22.84:s6txpOAx
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.
卵の名無しさん [sage] 2018/11/23(金) 07:36:18.66:t+QLwcrH
main = print $ length [(x,y)|x<-[-100..100],y<-[-100..100],7*x+3*y==5,abs x + abs y <= 100]
卵の名無しさん [sage] 2018/11/23(金) 07:45:24.89:Qqz1atCA
統計の話をしよう!!
サルを何千万匹殺しても無問題!!ただし、共産主義の香りづけをすれば
卵の名無しさん [sage] 2018/11/23(金) 08:10:20.25:QoVjbOvp
for x in range(-100,101):
for y in range(-100,101):
if(7*x+3*y==5 and x+y<=100):
print("(" + str(x) + "," + str(y) + ")")
卵の名無しさん [sage] 2018/11/23(金) 08:27:21.45:QoVjbOvp
debugged

for x in range(-100,101):
for y in range(-100,101):
if(7*x+3*y==5 and abs(x)+abs(y)<=100):
print("(" + str(x) + "," + str(y) + ")")
卵の名無しさん [sage] 2018/11/23(金) 08:28:05.53:QoVjbOvp
R

gr=expand.grid(-100:100,-100:100)
f=function(x,y) 7*x+3*y==5 & abs(x)+abs(y)<=100
sum(mapply(f,gr[,1],gr[,2]))
卵の名無しさん [sage] 2018/11/23(金) 08:29:57.03:QoVjbOvp
R
re=NULL
for(x in -100:100){
for(y in -100:100){
if(7*x+3*y==5 & abs(x)+abs(y)<=100){
re=rbind(re,(c(x,y)))}}}
nrow(re)
卵の名無しさん [sage] 2018/11/23(金) 10:32:55.82:QoVjbOvp
# Python

a=7; b=3; c=5
n=100
xy = []
for x in range(-n,n+1):
for y in range(-n,n+1):
if(a*x+b*y==c and abs(x)+abs(y)<=n):
xy.append([x,y])
print (len(xy))
print (xy)
卵の名無しさん [sage] 2018/11/23(金) 18:35:27.02:QoVjbOvp
# ある医院に1時間あたり平均5人の患者が来院し、その人数の分布はポアソン分布にしたがうとする。
# 1時間あたりの平均診療人数は6人(平均診療時間10分)で、一人あたりの診療時間は指数分布に従うとする。
# 診察までの平均の待ち時間は何分か?
λ=5
μ=6

N=1e5
sum(rpois(N,λ)*rexp(N,μ))/N
w8t=replicate(1e3,sum(rpois(N,λ)*rexp(N,μ))/N)*60
summary(w8t)

シミュレーション結果も

> summary(w8t)
Min. 1st Qu. Median Mean 3rd Qu. Max.
49.33 49.88 50.01 50.01 50.14 50.61

理論値通りだな。
卵の名無しさん [sage] 2018/11/23(金) 19:10:32.75:QoVjbOvp
ttp://http://www.f.waseda.jp/sakas/R/ROR/orQueue.html
卵の名無しさん [sage] 2018/11/23(金) 22:53:03.27:t+QLwcrH
1時間に平均値5人の患者がくる医院で
次の患者がくるまでの時間が10分以内である確率と
30分以上である確率はいくらか?
卵の名無しさん [] 2018/11/24(土) 01:25:40.73:5hOk6q/8
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2018/11/24(土) 11:07:29.76:wOJ88Y8z
deli <- function(course=90,hr=15,call=5){
# average 5 calls during 15 hours with 90 min delivery
k=call/hr
integrate(function(x)k*exp(-k*x),0,course/60)$value
}
vd=Vectorize(deli)
dc=0:180
plot(dc,vd(dc),type='l',lwd=2,bty='l',
xlab='Deli.course(min)',ylab='Prob of call')
卵の名無しさん [sage] 2018/11/24(土) 11:42:17.66:wOJ88Y8z
deli <- function(course=90,hr=15,call=5){
# average 5 calls during 15 hours with 90 min delivery
k=call/hr
integrate(function(x)k*exp(-k*x),0,course/60)$value
}
vd=Vectorize(deli)
dc=0:180
plot(dc,vd(dc),type='l',lwd=2,bty='l',
xlab='Deli.course(min)',ylab='Prob of call')

uniroot(function(x,u0=0.5)vd(x)-u0,c(0,180))$root

DH <- function(course=90,hr=15,call=5){
k=call/hr
x=course/60
1-exp(-k*x)
}

p2c=function(p,k=5/15) (-60*log(1-p)/k)
curve(p2c(x),bty='l',xlab='p',ylab='course(min)')
卵の名無しさん [] 2018/11/24(土) 13:12:14.88:owOvYQ4F
このスレの自称医者のほんまもん医師確率は?

検索した知識で医者を騙りMath
ttp://egg.5ch.net/test/read.cgi/hosp/1541780622/
卵の名無しさん [sage] 2018/11/24(土) 14:11:47.95:4kuDQ9FR
こういうのを見ればわかるだろうに

ttps://egg.5ch.net/test/read.cgi/hosp/1499746033/879">ttps://egg.2ch.net/test/read.cgi/hosp/1499746033/879

ttp://i.imgur.com/ztM8yOL.png

馬鹿なのか、馬鹿じゃなきゃ、これにでも答えてみ!

1時間に平均値5人の患者がくる医院で
次の患者がくるまでの時間が10分以内である確率と
30分以上である確率はいくらか?
卵の名無しさん [sage] 2018/11/24(土) 14:18:05.42:4kuDQ9FR


これ用のスクリプト

18時から翌朝9時までの15時間の当直帯に平均5回のコールがある。当直室にデリヘル90分コースで呼んだとすると
デリヘル滞在中にコールされる確率はいくらか?
卵の名無しさん [sage] 2018/11/24(土) 16:38:49.21:wOJ88Y8z
two sample poisson test

パッケージでp値が異なるのでソースを確認。

X=2 ; Y=9
N=17877;M=16660
P=N/(N+M)

poisson.test(c(X,Y),c(N,M))$p.value
binom.test(X,X+Y,P)$p.value

library(rateratio.test)
rateratio.test(c(X,Y),c(N,M))$p.value
2*min(binom.test(X,X+Y,P,alt='l')$p.value,
binom.test(X,X+Y,P,alt='g')$p.value)
卵の名無しさん [sage] 2018/11/24(土) 17:00:00.40:wOJ88Y8z
救急車搬送数が日勤の8時間で0、夜勤の16時間で5であったときに
夜勤帯の方が時間あたり救急搬送が多いと言えるか?
救急車搬送数はポアソン分布に従うとして有意水準5%で検定せよ。

日勤0のとき夜勤で何台以上の搬送があれば有意と言えるか?

rm(list=ls())
library(rateratio.test)
poisson.test(c(0,5),c(8,16))$p.value
rateratio.test(c(0,5),c(8,16))$p.value
x=0:20
y=sapply(x,function(x) poisson.test(c(1,x),c(8,16))$p.value)
plot(x,y,bty='l')
x[which.max(y<0.05)]

y=sapply(x,function(x) rateratio.test(c(1,x),c(8,16))$p.value)
plot(x,y,bty='l')
x[which.max(y<0.05)]
卵の名無しさん [sage] 2018/11/24(土) 17:01:06.35:wOJ88Y8z

日勤と夜勤でお看取り件数に差があるかも検定できるな。
卵の名無しさん [] 2018/11/24(土) 20:15:42.14:mGu7MkO8
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.
卵の名無しさん [sage] 2018/11/24(土) 20:20:35.00:4kuDQ9FR
f = function(A=1,B=2,N=100){
p=0
for (i in 1:N){
for(j in 0:(i-1)){
p=p+dpois(i,A)*dpois(j,B)}}
p
}
f()
f(1,3)
卵の名無しさん [sage] 2018/11/24(土) 20:31:46.81:4kuDQ9FR
soccer= function(A=1,B=2,N=1000){
pa=pd=0
for (i in 1:N){
for(j in 0:(i-1)){
pa=pa+dpois(i,A)*dpois(j,B)
pd=pd+dpois(i,A)*dpois(i,B)
}}
c(Awin=pa,Bwin=1-pa-pd,Draw=pd)
}

soccer()
卵の名無しさん [sage] 2018/11/24(土) 20:39:49.49:4kuDQ9FR

サッカーの勝敗確率
卵の名無しさん [sage] 2018/11/24(土) 20:47:34.09:4kuDQ9FR
debugged

soccer= function(A=5,B=10,N=100){
pa=pd=0
for (i in 1:N){
pd=pd+dpois(i,A)*dpois(i,B)
for(j in 0:(i-1)){
pa=pa+dpois(i,A)*dpois(j,B)

}}
c(Awin=pa,Bwin=1-pa-pd,Draw=pd)
}
卵の名無しさん [] 2018/11/25(日) 02:02:43.79:JOuyBVrN
ポイント乞食ご用達の楽天銀行に貯金していて、
楽天に口座凍結されて無一文になった世田谷のS君 元気??

一応 開業医なのに楽天銀行って  

慶応のOBらが泣いてるよww
卵の名無しさん [sage] 2018/11/25(日) 08:07:10.02:Vr8P87vG
マルコフの確認
(pexp(2+4,1/3)-pexp(2,1/3))/(1-pexp(2,1/3))
pexp(4,1/3)
卵の名無しさん [sage] 2018/11/25(日) 09:08:24.99:B7CJHmdM
k=15
a=20
b=30
(pexp(a+b,1/k)-pexp(a,1/k))/(1-pexp(a,1/k))
pexp(b,1/k)
卵の名無しさん [sage] 2018/11/25(日) 12:02:52.13:9toFqzz4
k=15
a=20
b=30
y=function(x) 1-exp(-x/k)
(y(a+b)-y(a))/(1-y(a))
y(b)
卵の名無しさん [sage] 2018/11/25(日) 12:19:14.40:9toFqzz4

debugged again

soccer= function(A=5,B=10,N=100){
if(A>B){
tmp=A
A=B
B=tmp
}
pa=pd=0
for (i in 1:N){
pd=pd+dpois(i,A)*dpois(i,B)
for(j in 0:(i-1)){
pa=pa+dpois(i,A)*dpois(j,B)

}}
c(Upset=pa,Ordinal=1-pa-pd,Draw=pd)
}
卵の名無しさん [sage] 2018/11/25(日) 12:22:57.28:9toFqzz4
debugged with equivalent routine

soccer= function(A=5,B=10,N=100){
if(A==B) return(c(c(Upset=0,Ordinal=0,Draw=1)))
if(A>B){
tmp=A
A=B
B=tmp
}
pa=pd=0
for (i in 1:N){
pd=pd+dpois(i,A)*dpois(i,B)
for(j in 0:(i-1)){
pa=pa+dpois(i,A)*dpois(j,B)

}}
return(c(Upset=pa,Ordinal=1-pa-pd,Draw=pd))
}
卵の名無しさん [sage] 2018/11/25(日) 12:45:46.33:9toFqzz4

if(A==B) return(c(c(Upset=0,Ordinal=0,Draw=1)))
は不要だな。
卵の名無しさん [sage] 2018/11/25(日) 12:49:45.63:9toFqzz4
サッカーの特典はポアソン分布に従うとされている。

PK戦はなしで考える。

平均得点2点のチームAと平均得点3点のチームBが戦ったとき
Aが勝つ確率、Bが勝つ確率 および 引き分けの確率を求めよ。

得点の上限Nを100として計算。

soccer= function(A=2,B=3,N=100){
if(A>B){
tmp=A
A=B
B=tmp
}
pa=pd=0
for (i in 1:N){
pd=pd+dpois(i,A)*dpois(i,B)
for(j in 0:(i-1)){
pa=pa+dpois(i,A)*dpois(j,B)
}}
return(c(Upset=pa,Ordinal=1-pa-pd,Draw=pd))
}

> soccer(2,3)
Upset Ordinal Draw
0.2469887 0.5920274 0.1609839
卵の名無しさん [sage] 2018/11/25(日) 12:52:38.63:9toFqzz4

1億回シミュレーションしてみた。

> sim <- function(A=2,B=3,K=1e8) {
+ a=rpois(K,A) ; b=rpois(K,B)
+ c(Upset=mean(a>b),Ordinal=mean(a<b),Draw=mean(a==b))
+ }
> sim()
Upset Ordinal Draw
0.2470561 0.5851947 0.1677492

ほぼ同じした結果がでて、気分が( ・∀・)イイ!!
卵の名無しさん [sage] 2018/11/25(日) 14:41:03.20:9toFqzz4
λ0=3/60  # 平均到達率
μ0=4/60 # 平均サービス率 1/μ0 : 平均サービス時間
(ρ0=λ0/μ0) # 平均トラフィック密度


# □ ← ○○○○○○
ρ0/(1-ρ0)*(1/μ0)
ρ0/(1-ρ0)*(1/μ0)+1/μ0

# □ ← ○○○
# □ ← ○○○
(λ1=λ0/2)
(ρ1=λ1/μ0)
ρ1/(1-ρ1)*(1/μ0)
ρ1/(1-ρ1)*(1/μ0)+(1/μ0)

# □ ←
# \
#    ○○○○○
# /
# □ ←
(μ2=2*μ0)
(ρ2=λ0/μ2)
2*ρ2^3/(1-ρ2^2) * (1/μ0)
2*ρ2^3/(1-ρ2^2) * (1/μ0) + (1/μ0)

# □□ ← ○○○○○○
(μ3=2*μ0)
(ρ3=λ0/μ3)
ρ3/(1-ρ3)*(1/μ3)
ρ3/(1-ρ3)*(1/μ3) + (1/μ3)
卵の名無しさん [sage] 2018/11/25(日) 15:33:46.37:9toFqzz4

答えから、指数分布のマルコフ性が導き出されていることを確認
卵の名無しさん [sage] 2018/11/25(日) 21:52:47.06:9toFqzz4
# 10分に2本の割合で電車が到着するダイヤ。
# それぞれの平均待ち時間を求めてみよう
# 5分おきのダイヤでの、平均待ち時間は何分か?
i=j=5
fij <- function(x){
if(x<i) return(i-x)
return(i+j-x)
}
fij=Vectorize(fij)
curve(fij(x),0,10,type='h')
integrate(fij,0,10)$value/10

# 2(=i)分後、8(=j)分後、と電車が到着するダイヤでの平均待ち時間は何分か?
i=2 ; j=8 # 8:00,8:02,8:10,8:12,8:20,...
fij <- function(x){
if(x<i) return(i-x)
return(i+j-x)
}
fij=Vectorize(fij)
curve(fij(x),0,i+j,type='h')
integrate(fij,0,i+j)$value/(i+j)
卵の名無しさん [sage] 2018/11/25(日) 22:09:31.18:9toFqzz4
# 8:15,8:50,9:15,9:50,10:15,10:50....
i=50-15 ; j=60-(50-15)
fij <- function(x){
if(x<i) return(i-x)
return(i+j-x)
}
fij=Vectorize(fij)
curve(fij(x),0,i+j,type='h')
integrate(fij,0,i+j)$value/(i+j)
(i*i/2+(60-i)*j/2)/(i+j)
卵の名無しさん [] 2018/11/25(日) 22:53:07.02:JHTxnUVJ
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.
卵の名無しさん [sage] 2018/11/26(月) 00:38:59.24:ZChMNBQH
数学板の質問スレに俺でも答えられる問題がでるとホッとするな。
簡単すぎて誰も答えないからというのもあるが。
卵の名無しさん [sage] 2018/11/26(月) 01:19:35.09:ZChMNBQH
時刻表から平均待ち時間を算出する。

tt=c(0,10,13,20,23,30,40,47,50,60) # time table
ct2wt <- function(x){ # clock time to waiting time
n=length(tt)
if(x<=tt[1]){w8=tt[1]-x
}else{
for(i in 1:(n-1)){
if(tt[i]<=x & x<=tt[i+1]){
w8=(tt[i+1]-x)
break
}
}}
return(w8)
}
ct2wt=Vectorize(ct2wt)
curve(ct2wt(x),0,60,type='h',bty='l')
integrate(ct2wt,0,60)$value/60
x=diff(tt)
sum(x^2/2)/sum(x)
卵の名無しさん [] 2018/11/26(月) 01:24:22.62:iwt1L6U2
ちっちっ×××× ちっち××××
××××ち××××
へいたんな×× おうとつない
×××だけぷっくりしてるの
あまいあじがするから××てほしいな?
にゃにゃにゃにゃにゃにゃにゃん☆

ちっちっ×××× ちっち××××
××××ち××××
つるつるな×× おにくがない
しるくの×××ごこちなんだ
ほおずりですりすりっとしてほしいな?

×××××でいっぱい××て?
ぜんぶ××××から♪

ちっちっ×××× ちっち××××
××××ち××××
すべすべの×× おおきくない
けんこうにすっごくいいんだよ
ゆびさきで××××ってしてほしいな? 👀
Rock54: Caution(BBR-MD5:1341adc37120578f18dba9451e6c8c3b)
卵の名無しさん [sage] 2018/11/26(月) 07:32:00.16:ZChMNBQH

Haskellの練習

Prelude> let tt = [0,10,13,20,23,30,40,47,50,60]
Prelude> let diff = zipWith (-) (tail tt) (init tt)
Prelude> sum (map (\x -> x^2/2) diff) / sum(diff)
3.95
卵の名無しさん [sage] 2018/11/26(月) 07:50:43.97:ZChMNBQH

python の 練習

import numpy as np
diff=np.diff([0,10,13,20,23,30,40,47,50,60])
print ( sum(map (lambda x: x**2/2,diff))/sum(diff ))
卵の名無しさん [sage] 2018/11/26(月) 07:51:08.82:ZChMNBQH

問題はこれ

東京駅からのぞみ号で朝8時から9時に出発する(9時発も可)。

無作為に選んだ8時台の時間に出発ホームに到着したとすると平均の待ち時間は何分か?

以下が東京8時台発のぞみ号の時刻表である。

8:00 8:10 8:13 8:20 8:23 8:30 8:40 8:47 8:50 9:00
卵の名無しさん [sage] 2018/11/26(月) 18:21:38.38:ZDBUmL4t

この問題を数学板に書いたら応用問題が返ってきた。

ある駅のホームの1番線には1時間ごと、2番線には(1/2)時間ごと、3番線には(1/3)時間ごとに電車が来るようにダイヤを組みたい。
ランダムな時間に駅に着いたときの平均待ち時間を最小にするには、どのようにダイヤを組めば良いか。
ただし、何番線の電車に乗っても向かう方向や停車駅に違いは無いとする。

プログラミングで簡単に解けた。

w8 <- function(xy,Print=FALSE){
x=xy[1];y=xy[2]
if(x<0|x>20|y<0|y>30)return(Inf)
tt=c(0,x,x+20,x+40,y,y+30,60)
tt=sort(tt)
d=diff(tt)
w=sum(d^2/2)/sum(d)
if(Print){
print(tt)
cat(sum(d^2/2),'/',sum(d))
}
return(w)
}
optim(par=c(0,0),w8,method='Nelder-Mead')
w8(c(10,15),P=T)
optim(par=c(0,0),w8,method='Nelder-Mead',control=list(fnscale=-1))
w8(c(0,0),P=T)
卵の名無しさん [] 2018/11/26(月) 19:10:20.76:WZnn9Mtx
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.
卵の名無しさん [sage] 2018/11/26(月) 20:45:26.65:G0yfFsA6

1時間に4本の4番線にも拡大できるようにプログラムを一般化。

densha <- function(init,Print=FALSE){
init=c(0,init)
J=length(init)
if(any(init*(1:J)>60)|any(init<0)) return(60)
H=list()
for(i in 1:J){
H[[i]]=init[i]+60/i*(0:(i-1))
}
tt=sort(unlist(H))
tt=c(tt,tt[1]+60)
d=diff(tt)
w=sum(d^2/2)/sum(d)
if(Print){
print(H)
cat(sum(d^2/2),'/',sum(d),'\n')
}
return(w)
}
densha(c(15,10),P=T)
optim(par=c(10,10,10),densha,method='BFGS')
densha(c(15,10,7.5),P=T)
卵の名無しさん [sage] 2018/11/27(火) 08:33:47.65:WzO5TT32
Pn(t)=rho^n/n!P0(t) ,1<=n<=s

Pn(t)=rho^n/s!s^(n-s)P0(t) , n>=s

P0(t)= 1/{sigma[n=0,n=s]rho^m/n! + rho^(s+1)/(s!(s-rho))}

ttp://http://www.geocities.co.jp/Technopolis-Mars/5427/math/sw_waitque5.html
卵の名無しさん [sage] 2018/11/27(火) 08:48:31.40:WzO5TT32
Pn(t)=rho^n/n!P0(t) ,1<=n<=s

Pn(t)=rho^n/(s!s^(n-s))P0(t) , n>=s

P0(t)= 1/{sigma[n=0,n=s]rho^n/n! + rho^(s+1)/(s!(s-rho))}

ttp://http://www.geocities.co.jp/Technopolis-Mars/5427/math/sw_waitque5.html

MMS = function(t, n, lamda,mu,s){
rho=lamda/mu
sig=0
for(i in 0:n) sig=sig+rho^i/factorial(i)
p0t=1/( sig + rho^(s+1)/factorial(s)/(s-rho) )
ifelse(n >= s, rho^n/factorial(s)/s^(n-s)*p0t, rho^n/factorial(n)*p0t)
}
卵の名無しさん [sage] 2018/11/27(火) 09:47:23.68:WzO5TT32
MMS = function(n, lamda=1/20,mu=1/10,s=3){
rho=lamda/mu
sig=0
for(i in 0:s) sig=sig+rho^i/factorial(i)
p0=1/( sig + rho^(s+1)/factorial(s)/(s-rho) )
ifelse(n >= s, rho^n/factorial(s)/s^(n-s)*p0, rho^n/factorial(n)*p0)
}
1-sum(sapply(0:3,MMS))
卵の名無しさん [sage] 2018/11/27(火) 09:48:36.29:WzO5TT32
演習問題
&#61550; 問題
&#61550; 電話回線のチケット予約システムがあり、その窓口数は3であ

&#61550; 予約の電話は平均して20秒に1回
&#61550; 窓口は1件あたり10秒必要
&#61550; 予約時3つの窓口がすべて応対中であれば話中になる
&#61550; このシステム全体を損失系M/M/3とみなせるとする

このとき、
&#61550; 話中である確率を求めなさい
&#61550; 話中となる確率を1%未満とするには、窓口はいくつ必要です
か?
卵の名無しさん [sage] 2018/11/27(火) 09:56:32.58:WzO5TT32
MMS = function(n, lamda=1/20,mu=1/10,s=3){
rho=s*lamda/mu
sig=0
for(i in 0:s) sig=sig+rho^i/factorial(i)
p0=1/( sig + rho^(s+1)/factorial(s)/(s-rho) )
ifelse(n >= s, rho^n/factorial(s)/s^(n-s)*p0, rho^n/factorial(n)*p0)
}
1-sum(sapply(0:3,MMS))
卵の名無しさん [sage] 2018/11/27(火) 09:57:04.81:WzO5TT32
MMS = function(n, lamda=1/20,mu=1/10,s=3){
rho=s*lamda/mu
sig=0
for(i in 0:s) sig=sig+rho^i/factorial(i)
p0=1/( sig + rho^(s+1)/factorial(s)/(s-rho) )
ifelse(n >= s, rho^n/factorial(s)/s^(n-s)*p0, rho^n/factorial(n)*p0)
}
1-sum(sapply(0:3,MMS))
卵の名無しさん [sage] 2018/11/27(火) 09:59:56.71:WzO5TT32
MMS = function(n, λ=1/20,μ=1/10,s=3){
ρ=s*λ/μ
sig=0
for(i in 0:s) sig=sig+ρ^i/factorial(i)
p0=1/( sig + ρ^(s+1)/factorial(s)/(s-ρ) )
ifelse(n >= s, ρ^n/factorial(s)/s^(n-s)*p0, ρ^n/factorial(n)*p0)
}
1-sum(sapply(0:3,MMS))
卵の名無しさん [sage] 2018/11/27(火) 10:36:18.18:WzO5TT32
MMS = function(n, λ=1/20,μ=1/10,s=3){
ρ=λ/μ
sig=0
for(i in 0:s) sig=sig+ρ^i/factorial(i)
p0=1/( sig + ρ^(s+1)/factorial(s)/(s-ρ) )
ifelse(n >= s, ρ^n/factorial(s)/s^(n-s)*p0, ρ^n/factorial(n)*p0)
}
卵の名無しさん [sage] 2018/11/27(火) 11:23:34.49:WzO5TT32
draft

.lambda=1/20
.mu=1/10
.s=1
MMS = function(n, lambda=.lambda ,mu=.mu,s=.s){
rho=lambda/mu
sig=0
for(i in 0:s) sig=sig+rho^i/factorial(i)
p0=1/( sig + rho^(s+1)/factorial(s)/(s-rho) )
ifelse(n >= s, rho^n/factorial(s)/s^(n-s)*p0, rho^n/factorial(n)*p0)
}

now8=function(x){
p=0
for(i in 0:x) p=p+MMS(i,s=x)
}

1-now8(1)

E=0
for(i in 0:1e4) E=E+i*MMS(i)
E*(1/.mu)

n=(1:10)[which.max(sapply(1:10,now8)>0.9)]
now8(n)
卵の名無しさん [sage] 2018/11/27(火) 12:44:46.57:RTIAbEXI
”お待たせしません”を謳い文句にした真面耶馬医院で
患者の来院は平均して20分に1人、診療は1人あたり10分とする。
診察医は一人。
謳い文句に反して患者が待たされる確率は?
患者の平均待ち時間は?
待たされる確率を10%以下にするには何人の医師が必要か?
待ち時間を3分以下にするには何人の医師が必要か?

lambda=1/20;mu=1/10
MMS = function(n, lambda ,mu, s){
rho=lambda/mu # rho < s
sig=0
for(i in 0:s) sig=sig+rho^i/factorial(i)
p0=1/( sig + rho^(s+1)/factorial(s)/(s-rho) )
# Pn : probability of n guests in system
Pn=ifelse(n >= s, rho^n/factorial(s)/s^(n-s)*p0, rho^n/factorial(n)*p0)
Ps=rho^s/factorial(s)*p0
L=rho + Ps*s*rho/(s-rho)^2 # guests in system
Lq=Ps*s*rho/(s-rho)^2 # guests in que
Wq=Lq/lambda # waiting time in que
c(`Pn(t)`=Pn,L=L,Lq=Lq,Wq=Wq)
}

# No Wait Probability when s=x
nwp=function(x,lambda,mu){
p=0
for(i in 0:x) p=p+MMS(i,lambda,mu,s=x)
p
}
nwp(1,lambda,mu)
nwp(2,lambda,mu)
卵の名無しさん [sage] 2018/11/27(火) 13:05:37.04:RTIAbEXI
問題(第1種情報処理技術者試験・平成元年度春期午前問17を改題)

ある医院では、患者が平均10分間隔でポアソン到着にしたがって訪ねてくることがわかった。
医者は1人であり、1人の患者の診断及び処方にかかる時間は平均8分の指数分布であった。

設問1 患者が待ち始めてから、診断を受け始めるまでの「平均待ち時間」を求めなさい。

設問2 待っている患者の平均人数を求めなさい。

設問3 患者の「平均待ち時間」が60分となるような平均到着間隔は約何分か?秒単位を
      切り捨てた値を答えなさい。

これに 
設問4  「平均待ち時間」を10分以下にするには同じ診察効率の医師が何人に必要か?
卵の名無しさん [sage] 2018/11/27(火) 13:53:38.67:RTIAbEXI
# ある医院では、患者が平均10分間隔でポアソン到着にしたがって訪ねてくることがわかった。
# 医者は1人であり、1人の患者の診療にかかる時間は平均8分の指数分布であった。
# 「平均待ち時間」を5分以下にするには同じ診察効率の医師が何人に必要か?
# その最小人数で「平均待ち時間」を5分以下に保って診療するには1時間に何人まで受付可能か?
sapply(1:3,function(x) MMS(0,1/10,1/8,x)['Wq'])
MMS(0,1/10,1/8,s=2)
f= function(l) MMS(0,l,mu=1/8,s=2)['Wq']
v=Vectorize(f)
curve(v(x),bty='l',0,2/8) # rho=l/m < s , l < s*m
abline(h=5,lty=3)
60*uniroot(function(x)v(x)-5,c(0.1,0.2))$root
MMS(0,9.3/60,mu=1/8,s=2)
卵の名無しさん [sage] 2018/11/27(火) 15:40:44.01:RTIAbEXI
# M/M/S(s)
MMSs <- function(n,lambda,mu,s){
if(n > s) return(0)
rho=lambda/mu # rho < s
sig=0
for(i in 0:s) sig=sig+rho^i/factorial(i)
Pn=rho^n/factorial(n)/sig
return(Pn)
}
s=3
sapply(0:s,function(x) MMSs(x,1/20,1/10,s))
cnvg=function(x,lambda,mu) MMSs(x,lambda,mu,x) # 輻輳 convergence
vc=Vectorize(function(x) cnvg(x,10/60,1/30))
(1:10)[vc(1:10) < 0.05]
卵の名無しさん [] 2018/11/27(火) 18:51:54.59:sOmaXwxS
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2018/11/27(火) 20:30:45.92:RTIAbEXI
mms <- function(n,lambda,mu,s,t=0,Print=TRUE){
alpha=lambda/mu
rho=lambda/s/mu # alpha=s*rho
sig0=0
for(i in 0:(s-1)) sig0=sig0+alpha^i/factorial(i)
P0=1/( sig0 + alpha^s/factorial(s-1)/(s-alpha) )
Pn=ifelse(n >= s, alpha^n/factorial(s)/s^(n-s)*P0, alpha^n/factorial(n)*P0)
Lq=lambda*mu*alpha^s/factorial(s-1)/(s*mu-lambda)^2*P0
L=Lq+alpha
Wq=Lq/lambda
#=mu*alpha^s/factorial(s-1)/(s*mu-lambda)^2*P0
W=Wq+1/mu
Pc=mu*P0*alpha^s/factorial(s-1)/(s*mu-lambda)
#=s^s*P0/factorial(s)*rho^s/(1-rho)
PTt=Pc*exp(-(1-rho)*s*mu*t)
output=c(P0=P0,Pn=Pn,Lq=Lq,L=L,Wq=Wq,W=W,Pc=Pc,PTt=PTt)
# P0:0 in system, Pn:n in system, Lq:guests in que, Wq: waiting time in que
# L:quests in system, W:total waiting time, Pc:all windows occupied,
# P: waiting time in que greater than t
if(Print) print(output,digits=3)
invisible(output)
}
mms(n=0,lambda=1/60,mu=1/10,s=1,t=0)
卵の名無しさん [] 2018/11/27(火) 20:40:29.10:2tUinJG4
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2018/11/27(火) 21:06:39.05:RTIAbEXI
レジが1台ある。客の到着が1時間あたり平均12人であり、
レジの所要時間が平均3分のとき,次の値を求めてみよう。
?到着したとき,すぐにサービスが受けられる確率
?系の中にいる人の平均人数
?サービスを待っている人の平均人数
?到着してからサービスを受けて去るまでの平均時間

?到着してからサービスを受けるまでの平均待ち時間
?客の到着が2倍の平均24人になった。到着してからサービスを受けて去るまでの平均時間を変えないようにするには
レジの平均サービス時間を何分にすればよいか?求めてみよう。
卵の名無しさん [sage] 2018/11/27(火) 21:08:46.15:RTIAbEXI
筆算は面倒。数値を変えても算出できるようにした。

mms <- function(n,lambda,mu,s,t=0,Print=TRUE){
alpha=lambda/mu
rho=lambda/s/mu # alpha=s*rho
sig0=0
for(i in 0:(s-1)) sig0=sig0+alpha^i/factorial(i)
P0=1/( sig0 + alpha^s/factorial(s-1)/(s-alpha) )
Pn=ifelse(n >= s, alpha^n/factorial(s)/s^(n-s)*P0, alpha^n/factorial(n)*P0)
Lq=lambda*mu*alpha^s/factorial(s-1)/(s*mu-lambda)^2*P0
L=Lq+alpha
Wq=Lq/lambda
#=mu*alpha^s/factorial(s-1)/(s*mu-lambda)^2*P0
W=Wq+1/mu
Pc=mu*P0*alpha^s/factorial(s-1)/(s*mu-lambda)
#=s^s*P0/factorial(s)*rho^s/(1-rho)
PTt=Pc*exp(-(1-rho)*s*mu*t)
output=c(P0=P0,Pn=Pn,Lq=Lq,L=L,Wq=Wq,W=W,Pc=Pc,PTt=PTt)
# P0:0 in system, Pn:n in system, Lq:guests in que, Wq: waiting time in que
# L:quests in system, W:total waiting time, Pc:all windows occupied,
# P: waiting time in que greater than t
if(Print) print(output,digits=3)
invisible(output)
}

> mms(0,12/60,1/3,1)
P0 Pn Lq L Wq W Pc PTt
0.4 0.4 0.9 1.5 4.5 7.5 0.6 0.6
> uniroot(function(x) mms(0,24/60,1/x,1,P=F)['W']-7.5,c(0.1,2))$root
[1] 1.874993
卵の名無しさん [sage] 2018/11/27(火) 23:07:59.15:RTIAbEXI
# M/M/s/K
MMSK <- function(lambda,mu,s,k){
alpha=lambda/mu
sig1=sig2=0
for(n in 0:s) sig1=sig1+alpha^n/factorial(n)
if(k>s) for(n in 1:(k-s)) sig2=sig2+alpha^s/s*(alpha/s)^n
Psk=s^s/factorial(s)*(alpha/s)^k/(sig1+sig2)
return(Psk)
}

MMSK(lambda=1/20,mu=1/10,s=3,k=3)
MMSS(n=3,l=1/20,m=1/10,s=3)
E2s <- function(alpha,s) MMSK(alpha,1,s,s)
E2s(0.5,3) # call loss, convergence α^s/s! / Σ[n=0,s]a^n/n!

a=seq(0,3,len=101)
plot(a,sapply(a,function(x)E2s(x,s=1)),type='l',bty='l',ylab='call loss prob.')
lines(a,sapply(a,function(x)E2s(x,s=2)),lty=2)
lines(a,sapply(a,function(x)E2s(x,s=3)),lty=3)
卵の名無しさん [] 2018/11/27(火) 23:08:01.08:yIHJQdw7
音楽の問題です

アヘ顔ダブルPEA〜〜〜CE
v(゜∀。)v
卵の名無しさん [sage] 2018/11/28(水) 07:55:01.98:5n5kFcMp
f <- function() sum(rbinom(10,3,1/3)==rbinom(10,3,1/3))
g <- function(k) mean(replicate(k,f()))
h=Vectorize(g)
x=seq(1000,100000,by=1000)
re=h(x)
plot(x,re,pch=19,bty='l',ann=F)
卵の名無しさん [sage] 2018/11/28(水) 08:08:55.83:5n5kFcMp
f <- function() sum(rbinom(10,3,1/3)==rbinom(10,3,1/3))
g <- function(k) mean(replicate(k,f()))
h=Vectorize(g)
x=seq(1000,100000,by=1000)
re=h(x)
plot(x,re,pch=19,bty='l',ann=F)

x=rep(100,10000)
y=h(x)
cx=cumsum(x)
cy=cumsum(y)/1:10000
plot(cx,cy,type='l')
卵の名無しさん [sage] 2018/11/28(水) 13:47:18.06:5n5kFcMp
rm(list=ls())
n=10 ; lambda=10/60 ; mu=1/8
# service starc clock time(ssct) since 9:00
ssct=numeric(n)
# waiting time(w8)
w8=numeric(n)
# service end clock time(sect)
sect=numeric(n)
# arrival clock time(act)
set.seed(1234) ; act=round(cumsum(rexp(n,lambda)))
# duration of service(ds)
set.seed(5678) ; ds=round(rexp(n,mu))

# step by step
act
ds
ssct[1]=act[1] # 9:15
sect[1]=act[1]+ds[1] # 9:25

act[2] # 9:16
max(sect[1]-act[2],0) # 9:25-9:16 vs 0
w8[2]=max(sect[1]-act[2],0) # 9 min
ssct[2]=max(sect[1],act[2]) # 9:25 vs 9:16
sect[2]=ssct[2]+ds[2] # 9:25 + 8 = 9:33

act[3] # 9:17
max(sect[2]-act[3],0) # 9:33 - 9:17 vs 0
w8[3]=max(sect[2]-act[3],0) # 16 min
ssct[3]=max(sect[2],act[3]) # 9:33 vs 9:17
sect[3]=ssct[3]+ds[3] # 9:33 + 11 = 9:44
卵の名無しさん [sage] 2018/11/28(水) 15:01:41.58:5n5kFcMp
# ある医院に1時間あたり平均5人の患者が来院し、その人数の分布はポアソン分布にしたがうとする。
# 1時間あたりの平均診療人数は6人で、一人あたりの診療時間は指数分布に従うとする。
# 診察までの平均の待ち時間は何時間か?

rm(list=ls())

# Five patients comes every hour on average to the clinic,
# and the single physicaina treats six patients every hour on average.
# n=40 ; lambda=5/60 ; mu=6/60

MM1sim <- function(n=40,lambda=5/60,mu=6/60,seed=FALSE,Print=TRUE){
# service starc clock time(ssct) since 9:00
ssct=numeric(n)
# waiting time(w8)
w8=numeric(n)
# service end clock time(sect)
sect=numeric(n)
# arrival clock time(act)
if(seed) set.seed(1234) ;
act=round(cumsum(rexp(n,lambda)))
# duration of service(ds)
if(seed) set.seed(5678) ;
ds=round(rexp(n,mu))

# simulation assuming service starts at 9:00
head(act) # act : arrival clock time
head(ds) # ds : duration of service
# initial values
ssct[1]=act[1] # 9:15 service start clock time for 1st guest
sect[1]=act[1]+ds[1] # 9:25 sevice end clock time for 1st guest
w8[1]=0
卵の名無しさん [sage] 2018/11/28(水) 15:02:14.90:5n5kFcMp
# simulation step by step
#
# act[2] # 9:16 arrival clock time of 2nd
# max(sect[1]-act[2],0) # 9:25-9:16 vs 0 = ?sevice for 1st ends b4 2nd arrival
# w8[2]=max(sect[1]-act[2],0) # 9 min : w8ing time of 2nd
# ssct[2]=max(sect[1],act[2]) # 9:25 vs 9:16 = service start clock time for 2nd
# sect[2]=ssct[2]+ds[2] # 9:25 + 8 = 9:33 service end clock time for 2nd
#
# act[3] # 9:17 arrival clock time of 3rd
# max(sect[2]-act[3],0) # 9:33 - 9:17 vs 0 = ?serivce for 2nd ends b4 3rd arrival?
# w8[3]=max(sect[2]-act[3],0) # 16 min : w8ting time of 3rd
# ssct[3]=max(sect[2],act[3]) # 9:33 vs 9:17 = service start clock time for 3rd
# sect[3]=ssct[3]+ds[3] # 9:33 + 11 = 9:44 service end clock time for 3rd
#

for(i in 2:n){
w8[i]=max(sect[i-1]-act[i],0)
ssct[i]=max(sect[i-1],act[i])
sect[i]=ssct[i]+ds[i]
}
if(Print){
print(summary(w8))
hist(w8,freq=FALSE,col="lightblue",main="")
}
invisible(w8)
}

w8m=replicate(1e3,mean(MM1sim(P=F)))
summary(w8m)
卵の名無しさん [sage] 2018/11/28(水) 19:33:11.50:5n5kFcMp

行列の長さが変わらない定常状態達したら理論値通りに動作しているようだ。
エラー処理はしていなし、細かいバグがあるかもしれないが、
一応完成。

ttp://https://www.tutorialspoint.com/tpcg.php?p=7psmrQ
卵の名無しさん [] 2018/11/28(水) 21:10:01.72:CEw4d3xR
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2018/11/29(木) 13:46:13.50:vdx9uljL
待ち行列理論の公式って
待ち行列の長さが変わらない定常状態での計算値だなぁ。

こういう設定に適応していいのか疑問があるな。
# Five clients comes every hour on average to the office,
# and the single clerk serves six clients every hour on average.
# n=40 ; lambda=5/60 ; mu=6/60
卵の名無しさん [sage] 2018/11/29(木) 13:47:25.88:vdx9uljL
シミュレーターを改良

MM1sim <- function(n=40,lambda=5/60,mu=6/60,
Lcount=FALSE,seed=FALSE,Brief=TRUE,Print=TRUE,Round=FALSE){
# n: how many clients, lambda: clients per hour, mu: service per hour
# Lcont: calculate clients in que, seed: ?set.seed
# Brief: ?show summary, Print: ?print graphs, Round: ?round result
# service starc clock time(ssct) since 9:00
ssct=numeric(n)
# waiting time in que(Wq)
Wq=numeric(n)
# waiting time from arrival to service end(W)
W=numeric(n)
# service end clock time(sect)
sect=numeric(n)
# arrival clock time(act)
if(seed) set.seed(1234)
act=cumsum(rexp(n,lambda)) ; if(Round) act=round(act)
# duration of service(ds)
if(seed) set.seed(5678)
ds=rexp(n,mu) ; if(Round) ds=round(ds)

# initial values
ssct[1]=act[1] # 9:15 service start clock time for 1st guest
sect[1]=act[1]+ds[1] # 9:25 sevice end clock time for 1st guest
Wq[1]=0
卵の名無しさん [sage] 2018/11/29(木) 13:47:48.53:vdx9uljL
for(i in 2:n){
Wq[i]=max(sect[i-1]-act[i],0)
ssct[i]=max(sect[i-1],act[i])
sect[i]=ssct[i]+ds[i]
}
W=Wq+ds
L=Lq=NA
if(Lcount){
ct2Lq <- function(ct){ # ct:clock time to Lq
sum(act<ct & ct<ssct)
}
Lq=mean(sapply(seq(0,max(ssct),len=1e4),ct2Lq)) # average clients in que
ct2L <- function(ct){ # ct:clock time to Lq
sum(act<ct & ct<sect)
}
L=mean(sapply(seq(0,max(ssct),len=1e4),ct2L)) # average clients in que
}
if(Brief){
cat("Lq = ",Lq,'\n',"summary of Waiting in que \n")
print(summary(Wq))
cat("L = ",L,'\n',"summary of total time since arrival \n")
print(summary(W))}
卵の名無しさん [sage] 2018/11/29(木) 13:48:05.65:vdx9uljL
if(Print){
par(mfrow=c(2,2))
hist(Wq,freq=FALSE,col="lightblue",main="Waiting time in que")
hist(W,freq=FALSE,col="lightgreen",main="Total time since arrival")
plot(sect,1:n,type='n',bty='l',ylab="client",xlab='clock time',
main=paste('average waiting time :',round(mean(Wq),2)))
segments(y0=1:n,x0=act,x1=ssct,col='gray')
points(act,1:n,pch=1)
points(ssct,1:n,pch=19)
points(sect,1:n,pch=3,cex=0.6)
legend('bottomright',bty='n',legend = c('arrival','service start','service end'),pch=c(1,19,3))
if(Lcount){ct=seq(0,max(ssct),len=1e4)
plot(ct,sapply(ct,ct2Lq),xlab="clock time",ylab="",main="clients in que",
type='s',bty='l')}
par(mfrow=c(1,1))
}
output=list(Wq=Wq,W=W,Lq=Lq,L=L,arrival=act,start=ssct,end=sect,duration=ds)
invisible(output)
}
MM1sim(n=40,Lcount=T,R=T,P=T,seed=F)
卵の名無しさん [sage] 2018/11/29(木) 14:01:23.60:vdx9uljL
来院数がポアソン分布(来院間隔は指数分布)、
診療時間はそれまでの患者の診療時間に影響されない(マルコフ性とか無記憶性と呼ばれる)ので指数分布
と仮定して、1時間に5人受診、診療時間は10分を平均値として受診数を40人としてシミュレーションすると
こんなにばらついた。
ttps://i.imgur.com/2HSJiRL.png
ttps://i.imgur.com/aG4ySWl.png
待ち時間行列理論でクリニックの待ち時間計算すると現実と大きく乖離すると思える。
卵の名無しさん [sage] 2018/11/29(木) 14:23:01.20:vdx9uljL
来院数がポアソン分布(来院間隔は指数分布)、
診療時間はそれまでの患者の診療時間に影響されない(マルコフ性とか無記憶性と呼ばれる)ので指数分布
と仮定して、1時間に5人受診、診療時間は10分を平均値として受診数を40人としてシミュレーション。

その結果

診療までの待ち時間
> summary(Wqm)
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.793 11.828 19.204 26.041 34.621 164.905
診療終了までの時間
> summary(Wm)
Min. 1st Qu. Median Mean 3rd Qu. Max.
7.952 20.296 29.359 35.335 44.600 161.234
診療待ちの人数
> summary(Lqm)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.1821 0.8501 1.5866 2.0976 2.7414 11.2506
卵の名無しさん [sage] 2018/11/29(木) 14:52:35.68:vdx9uljL
受診者数と平均待ち時間をシミュレーションしてみた。
受診者数が増えれば待ち行列時間の理論値50分に収束していくようだ。

ttps://i.imgur.com/iFN6eAN.png
卵の名無しさん [sage] 2018/11/29(木) 17:16:02.63:pxHQyZHt
sim = function(){
x=cumsum(rexp(5,5/15))
x[4] < x[3]+1
}
mean(replicate(1e5,sim()))

pexp(1,5/15)
卵の名無しさん [sage] 2018/11/29(木) 19:04:59.01:vdx9uljL

定常状態での理論値
mms <- function(n,lambda,mu,s,t=0,Print=TRUE){
alpha=lambda/mu
rho=lambda/s/mu # alpha=s*rho
sig0=0
for(i in 0:(s-1)) sig0=sig0+alpha^i/factorial(i)
P0=1/( sig0 + alpha^s/factorial(s-1)/(s-alpha) )
Pn=ifelse(n >= s, alpha^n/factorial(s)/s^(n-s)*P0, alpha^n/factorial(n)*P0)
Lq=lambda*mu*alpha^s/factorial(s-1)/(s*mu-lambda)^2*P0
L=Lq+alpha
Wq=Lq/lambda
#=mu*alpha^s/factorial(s-1)/(s*mu-lambda)^2*P0
W=Wq+1/mu
Pc=mu*P0*alpha^s/factorial(s-1)/(s*mu-lambda)
#=s^s*P0/factorial(s)*rho^s/(1-rho)
PTt=Pc*exp(-(1-rho)*s*mu*t)
output=c(P0=P0,Pn=Pn,Lq=Lq,L=L,Wq=Wq,W=W,Pc=Pc,PTt=PTt)
# P0:0 in system, Pn:n in system, Lq:guests in que, Wq: waiting time in que
# L:quests in system, W:total waiting time, Pc:all windows occupied,
# P: waiting time in que greater than t
if(Print) print(output,digits=3)
invisible(output)
}

> mms(0,5/60,6/60,1)
P0 Pn Lq L Wq W Pc PTt
0.167 0.167 4.167 5.000 50.000 60.000 0.833 0.833
卵の名無しさん [] 2018/11/29(木) 21:16:08.05:W5xHj2Da
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2018/11/30(金) 10:07:25.16:c4eruZjZ
rm(list=ls())
graphics.off()
par(mfrow=c(1,2))
a=360 ; b=1
R = function(t) ifelse(0<=t&t<=2*b,-a*t*(t-2*b),0)
N = integrate(R,0,2*b)$value ; (N=4*a*b^3/3)
A = function(t) ifelse(0<=t&t<=2*b,-a*t^3/3 +a*b*t^2,N)
curve(A(x),0,3,lwd=2,bty='l',xlab='t')
mu=100
n.win=2
c=n.win*mu
curve(R(x),0,3,lwd=2,bty='l',xlab='t') ; abline(h=2:3*mu,lty=1:2)
uniroot(function(t) R(t)-c,c(0,1))$root
d = sqrt(b^2-c/a)
t1 = b - d ; t1
Q <- function(t) A(t)-A(t1)-c*(t-t1)
curve(Q(x),0,3,bty='l') ; abline(h=0,col=8)
Q. <- function(t) -a*(t-t1)^3/3 + a*d*(t-t1)^2
curve(Q.(x),0,3,bty='l') ; abline(h=0,col=8)
optimize(Q,c(0,1))$minimum
uniroot(Q,c(1,3))$root ; t1+3*d ; (t4.1=b+2*d)
Q(2*b)/c +2*b; (t4.2=a/3/c*(b+d)^2*(2*d-b) +2*b)
par(mfrow=c(1,1))
curve(A(x),0,3,lwd=2,bty='l',xlab='t')
curve(x*N/t4.1,add=T)
integrate(Q.,t1,t4.1)$value ; 9/4*a*d^4
integrate(Q.,t1,2*b)$value + 1/2*(t4.2-2*b)*Q.(2*b) ; a/36*(b+d)^3/(b-d)*(4*b*d-b^2-d^2)
integrate(Q.,t1,t4.1)$value/N
(integrate(Q.,t1,2*b)$value + 1/2*(t4.2-2*b)*Q.(2*b))/N

min(9/4*a*d^4,a/36*(b+d)^3/(b-d)*(4*b*d-b^2-d^2))/N
卵の名無しさん [sage] 2018/11/30(金) 10:11:24.11:c4eruZjZ
c2Wq <- function(c,a=360,b=1){ #-> Wq:平均待ち時間
# R(t): 到着率関数 -at(t-2b)
# c:サービス率
R = function(t) ifelse(0<=t&t<=2*b,-a*t*(t-2*b),0)
N=4*a*b^3/3
d = sqrt(b^2-c/a)
min(case1=9/4*a*d^4/N,case2=a/36*(b+d)^3/(b-d)*(4*b*d-b^2-d^2)/N)
}
c2Wq(300)
卵の名無しさん [sage] 2018/11/30(金) 14:10:17.12:c4eruZjZ
rm(list=ls())
graphics.off()
par(mfrow=c(2,1))
a=360 ; b=1 # R(t) at(t-2b) 到着率関数[0,2b]
R = function(t) ifelse(0<=t&t<=2*b,-a*t*(t-2*b),0)
curve(R(x),0,3,bty='l',xlab='t')
N = integrate(R,0,2*b)$value ; 4*a*b^3/3 # 総人数
A = function(t) ifelse(t<=2*b,-a*t^3/3 +a*b*t^2,N) # 流入関数=∫Rdt
# = integerate(function(t) R(t),0,t) 0<t<2b
curve(A(x),0,3,bty='l',xlab='t')
mu=100 # 一窓口当たりのサービス率
n.win=2 # 窓口数
c=n.win*mu # 全サービス率
curve(R(x),0,3,bty='l',xlab='t') ; abline(h=2:3*mu,lty=1:2,col=8)
legend('center',bty='n',legend=c("2窓口","3窓口"),lty=c(1,2),col=8)
uniroot(function(t) R(t)-c,c(0,1))$root # 行列>0 : 流入率>サービス率
d = sqrt(b^2-c/a)
t1 = b - d ; t1 # 行列の始まる時刻(解析値) : 流入率=サービス率
Q <- function(t) A(t)-A(t1)-c*(t-t1) # 行列の人数 定義域無視
curve(Q(x),0,3,bty='l',xlab='t')
optimize(Q,c(0,1))$minimum
# 行列の終わる時刻
uniroot(Q,c(1,1e6))$root
t4 = ifelse(2*d<b,b+2*d,a/3/c*(b+d)^2*(2*d-b) +2*b) ; t4 #解析値
 # 行列終了時刻 t4 < 2b : 入場締切前に行列0 (2*d<b)
if(2*d<b) c(t1+3*d, b+2*d)
 # 行列終了時刻 t4 > 2b : 入場締切後に行列0 (2*d>b)
 if(2*d>b) c(Q(2*b)/c +2*b, a/3/c*(b+d)^2*(2*d-b) +2*b)
Q <- function(t) ifelse(t1<=t & t<=t4 ,A(t)-A(t1)-c*(t-t1),0) # 行列の人数[t1,t4]
curve(Q(x),0,3,bty='l',type='h',xlab='t',ylab="Wq",col='navy')
卵の名無しさん [sage] 2018/11/30(金) 14:12:35.52:c4eruZjZ
Q.<- function(t){
if(t1<=t & t<= min(t4,2*b)) -a*(t-t1)^3/3 + a*d*(t-t1)^2}
# -a*(t-t1)^3/3 + a*d*(t-t1)^2 # 解析値[t1,min(t4,2b)]
tt=seq(t1,min(t4,2*b),len=1000)
lines(tt,sapply(tt,Q.),bty='l',type='l',xlab='t',ylab='Wq')

par(mfrow=c(1,1))
curve(A(x),0,3,bty='l',ylab='person',xlab='t',lwd=1,
main="到着率:at(t-2b) サービス率:200") # 累積入場者
curve(Q(x),0,3,col='navy',add=T,lwd=1,lty=3,type='h') # 待ち人数
tt=seq(0,3,len=1000)
lines(tt,sapply(tt,function(t)A(t)-Q(t)),lwd=2,col=4)
legend('right',bty='n',legend=c("流入総数","流出総数","待ち人数"),
col=c(1,4,1),lty=c(1,1,3),lwd=c(1,2,1))
integrate(Q,t1,t4)$value # 総待ち時間(=縦軸方向積分面積Area under curve)
Wtotal=ifelse(2*d<b,9/4*a*d^4,a/36*(b+d)^3/(b-d)*(4*b*d-b^2-d^2)) ; Wtotal
Wq=Wt/N ; Wq
卵の名無しさん [sage] 2018/11/30(金) 14:22:24.86:c4eruZjZ
数式を追うだけだと身につかないからプログラムに入力して自分でグラフを書いてみると理解が捗る。
自分がどこができていないもよく分かる。必要な計算ができないとグラフが完成できないから。
プログラムしておくとあとで数値を変えて再利用できるのが( ・∀・)イイ!!

ttps://i.imgur.com/P3jWTLx.png
卵の名無しさん [] 2018/11/30(金) 21:39:40.37:kXCX0lfh
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.
卵の名無しさん [sage] 2018/11/30(金) 23:12:28.51:c4eruZjZ
#
source('tmp.tools.R') # 乱数発生にNeumann法
# 受付時間9:00-12:30,15:30-19:00
curve(10*(dgamma(x-9,2,1)+dgamma(x-16,8,5)),9,20,type='h') # 雛形
R <- function(x) ifelse((9<x&x<12.5)|(15.5<x&x<19),dgamma(x-9,2,1)+dgamma(x-16,8,5),0)
set.seed(123) ; data=vonNeumann2(function(x) R(x),9,19,Print=F)
N=100 # 来院患者数
n.win=1 # サービス窓口数
mu=8 # サービス率(1時間診察人数)
client=hist(data,freq=F,breaks=30,col='skyblue',main='',xlab='clock time')
breaks=client$breaks
y=client$counts/sum(client$counts)*N # 総数をN人に
# 到達率関数,離散量を連続関数に
R <- function(x) ifelse((9<x&x<12.5)|(15.5<x&x<19),y[which.max(x<=breaks)-1],0)
R=Vectorize(R)
curve(R(x),9,20,type='h',bty='l')
c=n.win*mu # 総サービス率
abline(h=c,col=8)
t1=uniroot(function(t)R(t)-c,c(9,10))$root ; t1 # 到達率=サービス率で待ち時間開始
t2=uniroot(function(t)R(t)-c,c(16,17))$root ; t2 # 午後の部
卵の名無しさん [sage] 2018/11/30(金) 23:12:57.93:c4eruZjZ
tt=seq(9,24,len=1000)
Rtt=R(tt)
plot(tt,Rtt,type='s',bty='l')
cumR=cumsum(Rtt)/sum(Rtt)*N # cumsumで累積来院数をgrid化
plot(tt,cumR,type='l',bty='l')
A <- function(t) cumR[which.max(t<=tt)] # 離散量を連続関数に
A=Vectorize(A)
curve(A(x),9,24,bty='l')
Q <- function(t){ # 時刻tでの待ち人数
if(t<t1) return(0)
if(t1<t&t<t2) return(max(A(t)-A(t1)-c*(t-t1),0)) # 午前の部
else return(max(A(t)-A(t2)-c*(t-t2),0)) # 午後の部
}
Q=Vectorize(Q)
curve(Q(x),9,24,bty='l',type='h',col=2,ylab='persons',xlab='clock time')
# 待ちの発生と終了の時刻をグラフから読み取る
t15=seq(14,15,len=100) ; plot(t15,sapply(t15,Q)) # 14.6
t17=seq(16.9,17.2,len=100) ; plot(t17,sapply(t17,Q)) # 17.0
Q(22.7)
t22=seq(22.75,22.80,len=100) ; plot(t22,sapply(t22,Q)) # 22.8

curve(Q(x),9,24,bty='l',type='h',col=2,ylab='persons',xlab='clock time')
MASS::area(Q,9, 14.6,limit=20)/A(14.6) # 午前の待ち時間
MASS::area(Q,17,22.8,limit=20)/(A(22.8)-A(17)) # 午後の待ち時間
卵の名無しさん [sage] 2018/11/30(金) 23:51:07.01:c4eruZjZ
午前の受付9時から12時30分まで午後の受付15時30分から19時までのクリニックに
図のような二峰性の分布で100人が来院するとする。
ttps://i.imgur.com/mEvgZjr.png
> breaks
[1] 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.5 13.0 13.5 14.0 14.5
[13] 15.0 15.5 16.0 16.5 17.0 17.5 18.0 18.5 19.0
> round(y)
[1] 5 8 10 8 6 5 3 0 0 0 0 0 0 0 0 7 19 17 8 3

医師は一人、診察時間は平均8分として待ち時間をグラフ化。
ttps://i.imgur.com/8Z21ezi.png

数値積分して平均の待ち時間を算出。
> integrate(Q,9,14.6,subdivisions=256)$value/A(14.6) # 午前の待ち時間
[1] 1.175392
> integrate(Q,17,22.8,subdivisions=256)$value/(A(22.8)-A(17)) # 午後の待ち時間
[1] 2.214289
卵の名無しさん [sage] 2018/12/01(土) 00:40:16.84:yFxD3TpK

混雑と待ち(朝倉書店)が届いたので

これやってみた。
ポアソン分布や指数分布を前提とせず、実際のヒストグラムから待ち時間のシミュレーション。
午前の受付9時から12時30分まで午後の受付15時30分から19時までのクリニックに
図のような二峰性の分布で100人が来院するとする。
ttps://i.imgur.com/mEvgZjr.png
> breaks
[1] 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.5 13.0 13.5 14.0 14.5
[13] 15.0 15.5 16.0 16.5 17.0 17.5 18.0 18.5 19.0
> round(y)
[1] 5 8 10 8 6 5 3 0 0 0 0 0 0 0 0 7 19 17 8 3

医師は一人、診察時間は平均8分として待ち時間をグラフ化。
ttps://i.imgur.com/8Z21ezi.png

数値積分して平均の待ち時間を算出。
> integrate(Q,9,14.6,subdivisions=256)$value/A(14.6) # 午前の待ち時間
[1] 1.175392
> integrate(Q,17,22.8,subdivisions=256)$value/(A(22.8)-A(17)) # 午後の待ち時間
[1] 2.214289


ttps://i.imgur.com/IKoA1iQ.png

診療終了23時w
卵の名無しさん [sage] 2018/12/01(土) 00:40:42.20:yFxD3TpK
午後から医師は二人に増やすとどうなるかシミュレーションしてみた。
診察時間は一人平均8分の設定は同じ。

ttps://i.imgur.com/ULERzvs.png
> integrate(Q,17,19.9,subdivisions=256)$value/(A(19.9)-A(17)) # 午後の待ち時間
[1] 1.496882
待ち時間が2.2時間から1.5時間に短縮。

診療終了は20時!
卵の名無しさん [] 2018/12/01(土) 09:45:22.56:j/i2xXms
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.
卵の名無しさん [sage] 2018/12/01(土) 10:03:30.90:RmWyTNtb
rm(list=ls())
nwin=2 ; mu=10
C=nwin*mu # サービス効率
R <- function(t) dgamma(t,2,1)*100 # 到達関数
R=Vectorize(R)
curve(R(x),0,10,bty='l') ; abline(h=C,col=8)
t1=uniroot(function(x)R(x)-C,c(0,1))$root ; t1 # 行列開始時刻
t2=optimise(R,c(0,2),maximum = T)$maximum ; t2 # 行列増大速度最高時刻
t3=uniroot(function(x)R(x)-C,c(1,4))$root ; t3 # 行列最長時刻
A <- function(t) integrate(R,0,t)$value # 累積来客数
A=Vectorize(A)
curve(A(x),0,10,bty='l')
Q <- function(t) A(t)-A(t1)-C*(t-t1) # 行列人数
Q=Vectorize(Q)
curve(Q(x),0,10,bty='l') ; abline(h=0,col=8)
optimize(Q,c(0,10),maximum=T)$maximum ; t3 # 行列最長時刻
t4=uniroot(Q,c(4,8))$root ; t4 # 行列終了時刻
# calculate t4 w/o Q-function 到達関数から行列終了時刻を算出
curve(R(x),0,10,bty='l',xlab='clock time',ylab='arrival rate')
abline(h=C,col=8)
t13=seq(t1,t3,len=20)
segments(x0=t13,y0=C,y1=R(t13),col=3)
text(1.25,25,'V') ; text(c(t1,t3,t4),20,c('t1','t3','t4'),cex=0.95)
V=integrate(function(t)R(t)-C,t1,t3)$value ; V # 待ち時間*人数
dQ <- function(t) integrate(function(x) C-R(x),t3,t)$value - V
uniroot(dQ,c(t3,10))$root ; t4
t34=seq(t3,t4,len=20)
segments(x0=t34,y0=20,y1=R(t34),col='cyan') ; text(4,15,'V')
卵の名無しさん [sage] 2018/12/01(土) 10:07:43.30:RmWyTNtb

到着関数が一峰性だと待ち行列が0になる時間が割と簡単に算出できる。
ド底辺シリツ医大裏口入学には無理だけどw

ttps://i.imgur.com/1v72ST5.png
卵の名無しさん [sage] 2018/12/01(土) 10:24:54.70:RmWyTNtb

ド底辺シリツ医を蔑むパロディであることわかってコピペしてんの?

これにでも答えてみ!

あるド底辺裏口シリツ医大のある学年に100人の学生がいる。
100人の学生は全員裏口入学である。
裏口入学を自覚したら翌日に退学しなければならない。
学生は自分以外の学生が裏口入学であるとことは全員知っているが自分が裏口入学であることは知らない。
教授が全員の前で「この学年には少なくとも一人が裏口入学している」と発言した。
この後、どうなるかを述べよ。
卵の名無しさん [] 2018/12/01(土) 13:36:46.51:ZZpMV2Nw
この季節はいつも風邪気味になるなぁ
外来から貰ってんのかな
冬コミが近いのに原稿がまだできとらんが
体調管理はしっかりしていかんとなぁ
ジャンルはFTで良いかなぁ
ガチ百合にすっかなぁ
卵の名無しさん [] 2018/12/01(土) 16:09:30.06:ZZpMV2Nw
便秘薬をいろいろ試しているが
どれが良いかなぁ
卵の名無しさん [sage] 2018/12/01(土) 18:54:24.93:RmWyTNtb
t0fn <- function(n){ # terminal 0 of factorial n ( n=10, 10!=3628800 => 2
m=floor(log(n)/log(5))
ans=0
for(i in 1:m) ans=ans+n%/%(5^i)
ans
}
t0fn=Vectorize(t0fn)
t0fn(10^(1:12))

10!から1兆!まで末尾の0の数
> t0fn(10^(1:12))
[1] 2 24 249 2499 24999
[6] 249998 2499999 24999999 249999998 2499999997
[11] 24999999997 249999999997
卵の名無しさん [sage] 2018/12/01(土) 18:55:28.45:RmWyTNtb
おい、ド底辺。

1兆の階乗は末尾に0が
249999999997
並ぶと計算されたが、あってるか?
検算しておいてくれ。
卵の名無しさん [] 2018/12/01(土) 20:53:46.49:o9d/f5rc
今年の納税額は五千万超えるなぁ

冬コミはFTCW の新作出るかなぁ?
卵の名無しさん [] 2018/12/01(土) 21:08:44.05:o9d/f5rc
ふ◯◯◯ち◯◯れ◯◯◯◯
卵の名無しさん [] 2018/12/01(土) 22:41:26.00:N4WBnKxq
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2018/12/01(土) 23:38:07.20:yFxD3TpK
あるド底辺裏口シリツ医大のある学年に100人の学生がいる。
100人の学生は全員裏口入学である。
裏口入学を自覚したら翌日に退学しなければならない。
学生は自分以外の学生が裏口入学であるとことは全員知っているが自分が裏口入学であることは知らない。
教授が全員の前で「この学年には少なくとも一人が裏口入学している」と発言した。
この後、どうなるかを述べよ。
卵の名無しさん [sage] 2018/12/02(日) 06:45:16.31:e9Pc8hcV
# Troubled train T1 with m passengers left station S1 arrived S2 station s minute later
# than depature of train T0
# beta*m passenger got out and rs passengers got in, where
# r denotes in-passenger rate per minute, T0 took b(beta*m + rs) extra-minutes
# regular train T0 takes c minutes for exchange of passengers
dango <- function(s,m,beta=3/10,r=3,b=0.01,c=0){
mm=(1-beta)*m+r*s
ss=s+b*(beta*m+r*s)-c
c(ss,mm)
}
sm=c(10,100)
re=sm
for(i in 1:2){
sm=dango(sm[1],sm[2])
re=rbind(re,sm)
}
rownames(re)=NULL
plot(re)
卵の名無しさん [] 2018/12/02(日) 07:38:46.89:IdisUW1u
薬局の店舗数を増やそうかなぁ
卵の名無しさん [sage] 2018/12/02(日) 12:10:26.58:TL1hN1iv
dat=hist(c(rnorm(1e6),rnorm(1e5,5,0.5)))
attach(dat)
plot(breaks[-1],counts,type='s',log='y',ylim=range(counts))
segments(x0=breaks[-1],y=min(counts),y1=counts)
segments(x0=breaks[1],y=min(counts),y1=counts[1])
卵の名無しさん [sage] 2018/12/02(日) 21:14:03.05:qDXWsGoQ
liars <- function(Answer){ # case of all liars permitted
N=length(Answer)
dat=permutations(2,N,0:1,set=F,rep=T)
check <- function(y,answer=Answer){
all(answer[y==0]==sum(y)) # all honest answer compatible?  
} # numeric(0)==sum(y):logical(0) all(logical(0)) : TRUE
dat[apply(dat,1,check),]
}
liars(c(1,2,2,3,3))
liars(c(1,3,5,7,9,1,3,5,7,9))
(x=sample(10,10,rep=T)) ; apply(!liars(x),1,sum)
liars(c(8, 9, 8, 2, 4, 4, 2, 3, 9, 8))
卵の名無しさん [] 2018/12/02(日) 21:35:54.10:jYRj3cxk
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.
卵の名無しさん [] 2018/12/02(日) 22:20:54.56:iMFc27fK
互いに相関のある5項目くらいのスコアの合計点から疾患の発生を予測するカットオフ値を求めました

単純に合計点した時の予測能は不十分であったため
主成分分析をして各主成分を線型結合して主成分スコアを出す時に、AUC値が最大になるように線型結合する係数に重み付けするのは一般的に大丈夫かしら?
卵の名無しさん [sage] 2018/12/02(日) 22:35:39.65:qDXWsGoQ
# 一般化、全員嘘つきも可、重複する答も可l

iars <- function(Answer){ # duplicate answer and/or case of all liars permitted
N=length(Answer)
dat=gtools::permutations(2,N,0:1,set=F,rep=T)
check <- function(y,answer=Answer){
if(all(y==1)) !all(1:N %in% answer)
else all(answer[y==0]==sum(y)) & !(sum(y) %in% answer[y==1])
# all honest answer compatible & not included in liar's anwer   
}
dat[apply(dat,1,check),]
}
liars(c(2,2,2,3,3))
liars(c(2,3,3,4,5))
liars(Answer<-sample(10,10,rep=T)) ; Answer
liars(c(4,5,5,6,7,7,8,8,9,10))
卵の名無しさん [] 2018/12/02(日) 22:54:14.37:5KkHnCxW
3S Policy Causes the ResultTruman of Panama document and 3S policy

We are keeping the citizens in a cage named "Freedom of Falsehood".
The way you just give them some luxury and convenience.Then release sports, screen, sex (3S).
Because the citizens are our livestock. For that reason, we must make it longevity. It makes it sick
(with chemicals etc.) and keeps it alive.This will keep us harvesting. This is also the authority
of the victorious country.The medal and the Nobel prize is not all Raoul declarationExamples of 3S policy
Hypocrites and disguised society and Panama document "He moved here here two years ago, I was afraid
of looking, but I thought it was a polite person to greet" Hello "when I saw it ... It was not like I was waking
this kind of incident ... ... "(Neighboring residents)On November 7, Shosuke Hotta, 42, a self-proclaimed office
worker in Sagamihara City, Kanagawa Prefecture, was arrested on suspicion of abusing her daughter Sakurai Ai.
This is the nature of the Earthlings
卵の名無しさん [sage] 2018/12/02(日) 23:16:13.68:+r9Osf+E

>互いに相関のある
なら変数減らせるんじゃね?
AUC?Area Under the Curve?
AICじゃなくて?
卵の名無しさん [] 2018/12/02(日) 23:31:52.94:61sstTZi

主成分3までで累積寄与度85%なので、3まで次元は減ります

主成分1 + 主成分2 + 主成分3とするのではなく

AUCを最大にする主成分1 + β1*主成分2 + β2*主成分3の
係数を出すっていうのは一般的に大丈夫なんでしょうか

AUCはarea under curveです
卵の名無しさん [sage] 2018/12/02(日) 23:42:05.45:+r9Osf+E

統計テキストの演習問題によくあるから一般的だろね。
三角形の周囲長のデータから線形回帰で面積を出すというような意味のないことやってるかも。
卵の名無しさん [] 2018/12/02(日) 23:50:18.66:5KkHnCxW
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.
卵の名無しさん [] 2018/12/02(日) 23:57:57.44:iMFc27fK

次数が減るのがメリットかなと…
卵の名無しさん [sage] 2018/12/03(月) 07:19:35.51:DAMQxIpv

長方形の周囲長者から面積をだすのに
データが100個あればラグランジェの補完式で100次元式で完璧に当てはめることができる。
フィボナッチ数列も同じ。
卵の名無しさん [sage] 2018/12/03(月) 07:22:30.11:DAMQxIpv
象の体表面積の計算に有用な数値ってどこだろ?
身長体重鼻の長さ耳の大きさ?
卵の名無しさん [sage] 2018/12/03(月) 07:24:12.72:DAMQxIpv
スリーサイズと身長体重の相関とか某女子大の講師が書いてたなw
卵の名無しさん [sage] 2018/12/03(月) 08:49:08.21:cRcCrmb8
par(mfrow=c(2,1))

f <- function(x,a=0.01) a^x - log(x)/log(a)
curve(f(x),0,2,bty='l') ; abline(h=1,col=8)
D( expression(a^x - log(x)/log(a)),'x')
df <- function(x,a=0.01) a^x * log(a) - 1/x/log(a)
curve(df(x))

g <- function(x,a=0.01) a^x/(log(x)/log(a))
curve(g(x),0,2,bty='l') ; abline(h=1,col=8)

D(expression (a^x/(log(x)/log(a))),'x')
dg <- function(x,a=0.01) a^x * log(a)/(log(x)/log(a)) - a^x * (1/x/log(a))/(log(x)/log(a))^2
curve(dg,0,10)
卵の名無しさん [sage] 2018/12/03(月) 11:40:13.52:DAMQxIpv

AICとかWAICで比較する方法があったはず。
卵の名無しさん [sage] 2018/12/03(月) 12:54:57.80:DAMQxIpv
rm(list=ls())
library(gtools)
N=11
Answer=1:N
dat=permutations(2,N,0:1,set=F,rep=T) ; colnames(dat)=LETTERS[1:N]
# 1:嘘つき 0:正直 例.1 1 1 0 1 1 1 1 1 0 1で矛盾がないか調べる
check <- function(y,answer=Answer){ # remark 各人の解答
if(all(y==1)) !all(1:N %in% answer) # 正直者がいないとき
else all(answer[y==0]==sum(y)) & !(sum(y) %in% answer[y==1])
# すべての正直者の答のみが現実と一致するか?  
}
dat[apply(dat,1,check),]

# 一般化、全員嘘つきも可、重複する答も可
liars <- function(Answer,Strict=TRUE){ # duplicate answer and/or case of all liars permitted, Strict:liars always lie
N=length(Answer)
dat=gtools::permutations(2,N,0:1,set=F,rep=T)
check <- function(y,answer=Answer){
if(all(y==1)) !all(1:N %in% answer)
else if(Strict) all(answer[y==0]==sum(y)) & !(sum(y) %in% answer[y==1])
else all(answer[y==0]==sum(y))

# all honest answer compatible & not included in liar's anwer
}
dat[apply(dat,1,check),]
}
liars(c(2,2,2,3,3))
liars(c(2,3,3,4,5))
liars(Answer<-sample(10,10,rep=T)) ; Answer
liars(c(4,5,5,6,7,7,8,8,9,10))
liars(c(4,5,5,6,7,7,8,8,9,10),S=F)
卵の名無しさん [sage] 2018/12/03(月) 13:13:54.59:DAMQxIpv
シリツ医の使命は裏口入学撲滅国民運動の先頭に立つことだよ。

裏口入学の学生を除籍処分にしないかぎり、信頼の回復はないね。つまり、いつまで経ってもシリツ医大卒=裏口バカと汚名は拭えない。シリツ出身者こそ、裏口入学に厳しい処分せよを訴えるべき。

裏口入学医師の免許剥奪を!の国民運動の先頭に立てばよいぞ。
僕も裏口入学とか、言ってたら信頼の回復はない。
卵の名無しさん [sage] 2018/12/03(月) 15:36:25.67:1KqGOOJS
rm(list=ls())
graphics.off()
.a=0.01
f = function(x,a=.a) a^x-log(x)/log(a)
curve(f(x),bty='l',lwd=2) ; abline(h=0,col=8)
max=optimize(f,c(0,1),maximum=T)$maximum
min=optimize(f,c(0,1),maximum=F)$minimum
x1=uniroot(f,c(0,max))$root
x2=uniroot(f,c(max,min))$root
x3=uniroot(f,c(min,1))$root
ans=c(x1,x2,x3) ; ans
points(ans,c(0,0,0),pch=19,col=2)
卵の名無しさん [sage] 2018/12/03(月) 21:38:41.65:uthawMyt
liars <- function(Answer,Strict=TRUE){ # duplicate answer and/or case of all liars permitted
N=length(Answer)
dat=gtools::permutations(2,N,0:1,set=F,rep=T)
check <- function(y,answer=Answer){
if(all(y==1)) {!all(1:N %in% answer)}
else{
if(Strict){all(answer[y==0]==sum(y)) & !(sum(y) %in% answer[y==1])}
else {all(answer[y==0]==sum(y))}
}
# all honest answer compatible & not included in liar's anwer
}
dat[apply(dat,1,check),]
}
liars(c(2,2,2,3,3))
liars(c(2,3,3,4,5),S=F)

liars(Answer<-sample(10,10,rep=T),S=F) ; Answer
liars(Answer)
sort(Answer)
liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=FALSE)
liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=TRUE)
卵の名無しさん [sage] 2018/12/03(月) 21:39:50.88:uthawMyt
> liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=FALSE)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11]
[1,] 1 1 1 1 1 1 1 1 0 0 1
[2,] 1 1 1 1 1 1 1 1 0 1 0
[3,] 1 1 1 1 1 1 1 1 1 0 0
[4,] 1 1 1 1 1 1 1 1 1 1 1
> liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=TRUE)
[1] 1 1 1 1 1 1 1 1 1 1 1
卵の名無しさん [sage] 2018/12/03(月) 22:45:35.45:uthawMyt
liars <- function(Answer,Strict=TRUE){ # duplicate answer and/or case of all liars permitted
N=length(Answer)
arg=list()
for(i in 1:N) arg[[i]]=0:1
dat=do.call(expand.grid,arg) # expand.grid(0:1,0:1,0:1,...,0:1)
colnames(dat)=LETTERS[1:N]
check <- function(y,answer=Answer){
if(all(y==1)) {!all(1:N %in% answer)}
else{ # Strict: all honest answer compatible & not included in liar's anwer
if(Strict){all(answer[y==0]==sum(y)) & !(sum(y) %in% answer[y==1])}
else {all(answer[y==0]==sum(y))}
}
}
dat[apply(dat,1,check),]
}

liars(Answer<-sample(10,10,rep=T),S=F) ; Answer

liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=FALSE)
liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=TRUE)
卵の名無しさん [] 2018/12/03(月) 23:36:09.50:kWZ8ngVO
しゅごーいAWP
卵の名無しさん [sage] 2018/12/03(月) 23:36:55.91:uthawMyt
liars <- function(Answer,Strict=TRUE){ # duplicate answer and/or case of all liars permitted
N=length(Answer)
arg=list()
for(i in 1:N) arg[[i]]=0:1
dat=do.call(expand.grid,arg) # expand.grid(0:1,0:1,0:1,...,0:1)
colnames(dat)=LETTERS[1:N]
check <- function(y,answer=Answer){
if(all(y==1)) {!all(1:N %in% answer)}
else{ # Strict: all honest answer compatible & not included in liar's anwer
if(Strict){all(answer[y==0]==sum(y)) & !(sum(y) %in% answer[y==1])}
else {all(answer[y==0]==sum(y))}
}
}
res=as.matrix(dat[apply(dat,1,check),])
rownames(res)=NULL
return(res)
}

liars(Answer<-sample(10,10,rep=T),S=F) ; Answer

liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=FALSE)
liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=TRUE)
卵の名無しさん [] 2018/12/04(火) 01:12:57.83:nI+jKERK
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2018/12/04(火) 15:14:54.20:nfS0Ph7I

個数を表示するように改造

# 一般化、全員嘘つきも可、重複する答も可
liars <- function(Answer,Strict=FALSE){ # duplicate answer and/or case of all liars permitted
N=length(Answer) # Strict: liars always lie, never tell the truth
arg=list()
for(i in 1:N) arg[[i]]=0:1
dat=do.call(expand.grid,arg) # expand.grid(0:1,0:1,0:1,...,0:1)
colnames(dat)=LETTERS[1:N]
check <- function(y,answer=Answer){
if(all(y==1)) {!all(1:N %in% answer)}
else{ # Strict: all honest answer compatible & not included in liar's anwer
if(Strict){all(answer[y==0]==sum(y)) & !(sum(y) %in% answer[y==1])}
else {all(answer[y==0]==sum(y))}
}
}
re=as.matrix(dat[apply(dat,1,check),])
rownames(re)=1:nrow(re)
return(rbind(re,Answer))
}


liars(Answer<-sample(10,10,rep=T),S=F)

liars(c(1,2,3,4,5,5,5,5,9,9,9),Strict=FALSE)
liars(c(1,2,3,4,5,5,5,5,9,9,9),Strict=TRUE)
liars(c(7,7,7,7,8,8,8,9,9,10,11),Strict=F)
卵の名無しさん [sage] 2018/12/04(火) 19:24:56.87:nfS0Ph7I
バスの到着間隔が平均30分の指数分布であるEバスと
平均30分の一様分布であるUバスではどちらが待ち時間の期待値が小さいか?
卵の名無しさん [] 2018/12/05(水) 00:36:57.95:DRmF49xK
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2018/12/05(水) 18:34:25.14:mPAQrzgG
-- zerOne 5 -> [[0,0,0,0,0],[0,0,0,0,1]....[1,1,1,1,1,1]
zeroOne :: Num a => Int -> [[a]]
zeroOne n = (!! n) $ iterate (\x-> [a:b|a<-[0,1],b<-x]) [[]]
卵の名無しさん [] 2018/12/05(水) 19:07:50.43:XTI9A75j
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2018/12/05(水) 22:12:31.75:kHtcpiLC
# dat : all possible combinations
n=5 ;arg=list()
for(i in 1:n) arg[[i]]=0:1
dat=do.call(expand.grid,arg) # expand.grid(0:1,0:1,...)
dat=as.matrix(dat)
colnames(dat)=LETTERS[1:n]

# A=>!B, B=>C, C=>!D&!E, D=>!E, E=>E
is.compati<-function(i,x){ # i:index of honest, x: possible combination
switch(i, # 1..n
x['B']==0, # testified by A (=LETTERS[1])
x['C']==1, # testified by B (=LETTERS[2])
x['D']==0 & x['E']==0, # ...
x['E']==0,
x['E']==1)
}

check=function(x){
re=NULL
honest=which(x==1) # index of honest
for(i in honest){
re=append(re,is.compati(i,x))
}
all(re)
}
dat[apply(dat,1,check),]
卵の名無しさん [sage] 2018/12/05(水) 22:13:09.98:kHtcpiLC
正直者は嘘をつかないが
嘘つきは嘘をつくこともつかないこともある。

A〜Eの5人が次のように発言している
A「Bはウソつきだ」
B「Cはウソつきではない」
C「D.Eはどちらもウソつきだ」
D「Eはウソつきだ」
E「私はウソつきではない」

5人のうち、正直者と嘘つきは誰か?
可能性のある組合せをすべて示せ。
卵の名無しさん [sage] 2018/12/06(木) 09:56:22.91:cp3ws/tO

嘘つきが必ず嘘をつくStrict=TRUE、嘘も真実もいうStrict=FALSE
でどちらにも対応。

# dat : all possible combinations
n=5 ;arg=list()
for(i in 1:n) arg[[i]]=0:1
dat=do.call(expand.grid,arg) # expand.grid(0:1,0:1,...)
dat=as.matrix(dat)
colnames(dat)=LETTERS[1:n]

# A=>!B, B=>C, C=>!D&!E, D=>!E, E=>E
is.compati.H<-function(i,x){ # i:index of honest, x: possible combination
switch(i, # 1..n
x['B']==0, # testified by A (=LETTERS[1])
x['C']==1, # testified by B (=LETTERS[2])
x['D']==0 & x['E']==0, # ...
x['E']==0,
x['E']==1)
}
is.compati.L <- function(i,x){# is compatible for liars?
# i:index of liars, x: possible combination
switch(i, # 1..n
!(x['B']==0), # testified by A (=LETTERS[1])
!(x['C']==1), # testified by B (=LETTERS[2])
!(x['D']==0 & x['E']==0), # ...
!(x['E']==0),
!(x['E']==1))
}
卵の名無しさん [sage] 2018/12/06(木) 09:56:52.33:cp3ws/tO
check=function(x,Strict){
re=NULL
honest=which(x==1) # index of honest
for(i in honest){
re=append(re,is.compati.H(i,x))
}
if(Strict){
liar=which(x==0) # index of liar
for(i in liar){
re=append(re,is.compati.L(i,x))
}
}
all(re)
}
dat[apply(dat,1,function(x) check(x,Strict=TRUE)),]
dat[apply(dat,1,function(x) check(x,Strict=FALSE)),]
卵の名無しさん [sage] 2018/12/06(木) 16:42:18.52:E+1fMA/x
dat=as.matrix(expand.grid(1:0,1:0,1:0))
colnames(dat)=LETTERS[1:3]
compati.H <- function(i,x){ # i index of honest, x: possible combination
switch(i, # i= 1,2,or,3
# if A is honest, B should be honest, compatible?
ans <- x[2]==1, # when i=1
# if B is honest,C is a liar thereby A should be honest. compatible?
ans <- x[3]==0 & ifelse(x[3]==0,!(x[1]==0),x[1]==0), # when i=2, x[3]==0 & x[1]==1
ans <- NULL) # when i=3
return(ans)
}
compati.L <- function(i,x){ # i index of liar, x: possible combination
switch(i,
ans <- x[2]==0,
ans <- x[3]==1 & x[1]==1,
ans <- NULL)
return(ans)}

check <- function(x,Strict){
re=NULL
honest <- which(x==1)
for(i in honest){
re=append(re,compati.H(i,x))}
if(Strict){
liar <- which(x==0)
for(i in liar){
re=append(re,compati.L(i,x)) }}
all(re)}

dat[apply(dat,1,function(x) check(x,Strict=TRUE)),]

dat[apply(dat,1,function(x) check(x,Strict=FALSE)),]
卵の名無しさん [sage] 2018/12/06(木) 20:20:59.86:E+1fMA/x
a=1
m=100
n=1e6
x=sample(c(a/m,m*a),n,rep=T,prob=c(m/(m+1),1/(m+1))) ; hist(x,freq=F) ; mean(x)
a/m*m/(m+1)+m*a*1/(m+1) ; a/(m+1)*(1+m)
plot(c(m/(m/1),1/(m+1)),c(a/m,m*a),bty='l')
EX2=(a/m)^2*m/(m+1)+(m*a)^2*(1/(m+1))
(EW = EX2/a/2) ; mean(x^2)/mean(x)/2
EW <- function(m,a=1) (m^3+1)/m/(m+1)/2*a
m=1:100
plot(m,EW(m),bty='l')
卵の名無しさん [] 2018/12/07(金) 03:14:44.29:YE3oTb4v
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2018/12/07(金) 08:24:44.19:ySmU7MDt

裏口馬鹿にもわかるように原文もつけなきゃ。


原文はこれな。

私は昭和の時代に大学受験したけど、昔は今よりも差別感が凄く、慶応以外の私立医は特殊民のための特殊学校というイメージで開業医のバカ息子以外は誰も受験しようとすらしなかった。
常識的に考えて、数千万という法外な金を払って、しかも同業者からも患者からもバカだの裏口だのと散々罵られるのをわかって好き好んで私立医に行く同級生は一人もいませんでした。
本人には面と向かっては言わないけれど、俺くらいの年代の人間は、おそらくは8−9割は私立卒を今でも「何偉そうなこと抜かしてるんだ、この裏口バカが」と心の底で軽蔑し、嘲笑しているよ。当の本人には面と向かっては絶対にそんなことは言わないけどね。
卵の名無しさん [sage] 2018/12/07(金) 08:27:54.51:ySmU7MDt
開業医スレのシリツ三法則(試案、名投稿より作成)

1.私立医が予想通り糞だからしょうがない

>ttps://egg.5ch.net/test/read.cgi/hosp/1537519628/101-102">ttps://egg.5ch.net/test/read.cgi/hosp/1537519628/101-102
>ttps://egg.5ch.net/test/read.cgi/hosp/1537519628/844-853
ID:RFPm1BdQ

>ttps://egg.5ch.net/test/read.cgi/hosp/1537519628/869
>ttps://egg.5ch.net/test/read.cgi/hosp/1537519628/874-875
>ttps://egg.5ch.net/test/read.cgi/hosp/1537519628/874-880
>ttps://egg.5ch.net/test/read.cgi/hosp/1537519628/882
ID:liUvUPgn

2.馬鹿に馬鹿と言っちゃ嫌われるのは摂理
実例大杉!

3.リアルでは皆思ってるだけで口に出してないだけ
卵の名無しさん [] 2018/12/07(金) 20:21:20.38:g1XwAPhY
3S Policy Causes the ResultTruman of Panama document and 3S policy

We are keeping the citizens in a cage named "Freedom of Falsehood".
The way you just give them some luxury and convenience.Then release sports, screen, sex (3S).
Because the citizens are our livestock. For that reason, we must make it longevity. It makes it sick
(with chemicals etc.) and keeps it alive.This will keep us harvesting. This is also the authority
of the victorious country.The medal and the Nobel prize is not all Raoul declarationExamples of 3S policy
Hypocrites and disguised society and Panama document "He moved here here two years ago, I was afraid
of looking, but I thought it was a polite person to greet" Hello "when I saw it ... It was not like I was waking
this kind of incident ... ... "(Neighboring residents)On November 7, Shosuke Hotta, 42, a self-proclaimed office
worker in Sagamihara City, Kanagawa Prefecture, was arrested on suspicion of abusing her daughter Sakurai Ai.
This is the nature of the Earthlings
卵の名無しさん [] 2018/12/08(土) 07:31:43.87:xRW0g7nq
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2018/12/08(土) 20:18:41.06:W3abFsTH
liars <- function(Answer,Strict=TRUE){ # duplicate answer and/or case of all liars permitted
N=length(Answer)
arg=list()
for(i in 1:N) arg[[i]]=0:1
dat=do.call(expand.grid,arg) # expand.grid(0:1,0:1,0:1,...,0:1)
colnames(dat)=LETTERS[1:N]
check <- function(y,answer=Answer){
if(all(y==1)) {!all(1:N %in% answer)}
else{ # Strict: all honest answer compatible & not included in liar's anwer
if(Strict){all(answer[y==0]==sum(y)) & !(sum(y) %in% answer[y==1])}
else {all(answer[y==0]==sum(y))}
}
}
dat[apply(dat,1,check),]
}

liars(Answer<-sample(10,10,rep=T),S=F) ; Answer

liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=FALSE)
liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=TRUE)
卵の名無しさん [sage] 2018/12/09(日) 09:45:50.49:EZ1Q6//t
ttp://https://www.tutorialspoint.com/execute_r_online.php?9gkFGD

ttps://i.imgur.com/72yk8Wk.jpg
ttps://i.imgur.com/uC9tNaW.jpg
卵の名無しさん [sage] 2018/12/10(月) 04:15:43.72:u30TNISd
呪文:「ド底辺シリツ医大が悪いのではない、本人の頭が悪いんだ」を唱えると甲状腺機能が正常化するという統計処理の捏造をやってみる。

TSH : 0.34〜4.0 TSH:μIU/mlを基準値として(これが平均±2×標準偏差で計算されているとして)呪文前と呪文後のデータを正規分布で各々50個つくる。
負になった場合は検出限界以下として0にする。
ttp://i.imgur.com/k7MbKQ0.jpg
同じ平均値と標準偏差で乱数発生させただけなので両群には有意差はない。
横軸に呪文前のTSHの値、縦軸にTSHの変化(呪文後−呪文前)をグラフしてみると
ttp://i.imgur.com/GQ5X23P.jpg

つまり、呪文前のTSHが高いほど呪文後はTSHは下がり、呪文前のTSHが低いほど呪文後のTSHは上がるという傾向がみてとれる。
これを線形回帰して確かめてみる。

回帰直線のパラメータは以下の通り。

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.3812 0.3323 7.165 4.10e-09 ***
before -1.0351 0.1411 -7.338 2.24e-09 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.8365 on 48 degrees of freedom
Multiple R-squared: 0.5287, Adjusted R-squared: 0.5189
F-statistic: 53.84 on 1 and 48 DF, p-value: 2.237e-09

p = 2.24e-09 なので有意差ありとしてよい。

ゆえに、「ド底辺シリツ医大が悪いのではない、本人の頭が悪いんだ」という呪文は甲状腺機能を正常化させる。

ここで問題、この統計処理のどこが誤っているか?
卵の名無しさん [] 2018/12/10(月) 14:52:10.55:SBKPI/ud
アタマわるわる〜
卵の名無しさん [sage] 2018/12/10(月) 22:04:30.67:7+YyXAYs

頭が悪いのは誤りを指摘できないお前の頭な。
卵の名無しさん [] 2018/12/11(火) 08:23:18.37:EyBBmFk4
野獣先輩、オナシャス
アタマわるわるわ〜るわる〜
アタマわるわるわ〜るわる〜
あそれっ
アタマわるわるわ〜るわる〜
アタマわるわるわ〜るわる〜
あよいしょっ
アタマわるわるわ〜るわる〜
アタマわるわるわ〜るわる〜
あくしろよ
アタマわるわるわ〜るわる〜
アタマわるわるわ〜るわる〜
endless
卵の名無しさん [sage] 2018/12/11(火) 08:39:06.09:PFEjAytf

文章だけでド底辺シリツ医大卒の裏口馬鹿とわかる。
これに答えられない国立卒がいた。
駅弁らしいが。

平均0、分散1の正規分布の95%信頼区域は[-1.96,1.96]で区域長は約3.92である。
平均0、分散1の一様分布の95%信頼区域の区域長さはいくらか?
卵の名無しさん [] 2018/12/11(火) 13:32:28.73:c5MyHopu
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2018/12/12(水) 22:30:23.75:x9HwYbel
おいこら
あっちでまた非医師仲間のコンプが湧いてるぞ
さっさと引き取れや
卵の名無しさん [sage] 2018/12/14(金) 12:51:17.00:eeDD4wBK
回答付きでレスできない椰子ってシリツ卒なんだろうな。
卵の名無しさん [] 2018/12/14(金) 23:45:34.35:/gtLrghw
お前は今までに吐いたゲロの回数を覚えているのか?
卵の名無しさん [sage] 2018/12/15(土) 06:52:37.95:PqeMZC8f

ゲロの回数の従う事前分布をどう想定する?
卵の名無しさん [sage] 2018/12/15(土) 06:57:22.51:PqeMZC8f
ある女医が一日に5回屁をこいたとする。
屁の回数はポアソン分布と仮定して
この女医の一日にこく屁の回数の95%信頼区間を述べよ、
という問題にできるぞ。
答えてみ!
卵の名無しさん [sage] 2018/12/15(土) 07:17:43.02:PqeMZC8f
事前分布を想定して現実のデータからその分布の最適分布を算出する。当然、区間推定にある。
relocation of probability dustrubution
これがベイズ統計の基本的な考え方だよ。
上記の女医の屁の回数も区間推定できる。
卵の名無しさん [sage] 2018/12/15(土) 07:47:09.33:PqeMZC8f
ゲロの回数だとゼロ過剰ポアソン分布の方がいいだろうな。
卵の名無しさん [sage] 2018/12/15(土) 07:57:08.94:PqeMZC8f
ttp://http://kusanagi.hatenablog.jp/entry/2017/09/19/210333
卵の名無しさん [] 2018/12/15(土) 08:21:49.91:dSAl+lHg
臨床問題です
サブとアドンとBLの関連を原稿用紙30枚以上で考察せよ
卵の名無しさん [sage] 2018/12/15(土) 08:23:29.62:PqeMZC8f

んで、女医の放屁数は出せた?
卵の名無しさん [sage] 2018/12/15(土) 08:25:40.34:PqeMZC8f

問題の意味がわからないから詳述してくれ。
女医の屁の方は問題設定が明確だぞ。
卵の名無しさん [sage] 2018/12/15(土) 08:48:13.42:PqeMZC8f
ゲロの回数の事前分布なら
Zero-Inflated Negative Binomial Distribution
の方がいいかな。

Rにパッケージがあったような。
ポアソンよりパラメータが多くなるな。
卵の名無しさん [sage] 2018/12/15(土) 08:53:38.00:PqeMZC8f
VGAMに含まれてた。

ttp://https://www.rdocumentation.org/packages/VGAM/versions/0.7-7/topics/Zinb
卵の名無しさん [sage] 2018/12/15(土) 09:36:45.73:ek4No3cm
今日はこれで遊ぶかな。

ttp://https://stats.idre.ucla.edu/r/dae/zip/
卵の名無しさん [] 2018/12/15(土) 13:48:34.67:dSAl+lHg
問題に回答できないとは
さては中卒ニートだな
卵の名無しさん [sage] 2018/12/15(土) 14:06:30.51:Eu3ncs/k


問題の意味がわからないから詳述してくれ。
女医の屁の方は問題設定が明確だぞ。
卵の名無しさん [sage] 2018/12/15(土) 15:08:53.35:5ZAJ5aCI
こんな感じでゼロ過剰ポアソン分布モデルがつくれるな。

1年間にゲロを吐かない確率0.9
ゲロを吐いた場合の1年間あたりの回数=平均2のポアソン分布

theta=0.9
lambda=2
N=1e5
# Zero inflated poisson distribution
zip=numeric(N)
for (i in seq_along(zip)){
if(rbinom(1,1,1-theta)==0){
zip[i]=0
}else{
zip[i]=rpois(1,lambda)
}
}

おい、ド底辺、上記の過剰ポアソン分布モデルで
1年間に吐くゲロの回数の平均値を出してみ!
卵の名無しさん [sage] 2018/12/15(土) 15:09:33.17:5ZAJ5aCI
女医の放屁の方はポアソン分布でよさそうだな。

95%信頼区間を計算できたか?
卵の名無しさん [] 2018/12/15(土) 15:18:08.34:efNsfNge
自分で出した算数クイズは解けても
考察を要する問題は中卒には難しいようだな
解きやすいように少し簡単な問題にしてやろう

さて臨床問題です
ガチユリとフタナリの相関性について原稿用紙30枚以上で考察せよ
卵の名無しさん [sage] 2018/12/15(土) 15:31:26.76:5ZAJ5aCI

統計用語じゃないから、解説してくれ。
卵の名無しさん [sage] 2018/12/15(土) 15:41:42.49:5ZAJ5aCI
問題文が理解できない問題には答えられない。
当たり前のこと。
数学すれでも群論の話がでると俺は蚊帳の外。
図形とか確率なら理解できるから、取り組むよ。

こういうのは問題の意味は明確。
統計スレに書いていてポアソン分布知らないならお話にならないが。

ある女医が一日に5回屁をこいたとする。
屁の回数はポアソン分布と仮定して
この女医の一日にこく屁の回数の95%信頼区間を述べよ。
卵の名無しさん [sage] 2018/12/15(土) 15:50:36.53:5ZAJ5aCI
インフルエンザ迅速検査キットの感度が80%、偽陽性率1%とする。

臨床的にはインフルエンザを疑うが迅速検査陰性、

不要な薬は使いたくない、と患者の要望。

検査が早期すぎるための偽陰性かと考えて翌日再検したが、こちらも陰性。

「私がインフルエンザである可能性はどれくらいありますか?
可能性が10%以上なら仕事を休んで抗ウイルス薬希望します。」

という、検査前の有病率がいくら以上であればこの患者に抗ウイルス薬を処方することになるか?
卵の名無しさん [sage] 2018/12/15(土) 15:58:10.95:5ZAJ5aCI
nLR=(1-0.80)/0.99 # FN/TN
po=0.1/(1-0.1)
o=po/nLR^2 # po=o*nLR^2
o/(1+o)
卵の名無しさん [sage] 2018/12/15(土) 16:30:26.03:5ZAJ5aCI
インフルエンザの流行期ならなら有熱で受診した患者がインフルエンザである確率分布はこんな感じ(青のヒストグラム)

ttps://i.imgur.com/EjxDDQB.jpg

平均値80%となるβ分布Beta(8,2)を想定。

すると インフルエンザ迅速検査キットの感度が80%、偽陽性率1%のキットでの検査陰性が2回続いた患者がインフルエンザである確率は桃色のヒストグラムのような分布になる。

平均値約20%、インフルエンザである確率が10%以上である可能性は74%と説明できる。
卵の名無しさん [sage] 2018/12/15(土) 16:41:26.81:5ZAJ5aCI
nLR=(1-0.80)/0.99 # FN/TN
po=0.1/(1-0.1)
o=po/nLR^2 # po=o*nLR^2
o/(1+o)

curve(dbeta(x,8,2),bty='l',ann=F,type='h',col='maroon')
N=1e5
x=rbeta(N,8,2)
hist(x,breaks=30,col='lightblue',main='検査前有病確率',
f=F,xlab='',yaxt='n', ylab='')
o=x/(1-x)
po=o*nLR^2
pp=po/(1+po)
# hist(pp,f=F,breaks=50,col='pink',main='検査後有病確率',
yaxt='n', xlab='',ylab='')
BEST::plotPost(pp,compVal = 0.10,breaks=60,xlab="2回陰性後有病確率",
col='pink',showMode=F)
卵の名無しさん [sage] 2018/12/15(土) 16:43:14.07:5ZAJ5aCI
par(mfrow=c(2,1))
theta=0.9
lambda=2
N=1e5
# Zero inflated poisson distribution
zip=numeric(N)
for (i in seq_along(zip)){
if(rbinom(1,1,1-theta)==0){
zip[i]=0
}else{
zip[i]=rpois(1,lambda)
}
}
hist(zip)
HDInterval::hdi(zip)
mean(zip)

# Hurdle distribution
hurdle=numeric(N)
for (i in seq_along(hurdle)){
if(rbinom(1,1,1-theta)==0){ # if zero, then zero
hurdle[i]=0
}else{ # else zero truncated poisson distribution
tmp=0
while(tmp==0){
tmp=rpois(1,lambda)
}
hurdle[i]=tmp
}
}
hist(hurdle)
HDInterval::hdi(hurdle)
卵の名無しさん [] 2018/12/15(土) 17:13:08.28:dSAl+lHg
この程度の問題文が理解できないとは
さては中卒ニートだな
卵の名無しさん [sage] 2018/12/15(土) 17:48:16.98:Eu3ncs/k

自分の出した問題も説明できないとはド底辺シリツか?
卵の名無しさん [sage] 2018/12/15(土) 17:50:19.60:Eu3ncs/k

知らんことには回答できない。
答えてほしけりゃ問題を敷衍して書けよ。
統計ネタなら答えるぞ。
卵の名無しさん [] 2018/12/15(土) 19:14:33.63:lcyf4Gyo
問題が理解すらできないとは
さては中卒ニートだな
卵の名無しさん [sage] 2018/12/15(土) 19:25:13.63:Eu3ncs/k


自分の出した問題も説明できないとはド底辺シリツか?
卵の名無しさん [] 2018/12/15(土) 20:03:13.15:lcyf4Gyo
試験で解答できなきゃ零点だ
卵の名無しさん [sage] 2018/12/15(土) 20:24:09.71:Eu3ncs/k

不適切問題じゃね。
こういうのが即答できれば基礎学力の試験になる。

ある女医が一日に5回屁をこいたとする。
屁の回数はポアソン分布と仮定して
この女医の一日にこく屁の回数の95%信頼区間を述べよ、
卵の名無しさん [sage] 2018/12/15(土) 20:34:41.94:Eu3ncs/k

原稿用紙30枚以上の模範解答書いてみ!
はよ、はよ!
卵の名無しさん [] 2018/12/15(土) 21:14:31.96:3n76OB9+
捏造データでお遊んでろ。
卵の名無しさん [sage] 2018/12/15(土) 21:24:38.91:Eu3ncs/k

ベイズ統計における事前確認は捏造ではなく
無情報もしくは弱情報分布である。
日本人女性の平均身長を1〜2mの分布とする
というのが弱情報分布。
卵の名無しさん [sage] 2018/12/15(土) 21:25:49.01:Eu3ncs/k
事前分布の分散は逆ガンマより半コーシーを使うのがGelman流ね。
卵の名無しさん [sage] 2018/12/15(土) 21:29:02.64:Eu3ncs/k
事前確率分布を設定することでこういう計算も可能となる。
オマエの知識レベルじゃ無理だろうけど。

インフルエンザの迅速キットは特異度は高いが感度は検査時期によって左右される。
ある診断キットが開発されたとする。
このキットは特異度は99%と良好であったが、
感度については確かな情報がない。
事前確率分布として一様分布を仮定する。
50人を無作為抽出してこの診断キットで診断したところ40人が陽性であった。
この母集団の有病率の期待値と95%CIはいくらか?
またこの診断キットの感度の期待値と95%CIはいくらか
卵の名無しさん [sage] 2018/12/16(日) 01:08:39.24:/hMzfoFS
1年:進級失敗10人、うち1人放校
2年:進級失敗16人、放校なし
3年:進級失敗34人、うち放校9人
4年:進級失敗9人、うち放校2人
5年:進級失敗10人、うち放校1人
6年:卒業失敗26人、うち放校1人

ttps://mao.5ch.net/test/read.cgi/doctor/1488993025/1">ttps://mao.5ch.net/test/read.cgi/doctor/1488993025/1

この放校者数をポアソン分布とゼロ過剰ポアソン分布で回帰してみる。

library(VGAM)
n=0:10
hoko=c(1,0,9,2,1,1)
fitp=glm(hoko ~ 1,poisson())
coef(fitp)
plot(nn,dpois(n,coef(fitp)),bty='l')
summary(fitp)

fitz=vglm(hoko ~ 1,zipoisson())
coef(fitz)
summary(fitz)
(pstr0=exp(coef(fitz)[1]))
(lambda=logit(coef(fit)[2],inv=T))
plot(n,dzipois(nn,lambda,pstr0),bty='l',pch=19)

卵の名無しさん [] 2018/12/16(日) 06:39:53.73:ZC5C+Eow
算数の問題です
エリンギとマツタケの使用頻度を検証すると
あぁん いくいく いっひゃうのらぁ
卵の名無しさん [sage] 2018/12/16(日) 07:47:33.23:/hMzfoFS
このページ便利だな。

回帰に必要なパッケージとその一覧がサンプル付きで一覧できる。

ttp://http://dwoll.de/rexrepos/posts/regressionPoisson.html
卵の名無しさん [sage] 2018/12/16(日) 07:49:21.32:/hMzfoFS
これも親切設計

wants <- c("lmtest", "MASS", "pscl", "sandwich", "VGAM")
has <- wants %in% rownames(installed.packages())
if(any(!has)) install.packages(wants[!has])
卵の名無しさん [sage] 2018/12/16(日) 10:16:17.73:1U2yFJp0

おい、上の過剰ゼロポアソンモデルから放校者数の期待値を計算してみ。
来年のド底辺シリツ医大の放校者の予想になるぞ。
まあ、ド底辺シリツが放校者ゼロ過剰というのは過大評価だがね。
卵の名無しさん [sage] 2018/12/16(日) 10:39:40.56:/hMzfoFS
pairsxyz <- function(x,y,z){
xyz=data.frame(x,y,z)
panel.cor <- function(x, y, ...){
usr <- par('usr'); on.exit(par(usr))
par(usr=c(0,1,0,1))
r <- cor(x, y, method='spearman', use='pairwise.complete.obs')
zcol <- lattice::level.colors(r, at=seq(-1, 1, length=81), col.regions=colorRampPalette(c(scales::muted('red'),'white',scales::muted('blue')), space='rgb')(81))
ell <- ellipse::ellipse(r, level=0.95, type='l', npoints=50, scale=c(.2, .2), centre=c(.5, .5))
polygon(ell, col=zcol, border=zcol, ...)
text(x=.5, y=.5, lab=100*round(r, 2), cex=2, col='black')
pval <- cor.test(x, y, method='pearson', use='pairwise.complete.obs')$p.value
sig <- symnum(pval, corr=FALSE, na=FALSE, cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1), symbols = c('***', '**', '*', '.', ' '))
text(.6, .8, sig, cex=2, col='gray20')
}
panel.hist <- function(x, ...) {
usr <- par('usr'); on.exit(par(usr))
par(usr=c(usr[1:2], 0, 1.5))
h <- hist(x, plot=FALSE)
breaks <- h$breaks
nB <- length(breaks)
y <- h$counts; y <- y/max(y)
rect(breaks[-nB], 0, breaks[-1], y, col='lightblue', ...)
}
cols.key <- scales::muted(c('red', 'blue', 'green'))
cols.key <- adjustcolor(cols.key, alpha.f=1/4)
# pchs.key <- rep(19, 3)
# gr <- as.factor(1:3)
panel.scatter <- function(x, y){
# points(x, y, col=cols.key[gr], pch=19, cex=1)
points(x, y, col=sample(colours(),1),pch=19, cex=1)
lines(lowess(x, y))
}
卵の名無しさん [sage] 2018/12/16(日) 10:40:27.95:/hMzfoFS
pairs(xyz,
diag.panel=panel.hist,
lower.panel=panel.scatter,
upper.panel=panel.cor,
gap=0.5,
labels=gsub('\\.', '\n', colnames(xyz)),
label.pos=0.7,
cex.labels=1.4)
}

Nt <- 100
x <- sample(20:40, Nt, replace=TRUE)
y <- rnorm(Nt, 100, 15)
z <- rbinom(Nt, size=x, prob=0.5)
pairsxyz(x,y,z)

pairs も カスタマイズすればわりと使えるな。
卵の名無しさん [] 2018/12/16(日) 11:38:51.60:ZC5C+Eow
ニート ニート 働けニート

ttp://https://m.youtube.com/watch?v=qqA-oefg-m0
卵の名無しさん [sage] 2018/12/16(日) 11:42:14.17:/hMzfoFS
Nt <- 100
set.seed(123)
Ti <- sample(20:40, Nt, replace=TRUE)
Xt <- rlnorm(Nt, 100, 15)
Yt <- rbinom(Nt, size=Ti, prob=0.8)

20-40人からなるド底辺シリツ学生のグループを100組集める。
各グループを代表する知能指数が正規分布をしている。
裏口の確率は80%である。

その線形回帰は

glm(Yt ~ Xt, family=poisson(link="log"), offset=log(Ti))
卵の名無しさん [sage] 2018/12/16(日) 14:16:40.36:/hMzfoFS
source('tmp.tools.R')

library(Mass)
set.seed(71)
size <- 10000
x <- -seq(1/size,1,by=1/size)
shape <- 10.7
mu <- exp(3.7*x+2)
y1 <- sapply(mu, function(m)rnegbin(1, mu=m, theta=shape))
pairsxyz(cbind(x,y1,mu))
model_glmnb <- glm.nb(y1 ~ x)
summary(model_glmnb)

plot(x,y1,pch=19,col=rgb(.01,.01,.01,.02))
points(x,fitted(model_glmnb,seq(0,1,len=size)),col=0)
lines(x,model_glmnb$fitted)
points(x,mu,col=rgb(0,0,1,0.01),cex=0.5)

#
lambda <- sapply(mu,function(x) rgamma(1,shape=shape,scale=x/shape))
y2 <- sapply(lambda,function(x) rpois(1,x))
hist(y1,f=F,breaks=50)
hist(y2,f=F,breaks=50, add=T,col=5)
卵の名無しさん [sage] 2018/12/16(日) 20:30:27.72:/hMzfoFS
# ネットワークノード1..j..N
# ネットワーク内の客の数1..k..K、
# ノードjでの平均客数L[k,j]、通過時間W[k,j]、到着率lambda[k,j]
# mu[j]:サービス率,r[i,j]ノードiからjへの移行確率
# theta[j] = Σtheta[i](i=1,N) * r[i,j] の解がtheta
rm(list=ls())
theta=c(0.6,0.4)
mu=c(0.6,0.4)
N=2
K=10
L=W=lambda=matrix(rep(NA,N*K),ncol=N)

k=1
for(j in 1:N){
W[k,j]=1/mu[j]*(1+0)
}
tmp=numeric(N)
for(j in 1:N){
tmp[j]=theta[j]*W[k,j]
}
den=sum(tmp)
lambda[k,1]=k/den
for(j in 2:N){
lambda[k,j]=theta[j]*lambda[k,1]
}
for(j in 1:N){
L[k,j]=lambda[k,j]*W[k,j]
}
卵の名無しさん [sage] 2018/12/16(日) 20:30:52.05:/hMzfoFS
#
for(k in 2:K){
for(j in 1:N){
W[k,j]=1/mu[j]*(1 + L[k-1,j])
}
tmp=numeric(N)
for(j in 1:N){
tmp[j]=theta[j]*W[k,j]
}
den=sum(tmp)
lambda[k,1]=k/den
for(j in 2:N){
lambda[k,j]=theta[j]*lambda[k,1]
}
for(j in 1:N){
L[k,j]=lambda[k,j]*W[k,j]
}
}
L
W
lambda
卵の名無しさん [sage] 2018/12/17(月) 04:38:09.36:GOYrgwsC
minimize 2*b+4*sin(θ)/(cos(θ)-1/2)*α where (θ-sin(θ)/2+(sin(θ)/(cos(θ)-1/2))^2(α-sin(α))/2+(1-b)*sin(θ)/2=pi/8 ,0<b<1,0<θ<pi/2
卵の名無しさん [sage] 2018/12/17(月) 04:45:32.12:GOYrgwsC
minimize (2*b+4rα) where (θ-sinθ)/2+r^2(α-sinα)/2+(1-b)sinθ/2=pi/8 ,0<b<1,0<θ<pi/2


ttp://https://www.wolframalpha.com/input/?source=frontpage-immediate-access&i=minimize(2*b%2B4r%CE%B1)++where+(%CE%B8-sin%CE%B8)%2F2%2Br%5E2(%CE%B1-sin%CE%B1)%2F2%2B(1-b)sin%CE%B8%2F2%3Dpi%2F8+,0%3Cb%3C1,0%3C%CE%B8%3Cpi%2F2


Standard computation time exceeded...

Try again with Pro computation time
卵の名無しさん [sage] 2018/12/17(月) 05:14:49.85:GOYrgwsC
rangeB = map (/1000) [1..1000]
rangeTheta = map (\x -> x * pi/2/1000) [1..1000]
rangeAlpha = map (\x -> x * pi/1000) [1..1000]
rangeR = map (\x -> x * 1/1000) [1000..10000]
re = [2*b+4*r*α| b<-rangeB,θ<-rangeTheta, α<-rangeAlpha,r<-rangeR,(θ-sin(θ))/2+r^2*(α-sin(α))/2+(1-b)*sin(θ)/2==pi/8]
main = do
print $ minimum re
卵の名無しさん [sage] 2018/12/17(月) 05:39:04.50:GOYrgwsC
rangeB = map (/1000) [1..1000]
rangeTheta = map (\x -> x * pi/2/1000) [1..1000]
rangeAlpha = map (\x -> x * pi/1000) [1..1000]
re = [(2*b+4*sin(θ)/(cos(θ)-1/2)*α)| b<-rangeB,θ<-rangeTheta, α<-rangeAlpha,(θ-sin(θ))/2+(sin(θ)/(cos(θ)-1/2))^2*(α-sin(α))/2+(1-b)*sin(θ)/2==pi/8]
main = do
print $ minimum re
卵の名無しさん [sage] 2018/12/17(月) 05:47:22.52:GOYrgwsC
ttp://https://ja.wolframalpha.com/input/?source=frontpage-immediate-access&i=minimize(2*b%2B4r%CE%B1)++where+(%CE%B8-sin%CE%B8)%2F2%2Br%5E2(%CE%B1-sin%CE%B1)%2F2%2B(1-b)sin%CE%B8%2F2%3Dpi%2F8+,0%3Cb%3C1,0%3C%CE%B8%3Cpi%2F2,0%3C%CE%B1%3C2*pi
卵の名無しさん [sage] 2018/12/17(月) 05:47:36.95:GOYrgwsC
minimize(2*b+4rα) where (θ-sinθ)/2+r^2(α-sinα)/2+(1-b)sinθ/2=pi/8 ,0<b<1,0<θ<pi/2,0<α<2*pi
卵の名無しさん [] 2018/12/17(月) 13:52:12.63:FuhGkKV8
向学心のないコミュ障事務員のスレ

事務員と見せかけてその正体は大学受験に失敗したニートだろうな
二十歳前くらいの大学受験の知識で一生わたっていけると勘違いしているらしい

いや勘違いというか自分にそう言い聞かせなければいけないほど
人生終わってんだろうな
ハゲワロス
卵の名無しさん [sage] 2018/12/17(月) 13:59:09.34:N+SAyf9z

こういう野糞投稿しかできないのはド底辺シリツかな?
ド底辺スレから部屋割計算できなくて逃げ出したアホと同一人物?
卵の名無しさん [sage] 2018/12/17(月) 14:01:55.57:N+SAyf9z

向学心を語るなら>499の計算してからな。
ド底辺頭脳クン。
卵の名無しさん [] 2018/12/17(月) 14:02:51.74:FuhGkKV8
人生についての向学心は大学受験なんていう狭い領域で机上の空論をこねくり回すことではない
だがいつまでも不合格の受験生は、その領域から抜け出せなくなるんだなW

向学心のない事務員にふさわしいスレを持ってきてやったぞ

【因果応報】医学部再受験【自業自得】
ttps://medaka.5ch.net/test/read.cgi/kouri/1543851603/
卵の名無しさん [sage] 2018/12/17(月) 14:07:07.62:N+SAyf9z

>499は受験に無関係な臨床問題だよ。
答えてみ!
はよ!はよ!
向学心を語るなら>499の計算してからな。
ド底辺頭脳クン。
卵の名無しさん [] 2018/12/17(月) 14:08:05.38:FuhGkKV8
このスレもお勧めだぞW

【悲報】ワイの医学部志望の妹、精神壊れる
ttp://http://vippers.jp/archives/9238137.html
卵の名無しさん [sage] 2018/12/17(月) 14:09:08.10:N+SAyf9z


向学心を語るなら>499の計算してからな。
ド底辺頭脳クン。
卵の名無しさん [sage] 2018/12/17(月) 14:14:33.64:N+SAyf9z
ド底辺頭脳でもこれくらいできるかな?

12^2 = 144 ........................ 21^2 = 441
13^2 = 169 ........................ 31^2 = 961

二桁の数でこうなるのは他にある?

向学心も頭脳もないから答えられないだろうな。
卵の名無しさん [] 2018/12/17(月) 14:26:10.34:FuhGkKV8
さあそろそろ今日の宿題の問題を出題しといてやろうか
事務員には無理だろうけどな

さて問題です
ラブアンドピースとアヘ顔ダブルピースの相似性について原稿用紙30枚以上で考察せよ
卵の名無しさん [sage] 2018/12/17(月) 14:40:27.65:qP6ufigZ

2行で答がでる。

ド底辺頭脳には無理。

[(x,y)|x<-[1..9],y<-[1..9],let z=(10*x+y)^2,x<y,let a=z `div` 100,let b=z `mod` 100 `div` 10, let c=z `mod` 10,100*c+10*b+a==(10*y+x)^2]

[(x,y)|x<-[0..9],y<-[0..9],x<y,let z=(10*x+y)^2,let a=z `div` 100, let a1=a `div`10,let a2=a `mod` 10,
let b=z `mod` 100 `div` 10, let c=z `mod` 10,1000*c+100*b+a2*10+a1==(10*y+x)^2]
卵の名無しさん [sage] 2018/12/17(月) 14:43:19.14:qP6ufigZ

数値計算とか統計処理の必要な問題すらも作れないのは統計数理の素養がない馬鹿だからだろ。

臨床医ならこれくらいの計算ができる教養がほしいね。できなきゃド底辺シリツ医並の頭脳。


インフルエンザの迅速キットは特異度は高いが感度は検査時期によって左右される。
ある診断キットが開発されたとする。
このキットは特異度は99%と良好であったが、
感度については確かな情報がない。
事前確率分布として一様分布を仮定する。
50人を無作為抽出してこの診断キットで診断したところ40人が陽性であった。
この母集団の有病率の期待値と95%CIはいくらか?
またこの診断キットの感度の期待値と95%CIはいくらか
卵の名無しさん [] 2018/12/17(月) 19:41:34.06:FuhGkKV8
やはり低学歴ニートには答えられないんだな

参加賞で1曲あげといてやろう
ttp://https://www.youtube.com/watch?v=DMDnXwSiQA4
卵の名無しさん [sage] 2018/12/17(月) 19:55:33.62:N+SAyf9z


向学心を語るなら>499の計算してからな。
ド底辺頭脳クン。
卵の名無しさん [sage] 2018/12/17(月) 20:34:35.71:qP6ufigZ
source('tools.R')
ab=Mv2ab(0.70,0.01)
pbeta(0.80,ab[1],ab[2])-pbeta(0.60,ab[1],ab[2])
pbeta(0.90,ab[1],ab[2])-pbeta(0.50,ab[1],ab[2])
x=rbeta(1e5,ab[1],ab[2])
o=x/(1-x)
TP=0.80
FN=1-TP
TN=0.99
(nLR=FN/TN)
po=o*nLR^2
pp=po/(1+po)
BEST::plotPost(pp,compVal=0.10)
卵の名無しさん [sage] 2018/12/17(月) 20:34:41.41:qP6ufigZ
source('tools.R')
ab=Mv2ab(0.70,0.01)
pbeta(0.80,ab[1],ab[2])-pbeta(0.60,ab[1],ab[2])
pbeta(0.90,ab[1],ab[2])-pbeta(0.50,ab[1],ab[2])
x=rbeta(1e5,ab[1],ab[2])
o=x/(1-x)
TP=0.80
FN=1-TP
TN=0.99
(nLR=FN/TN)
po=o*nLR^2
pp=po/(1+po)
BEST::plotPost(pp,compVal=0.10)
卵の名無しさん [sage] 2018/12/17(月) 20:36:09.78:qP6ufigZ
インフルエンザ迅速検査キットの感度が80%、偽陽性率1%とする。

臨床的にはインフルエンザを疑うが迅速検査陰性、

不要な薬は使いたくない、と患者の要望。

検査が早期すぎるための偽陰性かと考えて翌日再検したが、こちらも陰性。

「私がインフルエンザである可能性はどれくらいありますか?
可能性が10%以上なら仕事を休んで抗ウイルス薬希望します。」

という。

臨床所見から疑われる有病率が70%程度(最頻値70%標準偏差10%)としたときにこの患者が仕事を休むことになる確率はいくらか?
卵の名無しさん [sage] 2018/12/18(火) 08:26:52.13:3rdYoIBg
バグに気づくのに時間がかかった、数学板に上げる前に気づいてよかった。

PQR = function(b,s){ # OQ=b ∠POQ=s
r=sin(s)/(cos(s)-1/2)
a=atan(sqrt(1^2+b^2-2*1*b*cos(s))/r) # <- WRONG!!
(s-sin(s))/2+r^2*(a-sin(a))/2+(1-b)*sin(s)/2
# (pi/2-s)/2 + b*sin(s)/2 - r^2*(a/2-sin(a)/2)
}
bb=seq(0,1,len=101)
ss=seq(0,pi/2,len=101)
z=outer(bb,ss,PQR)
image(bb,ss,z,xlab='b(OQ)',ylab='s(rad)')
contour(bb,ss,z,bty='l',nlevels=20,add=T, lty=3)
contour(bb,ss,z,levels=pi/8,lwd=2, add=T)
Persp3d(bb,ss,z)
b2s <- function(b){
uniroot(function(x) PQR(b,x)-pi/8, c(0,pi/2))$root
}
b2s=Vectorize(b2s)

L = function(b){ # 2b + 4ra
s=b2s(b)
r=sin(s)/(cos(s)-1/2)
a=atan(sqrt(1^2+b^2-2*1*b*cos(s))/r)
2*b + 4*r*a
}
L=Vectorize(L)
curve(L(x),0,pi/6,bty='l')
L(0)
卵の名無しさん [sage] 2018/12/18(火) 09:56:44.79:iW+brusm
こんな素朴な質問したら理解できない長文レスが数学化卒からきた。

4円弧モデルが最小ってどうすれば言えるの?

ttps://i.imgur.com/QK7tPmy.png
ttps://i.imgur.com/fvCMkmg.png
ttps://i.imgur.com/tsB0Xn2.png
の順に小さくなるのは計算できたけど。
卵の名無しさん [sage] 2018/12/18(火) 15:48:23.96:3rdYoIBg
暇つぶしにサムスカの太鼓持ち講演を聞いた。

相関係数を算出に全例調査しているのにp値を出していて

統計処理を理解していないアホだとわかったのが面白かった。
卵の名無しさん [sage] 2018/12/18(火) 15:50:29.76:3rdYoIBg

まあ、聞いているやつが(ド底辺シリツ医大卒のようなアホが多数で)p<0.001とか出せばエビデンスレベルが高いと誤解するだろうとわかっての所作なら策士だとは思うが。
卵の名無しさん [sage] 2018/12/18(火) 15:55:06.24:3rdYoIBg
こんなのがあんのね

電解質Na,K専用測定器 Fingraph

俺は夜間休日は血ガス測定で代用してたけど。
卵の名無しさん [] 2018/12/18(火) 21:56:13.92:RRjIHldX
3S Policy Causes the ResultTruman of Panama document and 3S policy

We are keeping the citizens in a cage named "Freedom of Falsehood".
The way you just give them some luxury and convenience.Then release sports, screen, sex (3S).
Because the citizens are our livestock. For that reason, we must make it longevity. It makes it sick
(with chemicals etc.) and keeps it alive.This will keep us harvesting. This is also the authority
of the victorious country.The medal and the Nobel prize is not all Raoul declarationExamples of 3S policy
Hypocrites and disguised society and Panama document "He moved here here two years ago, I was afraid
of looking, but I thought it was a polite person to greet" Hello "when I saw it ... It was not like I was waking
this kind of incident ... ... "(Neighboring residents)On November 7, Shosuke Hotta, 42, a self-proclaimed office
worker in Sagamihara City, Kanagawa Prefecture, was arrested on suspicion of abusing her daughter Sakurai Ai.
This is the nature of the Earthlings
卵の名無しさん [] 2018/12/18(火) 23:30:22.38:rfcy7s34
本日も事務員放送の終了時間となりました

ttp://https://m.youtube.com/watch?v=MMzpSqjIytg
卵の名無しさん [sage] 2018/12/19(水) 04:45:37.72:CUSSzVDj

相関係数を算出に全例調査しているのにp値を出だすのが
何でアホと言われるかわかる?
卵の名無しさん [sage] 2018/12/19(水) 13:50:09.99:CUSSzVDj

わからないからp値だしているのか
わからない>540のような馬鹿につけこんでいるのか、
どっちだろうな。

サイコロが2回続けて1の目出ました。

その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?

これに即答できんアホはこのスレに書く基礎学力なし。
卵の名無しさん [] 2018/12/19(水) 16:34:10.87:3mCL+IGn
さて問題です

ガチユリとガチムチの違いを原稿用紙30枚以上で述べよ
卵の名無しさん [sage] 2018/12/19(水) 16:43:43.16:CUSSzVDj


相関係数を算出に全例調査しているのにp値を出だすのが
何でアホと言われるかわかる?

サイコロが2回続けて1の目出ました。

その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?

オマエ、これに即答できんアホだろ。
卵の名無しさん [] 2018/12/19(水) 18:33:47.66:3mCL+IGn
問題に即答できんとは
さてはニートだな
卵の名無しさん [sage] 2018/12/19(水) 19:18:36.88:CUSSzVDj

統計スレで統計問題を書けないとはド底辺シリツ頭脳だな。
卵の名無しさん [] 2018/12/19(水) 20:12:36.56:3mCL+IGn
開業医でないのに開業スレに書きこむ
非医師のニート脳が何か言ってるなW
卵の名無しさん [sage] 2018/12/19(水) 21:12:41.91:CUSSzVDj

開業医スレに
こういうのを書いたら礼を言われましたよ。
ttps://egg.2ch.net/test/read.cgi/hosp/1542639046/93
卵の名無しさん [sage] 2018/12/19(水) 21:13:24.16:CUSSzVDj


サイコロが2回続けて1の目が出ました。

その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?

オマエ、これに即答できんアホだろ。
卵の名無しさん [sage] 2018/12/19(水) 21:24:51.44:CUSSzVDj


ニート脳の学力すらないどアホがオマエな。

オマエ、これに即答できんアホだろ。

統計スレなんだから

これに答えてみ!はよ!はよ!

サイコロが2回続けて1の目が出ました。

その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?
卵の名無しさん [] 2018/12/19(水) 21:25:04.74:3mCL+IGn
非医師ニートくんは
スレ1の説明も読めないようだ

ttp://itest.5ch.net/test/read.cgi/hosp/1542639046/1
卵の名無しさん [sage] 2018/12/19(水) 21:28:31.22:CUSSzVDj


スルーできないアホがオマエじゃん。

これに即答できんアホだろ。

統計スレなんだから

これに答えてみ!はよ!はよ!

サイコロが2回続けて1の目が出ました。

その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?
卵の名無しさん [sage] 2018/12/19(水) 21:49:54.61:CUSSzVDj

ttps://egg.2ch.net/test/read.cgi/hosp/1542639046/76-83
までの議論(>77が俺)は
非医者ニートとの会話だと思う?
相当頭が悪そうだな。

これに即答できんアホだろ。統計スレなんだから
これに答えてみ!はよ!はよ!

サイコロが2回続けて1の目が出ました。
その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?
卵の名無しさん [] 2018/12/19(水) 23:57:49.27:3mCL+IGn
今日もニートの歌

ttp://https://m.youtube.com/watch?v=45GP02Od_Do
卵の名無しさん [sage] 2018/12/20(木) 04:19:04.11:b33W7V5i

ttps://egg.2ch.net/test/read.cgi/hosp/1542639046/76-83
の議論(>77が俺)は
非医者ニートとの会話だと思う?
相当頭が悪そうだな。

これに即答できんアホだろ。統計スレなんだから
これに答えてみ!はよ!はよ!

サイコロが2回続けて1の目が出ました。
その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?
卵の名無しさん [sage] 2018/12/20(木) 08:39:31.68:YfbLPysN

開業医スレに
こういうのを書いたら礼を言われましたよ。
ttps://egg.2ch.net/test/read.cgi/hosp/1542639046/93

非医師ニートに教えてもらって例を言ってるのも非医師ニートなのか。二人から褒めるレスが返って来たんだが。


統計スレなんだから!これに答えてみ!はよ!はよ!

サイコロが2回続けて1の目が出ました。

その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?
卵の名無しさん [] 2018/12/20(木) 19:49:02.89:LEZzzwW7
事務員の日常

ttp://https://www.nicovideo.jp/watch/sm6470478
卵の名無しさん [sage] 2018/12/20(木) 20:49:22.03:s4OL7Lza

ttps://egg.2ch.net/test/read.cgi/hosp/1542639046/76-83
の議論(>77が俺)は
非医者ニートとの会話だと思う?
相当頭が悪そうだな。

これに即答できんアホだろ。統計スレなんだから
これに答えてみ!はよ!はよ!

サイコロが2回続けて1の目が出ました。
その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?
卵の名無しさん [] 2018/12/20(木) 22:04:13.70:aEbz7irJ
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2018/12/21(金) 07:36:37.26:RO6zf9jd
リンゲル液を凍らせた。
室温に放置して固相と液相が共存している時の液相の浸透圧は
元のリンゲル液より高いか低いかを即答できないのが
ド底辺シリツ医な、オマエも即答できんのじゃね。
ある学会でリンゲル液と同じと答えたアホがいたな。
卵の名無しさん [sage] 2018/12/21(金) 08:36:03.18:9yiQ3K91

ド底辺シリツ医にもわかるように原文をつけておけよ。

>>
私は昭和の時代に大学受験したけど、昔は今よりも差別感が凄く、特殊民のための特殊学校というイメージで開業医のバカ息子以外は誰も受験しようとすらしなかった。
常識的に考えて、数千万という法外な金を払って、しかも同業者からも患者からもバカだの裏口だのと散々罵られるのをわかって好き好んでド底辺医に行く同級生は一人もいませんでした。
本人には面と向かっては言わないけれど、俺くらいの年代の人間は、おそらくは8−9割はド底辺医卒を今でも「何偉そうなこと抜かしてるんだ、この裏口バカが」と心の底で軽蔑し、嘲笑しているよ。
当の本人には面と向かっては絶対にそんなことは言わないけどね。
<<
卵の名無しさん [] 2018/12/21(金) 12:14:03.53:oQHNIYqE
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2018/12/21(金) 17:03:49.74:JdSFbP47
 「イグっ&#9829; イグううぅーー&#9829; 鋼太郎、池袋にイっちゃうのおおぉぉ!」
卵の名無しさん [] 2018/12/21(金) 19:52:00.45:b22UegL5
age
卵の名無しさん [] 2018/12/22(土) 14:08:40.70:Ihwj4uih
ttp://https://www.nicovideo.jp/watch/sm34143061
卵の名無しさん [sage] 2018/12/23(日) 12:00:45.56:9jfRvGpH
f=c(179,28,19,13,9,7,6,5,5,4,4,4,5,7,9,10,11,12,14,16,18,19,19,20,21,22,23,24,25,27,28,30,
31,34,37,39,41,43,46,51,57,63,70,77,83,91,99,109,119,130,142,155,167,178,190,202,216,
233,249,265,282,302,326,354,387,420,457,502,549,598,648,700,761,836,927,1026,1142,1284,
1455,1651,1862,2089,2341,2625,2934,3264,3598,3923,4233,4508,4740,4893,4973,5007,4999,
4729,4314,3797,3222,2634,2071,1566,1135,788,523,761)
m=c(191,31,21,13,10,8,8,8,7,7,7,8,9,11,14,17,21,26,32,37,42,46,49,50,50,50,49,49,50,52,55,
58,60,63,65,67,71,76,82,89,97,104,112,122,134,148,165,183,203,224,246,268,294,324,357,
391,425,461,502,549,601,659,722,792,872,958,1052,1147,1239,1331,1433,1546,1663,1783,
1905,2026,2167,2333,2532,2750,2973,3195,3414,3630,3827,4000,4133,4200,4194,4104,3916,
3681,3388,3046,2669,2272,1875,1494,1145,841,589,392,246,144,79,71)

LE <-function(ndx,Y,N0=10^5){ # life expectancy
n=length(ndx)
lx=numeric(n)
lx[1]=N0
for(i in 1:(n-1))
lx[i+1] <- lx[i] - ndx[i]
nqx=ndx/lx
nLx=numeric(n)
for(i in 1:n)
nLx[i] <- mean(c(lx[i],lx[i+1]))
nLx[n]=0
Tx=rev(cumsum(rev(nLx)))
le=Tx/lx
return(round(le[Y+1],1))
}
卵の名無しさん [sage] 2018/12/23(日) 12:02:35.17:9jfRvGpH
Y=1:105
sapply(Y,function(x) LE(f,x))
sapply(Y,function(x) LE(m,x))
Y[sapply(Y,function(x) LE(m,x))<5]
sapply(Y,function(x) LE(f,x))
sapply(Y,function(x) LE(m,x))

Y=1:105
Y[sapply(Y,function(x) LE(f,x))<5]
Y[sapply(Y,function(x) LE(m,x))<5]
卵の名無しさん [] 2018/12/23(日) 18:51:20.54:u874lVPY
メリークリスマス

ttp://https://m.youtube.com/watch?v=DkpZeGIAgn4
卵の名無しさん [sage] 2018/12/24(月) 13:54:15.39:muWLHtMs
平均余命(縦線)と「平均寿命−現年齢」(点線の斜線)をグラフにしてみた。

ttps://i.imgur.com/uYnOOUs.png
卵の名無しさん [] 2018/12/24(月) 19:08:03.81:L4b+RVwf
ttp://https://m.youtube.com/watch?v=O0guNxFtetk
卵の名無しさん [] 2018/12/24(月) 20:36:41.73:6ZVUEdxI
他スレで喚いて荒らしていても
算数クイズくんが
底辺から抜け出すことは
困難を極めます
卵の名無しさん [sage] 2018/12/24(月) 22:12:45.55:lZLAiNKc
開業医スレに
こういうのを書いたら礼を言われましたよ。
ttps://egg.2ch.net/test/read.cgi/hosp/1542639046/93
卵の名無しさん [sage] 2018/12/24(月) 22:21:17.70:lZLAiNKc

これ理科のクイズ。

リンゲル液を凍らせた。
室温に放置して固相と液相が共存している時の液相の浸透圧は
元のリンゲル液より高いか低いかを即答できないのが
ド底辺シリツ医な、オマエも即答できんのじゃね。

ある学会でリンゲル液と同じと答えたアホがいたな。
卵の名無しさん [sage] 2018/12/25(火) 09:25:20.23:Lx1BgrzL
平均余命の信頼区間を計算しようと思ったが
各年齢での人口データがないと無理だな。
卵の名無しさん [] 2018/12/26(水) 00:18:55.39:rHMA/ZVK
さて国語の問題です

信じて送り出したフタナリ事務員が農家の叔父さんの・・・・・

続きを原稿用紙30枚以上で作成せよ
卵の名無しさん [sage] 2018/12/26(水) 20:53:45.05:0RdixcRl
clinical sense の症例が配信されてきた。
Devic病と思ったら経過中にレルミット兆候が出てMSに診断変更。
インターフェロンβ→ナタリズマブの前にステロイドパルスがないのが解せなかったな。
卵の名無しさん [] 2018/12/26(水) 23:30:42.66:wApOj4Hd
ところでMS法人って
みんな作ってる?
卵の名無しさん [sage] 2018/12/27(木) 14:17:15.36:7ElT0ESI
Welch.test=function(n1,n2,m1,m2,sd1,sd2){
T=(m1-m2)/sqrt(sd1^2/n1+sd2^2/n2)
df=(sd1^2/n1+sd2^2/n2)^2 / (sd1^4/n1^2/(n1-1)+sd2^4/n2^2/(n2-1))
p.value=2*pt(abs(T),df,lower.tail = FALSE)
return(c(p.value=p.value,t.statistic=T))
}

# white zoneの視認性と腺管密度の関係
# white zoneが鮮明な癌 窩間部の長さ136±45 (p<0.05)
# white zoneが不鮮明な癌 窩間部の長さ77±22 (p<0.05)

m1=136
sd1=45
m2=77
sd2=22

n2p <- function(n){
Welch.test(n,n,m1,sd1,m2,sd2)[1]
}
n2p=Vectorize(n2p)
plot(2:15,sapply(2:15,n2p),bty='l',pch=19)
abline(h=0.05)
卵の名無しさん [sage] 2018/12/27(木) 14:47:38.86:7ElT0ESI
# se=sd/√n , sd=se*√n
n2p_se <- function(n){
sd1=sd1*sqrt(n)
sd2=sd2*sqrt(n)
Welch.test(n,n,m1,sd1,m2,sd2)[1]
}
n2p_se=Vectorize(n2p_se)
n2p_se(5)
plot(n,sapply(n,n2p_se),bty='l',pch=19,ylim=c(0,1))
abline(h=c(0.01,0.05),col=8)
n2p_se(18:22)
卵の名無しさん [sage] 2018/12/27(木) 15:17:44.83:7ElT0ESI
# sim
# white zoneが鮮明な癌 窩間部の長さ136±45 (p<0.05)
# white zoneが不鮮明な癌 窩間部の長さ77±22 (p<0.05)
n=7
y1=scale(rnorm(n))*45 + 136
y2=scale(rnorm(n))*22 + 77
library(BEST)
BESTout=BESTmcmc(y1,y2)
# Look at the result:
BESTout
summary(BESTout)
plot(BESTout)
plot(BESTout, "sd")
plotPostPred(BESTout)
plotAll(BESTout, credMass=0.8, ROPEm=c(-0.1,0.1),
ROPEeff=c(-0.2,0.2), compValm=0.5)
plotAll(BESTout, credMass=0.8, ROPEm=c(-0.1,0.1),
ROPEeff=c(-0.2,0.2), compValm=0.5, showCurve=TRUE)
summary(BESTout, credMass=0.8, ROPEm=c(-0.1,0.1), ROPEsd=c(-0.15,0.15),
ROPEeff=c(-0.2,0.2))
pairs(BESTout)
卵の名無しさん [sage] 2018/12/27(木) 15:20:39.76:7ElT0ESI
white zoneの視認性と腺窩の深さの関係

white zoneが鮮明な癌 腺窩の深さ 180±47 (p<0.001)
white zoneが不鮮明な癌 腺窩の深さ 81±20 (p<0.001)
卵の名無しさん [sage] 2018/12/27(木) 15:25:25.68:7ElT0ESI

m1=180
sd1=47
m2=81
sd2=20

n2p <- function(n){
Welch.test(n,n,m1,sd1,m2,sd2)[1]
}
n2p=Vectorize(n2p)
n=2:10
plot(n,sapply(n,n2p),bty='l',pch=19)
abline(h=c(0.001,0.01),col=8)
n2p(5:10)
卵の名無しさん [sage] 2018/12/27(木) 15:30:09.78:7ElT0ESI
m1=180
sd1=47
m2=81
sd2=20

n2p <- function(n){
Welch.test(n,n,m1,sd1,m2,sd2)[1]
}
n2p=Vectorize(n2p)
n=2:10


# se=sd/√n , sd=se*√n
n2p_se <- function(n){
sd1=sd1*sqrt(n)
sd2=sd2*sqrt(n)
Welch.test(n,n,m1,sd1,m2,sd2)[1]
}
n2p_se=Vectorize(n2p_se)
n=25:35
plot(n,sapply(n,n2p_se),bty='l',pch=19,ylim=c(0,0.05))
abline(h=c(0.001,0.01),col=8)
n2p_se(27:32)
卵の名無しさん [sage] 2018/12/27(木) 15:30:31.81:7ElT0ESI
サンプルサイズが推定できて、気分が( ・∀・)イイ!!
卵の名無しさん [] 2018/12/27(木) 21:28:20.91:ZlVEHwaK
アイドル映像でも見て もちつけ

ttp://https://m.youtube.com/watch?v=duDNQoJVlRI
卵の名無しさん [sage] 2018/12/27(木) 22:51:46.90:gYAr3TuJ
qqct.jp
ttp://http://bvdeur67.secure.ne.jp/index.html
卵の名無しさん [sage] 2018/12/28(金) 00:56:18.13:Oc+hTpm3
日本にも、
ついに朝鮮殺戮殺人カルト宗教
殺人学会の、

テロ工作拠点が明らかになった!

テロ工作拠点
福山友愛病院

なんと日本警察に朝鮮殺戮殺人学会が侵入し、
カルトによる被害者側を警察が拉致して連れていくテロ工作拠点の一角!!

警察と完全犯罪達成の為に、共同組織犯罪をやっていて、

与えられていたのは、
犯罪ライセンス!!!!!!


薬物大量投与テロ発生!!
なんと故意に八倍!!!

カミサカというテロ医師による、
偽造カルテ作成発覚!!
なんとその為に監禁罪をやっていた!!!
卵の名無しさん [sage] 2018/12/28(金) 13:38:51.13:4e3e1x1A
直線解ならプログラム組めそうだけど答が円弧を含むなら
俺の能力では無理だな。
こういう問題を解ける頭脳には平伏するだけだな。


5等分の場合はこんな形が解になるそうです
ttps://imgur.com/xnH6eHf.jpg

正三角形5等分問題だと解が完全に非対称的な形になって面白い
ttps://imgur.com/rw7yGNl.jpg
卵の名無しさん [sage] 2018/12/28(金) 15:09:23.16:4e3e1x1A
自分がどれだけ馬鹿なのか自覚できていいな。
三角形なら直線で左右対象だろうとアプリオリに決めつけてプログラムしちゃうよなぁ。
卵の名無しさん [sage] 2018/12/28(金) 15:10:49.35:4e3e1x1A
理系で一番馬鹿なのが医学部を実感するなぁ。
卵の名無しさん [sage] 2018/12/29(土) 12:03:59.78:8oggYPKD
分岐角度が120°、対象図形と分割線のなす角が90°という
いわゆるplatoの法則で立式しないとコンピュータ解も難しそう。
卵の名無しさん [sage] 2018/12/29(土) 12:25:15.44:8oggYPKD

4分割ですらの正答出せなかった。

ttps://i.imgur.com/QK7tPmy.png
ttps://i.imgur.com/fvCMkmg.png
ttps://i.imgur.com/tsB0Xn2.png
の順に小さくなるのは計算できたけど。
卵の名無しさん [] 2018/12/30(日) 15:37:28.61:NpJOUauM
明日は内覧会ですW
卵の名無しさん [] 2018/12/31(月) 21:09:11.51:2cJ2vbGs
開業するのかw大晦日にw
卵の名無しさん [sage] 2018/12/31(月) 23:39:12.39:anCmupmN
数学板の統計スレにこんな課題があったのでシミュレーション解を投稿しておいた。


例えば、母集団から50枚の答案用紙を選んで、平均が
60点だとする。母集団は2500枚の答案用紙から成り立っているとして、平均は70点とする。このとき50枚の答案用紙をランダムに選んだかの検定はどの

ようにすればいいでしょうか。(つまり60点の平均点が低いので、ランダムに選んだかどうかを疑っているわけです。)
卵の名無しさん [sage] 2019/01/01(火) 10:02:25.14:fQ4brTV9
甲乙二人がおのおの32ピストル(当時のお金の単位)の金を賭けて勝負したとする。
 そしてどちらかが先に3点を得たものを勝ちとし、勝った方がかけ金の総額64ピストルをもら
 えるとする。ところが甲が2点、乙が1点を得たとき、勝負が中止になってしまった。
 このとき、二人のかけ金の総額64ピストルを甲と乙にどのように分配すればよいだろうか。
 ただし二人の力は互角で、勝つ確率はそれぞれ1/2ずつだとする。

プログラムで計算させてみる
n=0:1
x=expand.grid(n,n,n,n,n)
y=x[apply(x[,1:3],1,sum)==2,]
64*sum(apply(y,1,sum)>2)/nrow(y)
卵の名無しさん [sage] 2019/01/01(火) 21:19:05.09:nLWjX1/M
インフルエンザ脳症成人例は死亡率が高い

ttps://www.niid.go.jp/niid/images/iasr/36/429/graph/dt42951.gif


p0_4=c(14,202)
p5_19=c(20,408)
p20_59=c(7,72)
p60_=c(10,66)

p.mat=as.matrix(rbind(p0_4,p5_19,p20_59,p60_))
chisq.test(p.mat)
pairwise.prop.test(p.mat,p.adjust='holm')
fmsb::pairwise.fisher.test(p.mat)

p.mat

prop.test(c(34,17),c(610,138))
Fisher.test(c(34,17),c(610,138)
卵の名無しさん [sage] 2019/01/03(木) 18:09:59.16:6cY0SNEs
## m sd n
A=c(159.0625,sqrt(3924.729167),16)
B=c(240,sqrt(22027.5),17)
C=c(366.35,sqrt(5329.292105),20)

lh=rbind(A,B,C)
colnames(lh)=c("m","sd","n") ; lh
mean.G=sum(lh[,"m"]*lh[,"n"])/sum(lh[,"n"])
SS.bit=sum((lh[,"m"]-mean.G)^2*lh[,"n"])
SS.wit=sum(lh[,"sd"]^2*(lh[,"n"]-1))
df.bit=nrow(lh)-1
df.wit=sum(lh[,"n"]-1)
MS.bit=SS.bit/df.bit
MS.wit=SS.wit/df.wit
(F.ratio=MS.bit/MS.wit)
pf(F.ratio,df.bit,df.wit,lower.tail=FALSE)
(η2=(SS.bit)/(SS.bit+SS.wit))

A=c(159.0625,sqrt(3924.729167),16)
B=c(240,sqrt(22027.5),17)
C=c(366.35,sqrt(5329.292105),20)
a=A[1]+scale(rnorm(A[3]))*A[2]
b=B[1]+scale(rnorm(B[3]))*B[2]
c=C[1]+scale(rnorm(C[3]))*C[2]
x=c(a,b,c)
g=c(rep('A',A[3]),rep('B',B[3]),rep('C',C[3]))
g=factor(g,labels=LETTERS[1:3])
pairwise.t.test(x,g,p.adjust='holm')
卵の名無しさん [sage] 2019/01/03(木) 18:10:26.09:6cY0SNEs

ttps://i.imgur.com/BHgxjYD.png
卵の名無しさん [] 2019/01/03(木) 22:28:02.75:pv3ynAMm
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2019/01/04(金) 19:52:06.17:G2Rj2t04
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2019/01/05(土) 00:22:46.55:X56IPw/0
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2019/01/05(土) 13:06:20.59:1KoYjjkI
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2019/01/05(土) 17:38:24.01:+iYQLowq
ド底辺シリツ医にもわかるように原文をつけておけよ。

>>
私は昭和の時代に大学受験したけど、昔は今よりも差別感が凄く、特殊民のための特殊学校というイメージで開業医のバカ息子以外は誰も受験しようとすらしなかった。
常識的に考えて、数千万という法外な金を払って、しかも同業者からも患者からもバカだの裏口だのと散々罵られるのをわかって好き好んでド底辺医に行く同級生は一人もいませんでした。
本人には面と向かっては言わないけれど、俺くらいの年代の人間は、おそらくは8−9割はド底辺医卒を今でも「何偉そうなこと抜かしてるんだ、この裏口バカが」と心の底で軽蔑し、嘲笑しているよ。
当の本人には面と向かっては絶対にそんなことは言わないけどね。
<<
卵の名無しさん [] 2019/01/05(土) 19:11:13.14:71bgktVe
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2019/01/06(日) 08:58:44.31:g7qyfOQm
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2019/01/06(日) 14:48:30.19:SEvsBMAu
Zが標準正規分布に従う時、次の値を求めよ。
1:P{Z>u1}=0.05を満たすu1の値 → u1=1.645
2:P{Z<u2}=0.005を満たすu2の値 → u2=-2.576
3:P{-u3<Z<u3}=0.99を満たすu3の値 → u3=2.576

(u1=qnorm(0.05,lower.tail = FALSE))
(u2=qnorm(0.005,lower.tail= TRUE))
(u3=qnorm((1-0.99)/2,lower.tail=FALSE))
par(mfrow=c(3,1))
curve(dnorm(x),-4,4,bty='l')
curve(dnorm(x),u1,4,type='h',add=T,col=2)
curve(dnorm(x),-4,4,bty='l')
curve(dnorm(x),-4,u2,type='h',add=T,col=3)
curve(dnorm(x),-4,4,bty='l')
curve(dnorm(x),-u3,u3,type='h',add=T,col=4)

Xが正規分布N(10, 5^2)に従う時、次の確率を求めよ。
1:P{X>20} → 0.0228
2:P{X<5} → 0.1587
3:P{0<X<20} → 0.9544


1-pnorm(20,10,5)
pnorm(5,10,5)
pnorm(20,10,5)-pnorm(0,10,5)
卵の名無しさん [sage] 2019/01/06(日) 14:48:45.04:SEvsBMAu


ド底辺シリツ医にもわかるように原文をつけておけよ。

>>
私は昭和の時代に大学受験したけど、昔は今よりも差別感が凄く、特殊民のための特殊学校というイメージで開業医のバカ息子以外は誰も受験しようとすらしなかった。
常識的に考えて、数千万という法外な金を払って、しかも同業者からも患者からもバカだの裏口だのと散々罵られるのをわかって好き好んでド底辺医に行く同級生は一人もいませんでした。
本人には面と向かっては言わないけれど、俺くらいの年代の人間は、おそらくは8−9割はド底辺医卒を今でも「何偉そうなこと抜かしてるんだ、この裏口バカが」と心の底で軽蔑し、嘲笑しているよ。
当の本人には面と向かっては絶対にそんなことは言わないけどね。
卵の名無しさん [] 2019/01/06(日) 23:10:04.43:PSVRj6pz
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2019/01/07(月) 15:11:59.69:9K2vk7ik
なんだか疲れた
働きたくない
卵の名無しさん [sage] 2019/01/07(月) 15:25:03.66:31hT7o17
ttp://http://blogs.wsj.com/numbersguy/
ttp://http://www.stats.org
ttp://http://ww.numberwatch.co.uk
ttp://http://politicalarithmetik.blogspot.com
ttp://http://www.straightdope.com
ttp://http://serc.carleton.edu/nnn/index.html
ttp://http://www.statlit.org
卵の名無しさん [] 2019/01/07(月) 18:20:24.95:ubVk9gDC
戸田A哲君もアメリカで経済学助狂をやっているらしい。
バブル崩壊で安定を求めて理3に入ってしまったらしい。
無駄に齢とっちまったな。
卵の名無しさん [sage] 2019/01/07(月) 20:32:18.68:31hT7o17

正月休みで1週間ぶりに内視鏡したが違和感があるなぁ。
平日は週3やってる。
卵の名無しさん [sage] 2019/01/07(月) 21:02:56.59:31hT7o17
ttp://https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1182327/
卵の名無しさん [] 2019/01/07(月) 21:09:46.14:9K2vk7ik
なんだかだるい
あたりが暗く見える
笑い声を聞くとムカつく
疲れた
働きたくない
卵の名無しさん [] 2019/01/07(月) 21:22:19.83:/APKkASA
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2019/01/07(月) 21:26:07.02:31hT7o17
移民法でお先真っ暗だよなぁ。
卵の名無しさん [] 2019/01/07(月) 23:44:52.48:fKvhbwc+
窓の外で誰かが見ている
卵の名無しさん [sage] 2019/01/08(火) 11:14:42.05:Fx7hufSt
お天道様がみている、というのが日本人の道徳。
移民法でお先真っ暗。
卵の名無しさん [] 2019/01/08(火) 12:13:16.36:C0NmoK5j
電波が、電波の声が聞こえる
卵の名無しさん [sage] 2019/01/08(火) 12:44:58.49:o3Ur7/E6

便利でいいな。
オービスも聞こえればスピード違反で捕まることもないよな。
卵の名無しさん [sage] 2019/01/08(火) 13:32:28.48:o3Ur7/E6
rm(list=ls())

x="1-a,2-b"
y=strsplit(x,",")
z=unlist(y)
w=NULL
for(i in 1:length(z)){
w=rbind(w,unlist(strsplit(z[i],"-")))
}
data.frame(NUM=as.numeric(w[,1]),TEXT=w[,2])
卵の名無しさん [] 2019/01/08(火) 14:03:34.54:j1+ZKzaK
ダルい
疲れた
働いたら負け
卵の名無しさん [sage] 2019/01/08(火) 14:31:07.32:o3Ur7/E6

正月休みで1週間内視鏡から離れたら却って体調が悪いなぁ。

金のために不愉快な仕事をしないというのが最大幸福だな。

おかげで自宅で安眠できる。
卵の名無しさん [] 2019/01/08(火) 17:02:04.26:C0NmoK5j

これ即答してみ!

できなきゃ、ド底辺学力と認定してあげよう。

フタナリとガチユリの相関性について
原稿用紙30枚以上で考察せよ
卵の名無しさん [] 2019/01/08(火) 17:30:33.63:5YyNsaaz
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2019/01/08(火) 20:39:41.24:j/PKfHLe

原稿用紙30枚以上と書くあたり
部屋割カウントできない馬鹿とすぐ分かるぞ
卵の名無しさん [sage] 2019/01/08(火) 20:48:31.02:j/PKfHLe
こういう問題の方が楽しいね!

12345→51234のように、十進表記の末尾一桁を先頭にもってくる操作を考える。
ただし末尾は0ではないとし、全桁が同じ数字からなる数も考えないものとする。
ある数Mをこの操作でLへと置き換えた。
MがLで割り切れるMのうち、桁数が最も小さいものを全て求めよ。
卵の名無しさん [] 2019/01/08(火) 21:50:24.74:xj6Kc+5j

ナゾナゾは出せど
他人からの問題には全く回答不能なんだね

中卒ニートのコンビニバイトくん
卵の名無しさん [sage] 2019/01/08(火) 21:57:42.66:j/PKfHLe

数学板ででた問題、面白いだろ。
実用性は?だけど。

こっちは実用的。
Rのスレに質問あったのでレスしたけど
いつも達人がエレガントなコードを出してくる。
他人のコードを読むのは勉強になる。
ttps://rio2016.2ch.net/test/read.cgi/math/1501755792/630
卵の名無しさん [sage] 2019/01/08(火) 22:00:36.94:j/PKfHLe

では模範解答をお願いしますね。
原稿用紙30枚以上必要らしいけど。
はよ、はよ!
卵の名無しさん [] 2019/01/08(火) 22:00:48.42:xj6Kc+5j

これ即答してみ!

できなきゃ、ド底辺学力と認定してあげよう。

医師板で算数クイズ出して荒らしまわってて、
いい年してそんなものが何故必要かと聞かれ、
ガソリンスタンドで客からの注文に応えるため必要だ、と答えたド底辺学力のニートくんは、
なぜコンビニバイトに転職したのでしょう?
卵の名無しさん [sage] 2019/01/08(火) 22:14:44.26:j/PKfHLe

俺にはコンビニバイトは無理だな。
内視鏡や麻酔の方がずっと楽。
卵の名無しさん [sage] 2019/01/08(火) 22:16:41.70:j/PKfHLe

算数クイズができると論文の検証ができるわけね。

内視鏡の洗浄待機時間に 胃と腸 の所見用語集2017を読んでいたらこんな記載があった。(602頁Fig4の説明)

white zoneの視認性と腺管密度の関係
white zoneが鮮明な癌 窩間部の長さ136±45 (p<0.05)
white zoneが不鮮明な癌 窩間部の長さ77±22 (p<0.05)

サンプルサイズが記載なしでp<0.05としか書いてない。
p<0.01ならそう記載するだろうから、0.01<p<0.05なのだろう。
±のあとの数字は標準偏差なのか標準誤差なのか判然としない。
検定はt検定(等分散を前提とはできないのでWelch法を使用したとする)で
サンプルサイズは等しいとして±の後の数字は標準偏差あるとすると

> n2p(5:9)
p.value p.value p.value p.value p.value
0.055446074 0.032947710 0.019850610 0.012077956 0.007403284

サンプルサイズは僅か6〜8と推定される。
卵の名無しさん [sage] 2019/01/08(火) 22:20:06.62:j/PKfHLe
これ答えられるかい?
コンビニバイト以下の教養ならまあ無理だな。

>643の±の後の数字は標準誤差とすると
サンプルサイズはいくつと推定できるか?
卵の名無しさん [] 2019/01/08(火) 22:26:48.77:j1+ZKzaK
コンビニバイトくんのレスはこれだな

ttp://itest.5ch.net/test/read.cgi/hosp/1527071455/63
卵の名無しさん [] 2019/01/08(火) 22:33:11.95:xj6Kc+5j

それそれ
医師はそんなレスしないだろ
卵の名無しさん [sage] 2019/01/08(火) 22:34:22.63:j/PKfHLe

そういう計算もできない馬鹿がこういう事故を起こすわけなんだな。
ttp://i.imgur.com/ArPaux9.png

統計スレなんだから>635にでも答えてみ!
できなきゃガソリンスタンドのバイト以下の頭脳な。
卵の名無しさん [sage] 2019/01/08(火) 22:36:19.30:j/PKfHLe

ガソリンスタンドのレスは理解できたらしいが
>634のレスは理解できんだろ?ド底辺頭脳クン。
卵の名無しさん [] 2019/01/08(火) 23:00:15.32:C0NmoK5j

>統計スレなんだから

開業医でもないのに開業医スレに書き込むコンビニバイトくんに
特大ブーメランW
卵の名無しさん [sage] 2019/01/09(水) 07:21:21.07:7x5Uv3Et

標準誤差の場合のサンプルサイズ推定の
Rのコードはこのスレに既出なんだけどね。

開業医スレに投稿したら礼を言われましたぜ!
ttps://egg.2ch.net/test/read.cgi/hosp/1542639046/92-95
卵の名無しさん [sage] 2019/01/09(水) 07:23:46.55:7x5Uv3Et
ちゃんと主張の正しさにも同意を得たぞ。
ttps://egg.2ch.net/test/read.cgi/hosp/1542639046/76-83
卵の名無しさん [] 2019/01/09(水) 08:32:19.46:e7U7282c

コンビニバイトくんのレスは
何の釈明にもなっていない

>632への回答 はよはよ
卵の名無しさん [sage] 2019/01/09(水) 09:31:40.92:q6OvMTx7

礼を言われるような投稿がだよ〜ん。
あんたのは馬鹿を晒しているだけ。
ガソリンスタンドのレスは理解できたらしいが
>634のレスは理解できんだろ?ド底辺頭脳クン。
卵の名無しさん [] 2019/01/09(水) 13:44:05.50:e7U7282c

ところでコンビニバイトくん
非医師のアラシという自覚ある?

ガソリンスタンドのレスで理解できるのは
オマエがガソリンスタンドで給油の仕事をしているということのみだな
卵の名無しさん [sage] 2019/01/09(水) 14:24:39.06:7x5Uv3Et

悪いが非医師じゃないんだね。
非医師にこういう議論ができると思う?
ttps://egg.2ch.net/test/read.cgi/hosp/1542639046/76-83

こう言う方が非医師のアラシっぽいぞ。
ttps://egg.2ch.net/test/read.cgi/hosp/1540905566/625
卵の名無しさん [sage] 2019/01/09(水) 14:25:57.19:7x5Uv3Et

標準誤差のときのサンプルサイズの計算まだぁ?
ひょっとして、標準誤差が何かも知らない馬鹿ぁ?
卵の名無しさん [sage] 2019/01/09(水) 14:28:10.74:7x5Uv3Et

んで、あんたド底辺シリツ医大卒?
頭脳レベルはド底辺みたいだけど。
卵の名無しさん [sage] 2019/01/09(水) 14:52:34.20:7x5Uv3Et
ttp://http://fpr-calc.ucl.ac.uk/
の比率版を非心Χ二乗分布のRスクリプトをメールしたら返事が来たけどunderlining mathの議論が進まなかったな。
Intuitivel Biostatisticsの著者は即効で対応してErrataの追加と次版の修正の返事が来た。
卵の名無しさん [sage] 2019/01/09(水) 16:26:11.62:q6OvMTx7

どアホにもわかる計算の例示として税込みガソリン価格を上げただけということすらわからんらしいな。
こういう問題に算数が必要と書いてもオマエの頭じゃ正解だせないだろ?

診療所から病院に患者を救急搬送する。
病院から医師搭乗の救急車が診療所に向かっており10時到着予定と連絡が入った。
患者の病態が悪化したら、診療所の普通車で病院に向かい救急車と出会ったら
救急車に患者を移して搬送し病院到着を急ぐという計画を立てた。
普通車から救急車への患者の乗り換えで10分余分に時間がかかる。
道路事情から救急車は病院から診療所への道は
平均時速60kmで、逆方向は平均時速45kmで定速走行する。診療所の普通車は信号待ちもあり平均時速30kmで定速走行する。

何時以降の病態悪化は診療所の車を使わずに救急車の到着を待つ方が病院に早く着くか?
卵の名無しさん [] 2019/01/09(水) 16:42:16.13:PAq6vTKi

非正規雇用のオッさんの言い訳キモス
反面教師にしかならんわね

もうすぐ冬休みも終わって
再来年は高校受験だわ〜
卵の名無しさん [sage] 2019/01/09(水) 18:36:24.74:7x5Uv3Et

答まだぁ?
阿呆じゃね??
卵の名無しさん [] 2019/01/09(水) 19:44:34.23:e7U7282c
中学生にすらバカにされるコンビニバイトくんW
卵の名無しさん [sage] 2019/01/10(木) 14:24:50.58:9bNrFpHw

その頭脳すらなくて答られないのがオマエだぞ。
卵の名無しさん [sage] 2019/01/10(木) 14:25:28.63:9bNrFpHw


どアホにもわかる計算の例示として税込みガソリン価格を上げただけということすらわからんらしいな。
こういう問題に算数が必要と書いてもオマエの頭じゃ正解だせないだろ?

診療所から病院に患者を救急搬送する。
病院から医師搭乗の救急車が診療所に向かっており10時到着予定と連絡が入った。
患者の病態が悪化したら、診療所の普通車で病院に向かい救急車と出会ったら
救急車に患者を移して搬送し病院到着を急ぐという計画を立てた。
普通車から救急車への患者の乗り換えで10分余分に時間がかかる。
道路事情から救急車は病院から診療所への道は
平均時速60kmで、逆方向は平均時速45kmで定速走行する。診療所の普通車は信号待ちもあり平均時速30kmで定速走行する。

何時以降の病態悪化は診療所の車を使わずに救急車の到着を待つ方が病院に早く着くか?
卵の名無しさん [sage] 2019/01/10(木) 14:26:28.27:9bNrFpHw


悪いが非医師じゃないんだね。
非医師にこういう議論ができると思う?
ttps://egg.2ch.net/test/read.cgi/hosp/1542639046/76-83

こう言う方が非医師のアラシっぽいぞ。
ttps://egg.2ch.net/test/read.cgi/hosp/1540905566/625
卵の名無しさん [sage] 2019/01/10(木) 14:44:10.09:9bNrFpHw
バレット食道がんって右にあるよなぁ。

ttps://www.hindawi.com/journals/isrn/2013/840690.fig.001b.jpg
卵の名無しさん [] 2019/01/10(木) 19:43:55.09:xCiYE3NF
〜657
これ即答してみ!

できなきゃ、ド底辺学力と認定してあげよう。

医師板で算数クイズ出して荒らしまわってて、
いい年してそんなものが何故必要かと聞かれ、
ガソリンスタンドで客からの注文に応えるため必要だ、と答えたド底辺学力のニートくんは、
なぜコンビニバイトに転職したのでしょう?



送り仮名がオカシイところをみると
日本の方ですらないのですかね
卵の名無しさん [sage] 2019/01/10(木) 20:04:49.50:9bNrFpHw


悪いが非医師じゃないんだね。
非医師にこういう議論ができると思う?
ttps://egg.2ch.net/test/read.cgi/hosp/1542639046/76-83

こう言う方が非医師のアラシっぽいぞ。
ttps://egg.2ch.net/test/read.cgi/hosp/1540905566/625
卵の名無しさん [] 2019/01/11(金) 07:03:12.10:eIjYcl4Y

非正規雇用のオッさんの言い訳キモス
反面教師にしかならんわね

もうすぐ冬休みも終わって
再来年は高校受験だわ〜
卵の名無しさん [sage] 2019/01/11(金) 07:05:30.85:SA5KNNkQ

どアホにもわかる計算の例示として税込みガソリン価格を上げただけということすらわからんらしいな。
こういう問題に算数が必要と書いてもオマエの頭じゃ正解だせないだろ?

診療所から病院に患者を救急搬送する。
病院から医師搭乗の救急車が診療所に向かっており10時到着予定と連絡が入った。
患者の病態が悪化したら、診療所の普通車で病院に向かい救急車と出会ったら
救急車に患者を移して搬送し病院到着を急ぐという計画を立てた。
普通車から救急車への患者の乗り換えで10分余分に時間がかかる。
道路事情から救急車は病院から診療所への道は
平均時速60kmで、逆方向は平均時速45kmで定速走行する。診療所の普通車は信号待ちもあり平均時速30kmで定速走行する。

何時以降の病態悪化は診療所の車を使わずに救急車の到着を待つ方が病院に早く着くか?
卵の名無しさん [] 2019/01/11(金) 08:08:05.29:wEewwlyz

>税込みガソリン価格を上げただけ ?W

違うよねぇ

ttp://egg.5ch.net/test/read.cgi/hosp/1527071455/62-63
>税込みで5000円分給油してと言われて対応できないと仕事にならんだろ?

巧妙な話のすり替えワロス

医師は給油の仕事はしないよね
コンビニバイトくん
卵の名無しさん [sage] 2019/01/11(金) 08:59:52.18:SA5KNNkQ

どアホにもわかる計算の例示として税込みガソリン価格を上げただけということすらわからんらしいな。
こういう問題に算数が必要と書いてもオマエの頭じゃ正解だせないだろ?

診療所から病院に患者を救急搬送する。
病院から医師搭乗の救急車が診療所に向かっており10時到着予定と連絡が入った。
患者の病態が悪化したら、診療所の普通車で病院に向かい救急車と出会ったら
救急車に患者を移して搬送し病院到着を急ぐという計画を立てた。
普通車から救急車への患者の乗り換えで10分余分に時間がかかる。
道路事情から救急車は病院から診療所への道は
平均時速60kmで、逆方向は平均時速45kmで定速走行する。診療所の普通車は信号待ちもあり平均時速30kmで定速走行する。

何時以降の病態悪化は診療所の車を使わずに救急車の到着を待つ方が病院に早く着くか?
卵の名無しさん [sage] 2019/01/11(金) 09:01:14.48:SA5KNNkQ
数学板の統計スレで助言したら礼を言われた。

ttps://rio2016.2ch.net/test/read.cgi/math/1478799258/688
卵の名無しさん [sage] 2019/01/11(金) 09:22:06.72:SA5KNNkQ

そのスレの続きみたぁ?
ガソリンスタンドバイトでないことは普通の頭脳があれば理解できてるぞ。

ttps://egg.5ch.net/test/read.cgi/hosp/1527071455/64-65

ttps://egg.5ch.net/test/read.cgi/hosp/1527071455/96
卵の名無しさん [] 2019/01/11(金) 12:10:41.16:2Jz2b/ri
いい年してバイトのオッさん
おおキモイキモイ
卵の名無しさん [] 2019/01/11(金) 13:28:05.64:wEewwlyz

>税込みガソリン価格を上げただけ ?W

違うよねぇ

ttp://egg.5ch.net/test/read.cgi/hosp/1527071455/62-63
>税込みで5000円分給油してと言われて対応できないと仕事にならんだろ?

稚拙な話のすり替えワロス

医師は給油の仕事はしないよね
コンビニバイトくん

スレを辿ると
受験は遥か昔の医師の人生にとって一次方程式が何の役に立つのか? 
というレスにオマエが
給油の仕事で対応できない
と答えたんだよね

普通に見れば、ナリスマシ非医師のボロが出た、としか考えられんよねW
卵の名無しさん [sage] 2019/01/11(金) 13:49:59.59:SA5KNNkQ

一次方程式は役に立つよ。
これも二次方程式は必要ないぞ。
答えてみ!


どアホにもわかる計算の例示として税込みガソリン価格を上げただけということすらわからんらしいな。
こういう問題に算数が必要と書いてもオマエの頭じゃ正解だせないだろ?

診療所から病院に患者を救急搬送する。
病院から医師搭乗の救急車が診療所に向かっており10時到着予定と連絡が入った。
患者の病態が悪化したら、診療所の普通車で病院に向かい救急車と出会ったら
救急車に患者を移して搬送し病院到着を急ぐという計画を立てた。
普通車から救急車への患者の乗り換えで10分余分に時間がかかる。
道路事情から救急車は病院から診療所への道は
平均時速60kmで、逆方向は平均時速45kmで定速走行する。診療所の普通車は信号待ちもあり平均時速30kmで定速走行する。

何時以降の病態悪化は診療所の車を使わずに救急車の到着を待つ方が病院に早く着くか?
卵の名無しさん [sage] 2019/01/11(金) 13:51:40.72:SA5KNNkQ


そのスレの続きみたぁ?

シンプソンのパラドックスに感心したらしい開業医のレス読めないの?

ttps://egg.5ch.net/test/read.cgi/hosp/1527071455/64-65

ttps://egg.5ch.net/test/read.cgi/hosp/1527071455/96
卵の名無しさん [] 2019/01/11(金) 14:41:37.54:wEewwlyz
>668
>税込みガソリン価格を上げただけ ?W

違うよねぇ

ttp://egg.5ch.net/test/read.cgi/hosp/1527071455/62-63
>税込みで5000円分給油してと言われて対応できないと仕事にならんだろ?

稚拙な話のすり替えワロス

医師は給油の仕事はしないよね
コンビニバイトくん

スレを辿ると
受験は遥か昔の医師の今後の人生にとって算数が何の役に立つのか? 
というレスにオマエが
給油の仕事で対応できない
と答えたんだよね

普通に見れば、ナリスマシ非医師のボロが出た、としか考えられんよねW
卵の名無しさん [sage] 2019/01/11(金) 15:58:22.65:JAXb750V
# calculate point FPR by David Colquhoun
calc.FPR = function(pval=0.0475,nsamp=16,prior=0.5,sigma=1,delta1=1){
sdiff=sqrt(sigma^2/nsamp + sigma^2/nsamp)
df=2*(nsamp-1)
# Note FPR doesn't need calculation of power for p-equals case #
# under H0, use central t distribution
tcrit=-qt(pval/2,df,ncp=0)
x0=tcrit
y0=dt(x0,df,0)

#
# under H1 use non-central t distribution
ncp1=delta1/sdiff #non-centrality paramater
curve(dt(x,df),-3-ncp1,3+ncp1, ann=FALSE,bty='n')
curve(dt(x,df,ncp1),add=TRUE,lty=2)
abline(v=x0,lty=3)
x1=x0 #tcrit
y1=dt(x1,df,ncp=ncp1)
#
# Calc false positive rate
p0=2*y0 # p.value : two-sided verified with simulation
p1=y1
LRH1=p1/p0
FPR=((1-prior)*p0)/(((1-prior)*p0) + prior*p1)
FPR
output=c(FPR,LRH1)
return(FPR)
}
# end of function calc.FPR
calc.FPR()
卵の名無しさん [sage] 2019/01/11(金) 15:58:53.36:JAXb750V

そのスレの続きみたぁ?

シンプソンのパラドックスに感心したらしい開業医のレス読めないの?

ttps://egg.5ch.net/test/read.cgi/hosp/1527071455/64-65

ttps://egg.5ch.net/test/read.cgi/hosp/1527071455/96
卵の名無しさん [sage] 2019/01/11(金) 16:08:40.06:JAXb750V
内視鏡の洗浄待機時間に 胃と腸 の所見用語集2017を読んでいたらこんな記載があった。(602頁Fig4の説明)
white zoneの視認性と腺管密度の関係
white zoneが鮮明な癌 窩間部の長さ136±45 (p<0.05)
white zoneが不鮮明な癌 窩間部の長さ77±22 (p<0.05)

サンプルサイズが記載なしでp<0.05としか書いてない。p<0.01ならそう記載するだろうから、0.01<p<0.05なのだろう。
±のあとの数字は標準偏差なのか標準誤差なのか判然としない。
検定はt検定(等分散を前提とはできないのでWelch法を使用したとする)で
サンプルサイズは等しいとして±の後の数字は標準偏差あるとすると
> n2p(5:9)
p.value p.value p.value p.value p.value
0.055446074 0.032947710 0.019850610 0.012077956 0.007403284
サンプルサイズは僅か6〜8と推定される。

n=7
p.value=0.019850610

としてFalse Positive Riskを計算してみる(非心t分布でのコードは既出)

# calculate point FPR by David Colquhoun
を実行してみる。
> calc.FPR(0.01985,nsamp=7)
[1] 0.1245345
Web caluculator
ttp://http://fpr-calc.ucl.ac.uk/
の結果と一致して、気分が( ・∀・)イイ!!
卵の名無しさん [sage] 2019/01/11(金) 16:23:30.11:JAXb750V
Colquhounの方法って
尤度比を確率密度比で算出してんだよなあ
reverse Bayesとか呼んでるけど。

式で書けばこうなるはず、
# FPR=1/(1+L10*PH1/(1-PH1)) where L10 likelihood ratio = P(Data|H1)/P(Data|H0) ,PH1: prior of H1

4.
The point null
Some people don’t like the assumption of a point null that’s made in this
proposed
approach to calculating the false positive risk
, but it seems natural to users who wish
to know how likely their observations would be if there were really no effect (i.e. if the
point null were true). It’s often claimed that the null is never exactly true. This isn’t
necessarily so (just giv
e identical treatments to both groups). But more importantly, it
doesn’t matter. We aren’t saying that the effect size is exactly zero: that would
obviously be impossible. We are looking at the likelihood ratio, i.e. at the probability
of the data if the t
rue effect size were not zero relative to the probability of the data if
the effect size were zero. If the latter probability is bigger than the former then
clearly we can’t be sure that there is anything but chance at work. This does
not
mean that we ar
e saying that the effect size is exactly zero. From the point of view
of the experimenter, testing the point null makes total sense. In any case, it makes
little difference if the null hypothesis is a narrow band centred on zero
(Berger and Delampady 1987)
.
卵の名無しさん [sage] 2019/01/11(金) 16:26:49.23:JAXb750V

ここにレクチャーが
ttp://https://www.youtube.com/watch?v=iFaIpe9rFR0
あるんだけど、
非心t分布にはなんにも言及がないんだよなぁ。

非心分布の解説本ってこれを凌駕するのはないな。

サンプルサイズの決め方 (統計ライブラリー)

GPowerとかのソフト使ってクリック猿になるのは楽しくない。
卵の名無しさん [sage] 2019/01/11(金) 16:35:41.41:JAXb750V
比率のFalse Positive Risk算出のスクリプトを書いてみた。

calc.FPR.prop <- function(r1,r2,n1,n2,alpha=0.05,Print=TRUE,Show.chi=TRUE){
p.val=prop.test(c(r1,r2),c(n1,n2))$p.value
k=length(c(r1,r2)) # 2
df=k-1 # 1
p1=r1/n1 ; p2=r2/n2
PO=c(p1,p2) # proporition observed
# approximation with arcsine -- deprecated
# theta.i=asin(sqrt(PO)) # arcsine conversion
# delta=4*var(theta.i)*(k-1) # sum of squares
PE=(r1+r2)/(n1+n2) # PE: proportion expected
delta=sum((PO-PE)^2/PE)
N=2/(1/n1+1/n2) # harmonic mean to fit when n1 is not equal to n2
ncp1=N*delta # non-central parameter
power.chi=pchisq(qchisq(1-alpha,df),df,ncp1,lower=FALSE)
q.alpha=qchisq(1-alpha,df) # 3.841 when alpha=0.05
qcrit=qchisq(max(p.val,1-p.val),df,ncp=0) # qcrit = prop.test(c(r1,r2),c(n1,n2))$statistic
y0=dchisq(qcrit,df,0)
y1=dchisq(qcrit,df,ncp=ncp1)
FPR.equal=y0/(y0+y1) # length ratio = likelyhood ratio
if(Print){
curve(dchisq(x,df),0.5,3*qcrit,ylim=c(0,0.3),xlab=expression(paste(chi,'2')),ylab='density',bty='n',lwd=2,type='n') # H0
curve(dchisq(x,df,ncp1),qcrit,3*qcrit,col='lightgreen',type='h',add=TRUE,lwd=2)
curve(dchisq(x,df),qcrit,3*qcrit,col='orange',type='h',add=TRUE)
curve(dchisq(x,df),lwd=2,add=TRUE) # H0
curve(dchisq(x,df,ncp1),add=TRUE,lty=2,lwd=2) # H1
abline(v=qcrit)
abline(v=q.alpha,col='gray',lty=3)
卵の名無しさん [sage] 2019/01/11(金) 16:36:13.06:JAXb750V
legend('topright',bty='n',
legend=c('H0','H1',expression(paste(chi,'2:p.value')),expression(paste(chi,'2:alpha'))),
col=c('orange','lightgreen',1,'gray'),lty=c(1,2,1,3),lwd=c(2,2,1,1))
text(qcrit,y0,'y0',cex=0.75)
text(qcrit,y1,'y1',cex=0.75)
if(Show.chi){
text(qcrit,0,round(qcrit,2),cex=0.75)
text(q.alpha,0.30,round(q.alpha,2),cex=0.75)
}
}
ES=pwr::ES.h(r1/n1,r2/n2)
my.power=pwr::pwr.2p2n.test(ES,n1,n2,sig.level=p.val)$power
FPR.less=p.val/(p.val+my.power) # area ratio for 'less than' FDR
FPR.alpha=alpha/(alpha+power.chi) # FPR at alpha
output=c(power=power.chi,p.value=p.val,FPR.equal=FPR.equal,LH10=y1/y0,
FPR.less=FPR.less,FPR.alpha=FPR.alpha)
return(output)
}
##
calc.FPR0.p2 <- function(r1,r2,n1,n2,prior=0.5,alpha=0.05){
pval=prop.test(c(r1,r2),c(n1,n2))$p.value
ES=pwr::ES.h(r1/n1,r2/n2)
my.power=pwr::pwr.2p2n.test(ES,n1,n2,sig.level=pval)$power
power=pwr::pwr.2p2n.test(ES,n1,n2,sig.level=alpha)$power
LH10=my.power/pval # NOTE: sig.level=pval, not 0.05
FPR=pval*(1-prior)/(pval*(1-prior)+my.power*prior)
output=c(my.power=my.power,power=power,p.value=pval,FPR.less=FPR,LH10=LH10)
return(output)
}
卵の名無しさん [sage] 2019/01/11(金) 16:39:30.67:JAXb750V
> # EMPA-REG OUTCOME test
> # ttp://http://square.umin.ac.jp/massie-tmd/dmekuso.html
> np=2333 ; rp=282
> n10=2345 ; r10=243
> n25=2342 ; r25=247
> calc.FPR0.p2(rp,r10+r25,np,n10+n25)
my.power power p.value FPR.less LH10
0.50788496 0.53163451 0.04342913 0.07877384 11.69456891

ここに上げたけど、外部パッケージが必要なのでグラフしか出力されないな。
ttp://http://tpcg.io/lz0Ck7
卵の名無しさん [sage] 2019/01/11(金) 16:55:13.20:JAXb750V
p値って(帰無仮説棄却の)結論が誤っている確率だと思っている椰子が多いんだよなぁ。

ttps://rio2016.5ch.net/test/read.cgi/math/1478799258/701
卵の名無しさん [sage] 2019/01/11(金) 19:59:26.63:JAXb750V
calc.FPR = function(nsamp,pval,sigma,prior,delta1){
# sdiff=sqrt(sigma^2/nsamp + sigma^2/nsamp)
ns1=nsamp
ns2=nsamp
# CALC sdiff = sd of difference between means
sdiff=sqrt(sigma^2/ns1 + sigma^2/ns2)
df=ns1+ns2-2
# Note FPR doesn't need calculation of power for p-equals case
#
#under H0, use central t distribution
tcrit=qt((1-pval/2),df,ncp=0)
x0=tcrit
y0=dt(x0,df,0)
#
# under H1 use non-central t distribution
ncp1=delta1/sdiff #non-centrality paramater
x1=x0 #tcrit
y1=dt(x1,df,ncp=ncp1)
# check solution
# pcheck=pt(y1,df,ncp=ncp1)
# pcheck

# Calc false positive risk
p0=2*y0
p1=y1
FPR=((1-prior)*p0)/(((1-prior)*p0) + prior*p1)
cat('FPR = ',FPR,'\n')
output=c(FPR,x0,y0,x1,y1)
invisible(output)
}
# end of function calc.FPR
#
卵の名無しさん [sage] 2019/01/11(金) 19:59:55.21:JAXb750V
# calc.FPR0 gives FPR for given nsamp, for p-less-than case
calc.FPR0 = function(nsamp,pval,sigma,prior,delta1){
myp=power.t.test(n=nsamp,sd=sigma,delta=delta1,sig.level=pval,type="two.sample",alternative="two.sided",power=NULL)
power = myp$power
PH1=prior
PH0=1-PH1
FPR0=(pval*PH0/(pval*PH0 + PH1*power))
output=c(FPR_less=FPR0,power=power)
return(output)
}
#
calc.FPR(nsamp=7,pval=0.01985,sigma=1,prior=0.5,delta1=1)
calc.FPR0(nsamp=7,pval=0.01985,sigma=1,prior=0.5,delta1=1)

> calc.FPR(nsamp=7,pval=0.01985,sigma=1,prior=0.5,delta1=1)
FPR = 0.1245345
> calc.FPR0(nsamp=7,pval=0.01985,sigma=1,prior=0.5,delta1=1)
FPR_less power
0.07274575 0.25301819
>
卵の名無しさん [sage] 2019/01/11(金) 20:22:21.59:JAXb750V

そのシミュレーション

# t.test simulation when 0.045< p.value < 0.05
N=1000
n=10
x0=rnorm(N)
x1=rexp(N)

f<-function(prior=0.5){
choice=sample(1:0,1,prob=c(prior,1-prior))
x=sample(x0,n)
if(choice){
y=sample(x1,n) # choose different mean population
}else{
y=sample(x0,n) # choose the same population
}
c(t.test(x,y)$p.value,choice)
}
re=replicate(1e4,f(0.5))
res=re[2,re[1,]<0.045 & re[1,]<=0.050]
mean(res==0) # proportion of the same population = FPR
卵の名無しさん [] 2019/01/14(月) 21:11:37.39:W3rmWG0w
疲れた
ダルい
働いたら負け
卵の名無しさん [] 2019/01/14(月) 21:59:39.64:lm1UHN1Y
働きたくない
卵の名無しさん [sage] 2019/01/15(火) 11:09:44.07:dvPyxe58
待機で賃金が発生する職場が( ・∀・)イイ!!
卵の名無しさん [] 2019/01/15(火) 13:02:35.43:9BKWXGSR

職場に出勤しなくちゃいけない時点で負け組
卵の名無しさん [sage] 2019/01/15(火) 20:42:00.10:LzPFbWpe

自宅だと飲酒するから身体に悪い
卵の名無しさん [] 2019/01/16(水) 08:14:37.24:gq6jTqnA

焼肉屋のオーナーなんぞ
従業員を働かせて
毎日ゴルフ三昧だぞ
卵の名無しさん [sage] 2019/01/16(水) 17:55:44.22:ZhNONJwp

別にゴルフしたくないんだが。

こういう問題が解けた方が楽しい。
ttps://rio2016.2ch.net/test/read.cgi/math/1532824890/90
まとまった時間がとれないとできないな。
卵の名無しさん [] 2019/01/17(木) 13:00:45.59:jUkqCyOy

ゴルフは単なる症例報告だ
俺もゴルフは全くやらん

調剤薬局もそうだ
医師は自分で働かないと無収入になるのに対して
薬局オーナーは出勤せずに毎日遊び歩いていても
病院オーナーよりはるかに高い収入を得ている
しかも薬局オーナーは薬剤師である必要すらない
卵の名無しさん [sage] 2019/01/17(木) 14:01:12.40:qxQFIIFv

オーナー理事長で役員報酬の不労所得の医師もいるぞ。
卵の名無しさん [sage] 2019/01/17(木) 15:18:23.26:qxQFIIFv
治療薬ハンドブックを読んで該当箇所のポケット医薬品集を読むと
同効薬の違いが分かって(・∀・)イイ!!
防腐剤を含まない点眼抗菌薬はどれかとか実に役立つ。
卵の名無しさん [] 2019/01/17(木) 19:35:01.75:jUkqCyOy

そいつは働いたことが無いのかい?
でなきゃ妬ましくないな

俺の同級生の土建屋やパチンコ屋の子弟はひどいぞ
最終学歴が高卒だけど
就業経験ゼロで役員になって一生豪遊してるからな
卵の名無しさん [sage] 2019/01/19(土) 10:34:13.59:8uFRJt6f

パチンコ屋や土建屋の子弟ってシリツ医大に多いよな。
卵の名無しさん [] 2019/01/19(土) 14:00:04.35:+22CUuCd

知り合いの話かい?

他大学のことは知らんが
俺の出身の国立医学部にも土建屋の娘は居た

それはそうとニュースでミッキーハウス事件を見たことがあるかい?
あのニュースを見て理解できるのは
土建屋は病院なんぞ比べ物にならんくらい稼いでいるという事実だ

まあいずれにしても言えることは
働いたら負け
ということだ
卵の名無しさん [sage] 2019/01/19(土) 14:27:08.71:+Z1Yrlmo

この国には勤労・納税・教育の義務があんのよ。
卵の名無しさん [sage] 2019/01/19(土) 14:28:40.93:+Z1Yrlmo

納税したら負け、という価値観の椰子は多いだろうなぁ。
卵の名無しさん [] 2019/01/19(土) 15:20:32.33:tosZV9uO
働いたら負けだお
お家でカウチポテトしてコーラ飲んで
動画見てるのが最高だお
卵の名無しさん [sage] 2019/01/19(土) 16:57:43.58:8uFRJt6f

いや、学会出張に愛人を連れて行く方が楽しいんだが。
卵の名無しさん [] 2019/01/19(土) 17:22:09.90:HPdDoYmX

学会のついでになど下らん

平日の昼間に遊び歩いてこそ勝ち組だ
卵の名無しさん [sage] 2019/01/19(土) 17:46:18.37:8uFRJt6f

学会のついでの方が燃えるぞ!
卵の名無しさん [] 2019/01/19(土) 20:05:18.74:nd1Bx6ok
ttp://https://virtualsan-looking.jp/staff/

三権分立が存在しない権力のゴキブリ自民レイプ山口敬之安倍官製ドワンゴとゴキブリ共は庵のは原爆で細胞ごと死滅しろw
卵の名無しさん [] 2019/01/19(土) 21:15:57.55:m2smxm4o
疲れた
ダルい
働きたくない
卵の名無しさん [sage] 2019/01/19(土) 22:13:35.46:+Z1Yrlmo
curve(dnorm(x,50,10),0,100,bty='l')
curve(dnorm(x,50,10),q60,100,type='h',col='yellow',add=T)
curve(dnorm(x,50,10),q30,100,type='h',col='green',add=T,lty=3)

segments(q60,0,q60,dnorm(q60,50,10),lty=3)

pnorm(c(65,68,69),50,10,lower=F)
(q30=qnorm(1-0.3,50,10))
(q60=qnorm(1-0.6,50,10))
integrate(function(x) x*dnorm(x,50,10)/0.3,q30,Inf)$value - integrate(function(x) x*dnorm(x,50,10)/0.6,q60,Inf)$value

library(BEST)

sim <- function(){
N=1e4
x=scale(rnorm(N/0.3))*10+50
x30=x[x>=q30]
x=scale(rnorm(N/0.6))*10+50
x60=x[x>=q60]
d=x30-x60
mean(d)
}
re=replicate(1e3,sim())
summary(re)
卵の名無しさん [] 2019/01/19(土) 22:32:24.95:m2smxm4o
働いたら負け
卵の名無しさん [] 2019/01/19(土) 22:49:34.18:NSnAx4LQ

盆や年末に俗世を離れてコミケに行く
アタイは勝ち組
卵の名無しさん [sage] 2019/01/20(日) 08:22:51.49:cvbKrpB0
f <- function(p,sd=10){
m=sample(100,1)
ma=integrate(function(x)x*dnorm(x,m,sd)/(1-p),-Inf,qnorm(1-p,m,sd))$value
m-ma
}
f=Vectorize(f)
pp=seq(0.001,0.999,0.001)
plot(pp,f(pp),bty='l',type='l',xlab='辞退率',ylab='虚飾値',lwd=2)
卵の名無しさん [sage] 2019/01/20(日) 08:42:33.97:cvbKrpB0
'(1)予備校の発表する偏差値は合格者の偏差値の平均値
(2)合格者の成績分布は正規分布で標準偏差は母集団と同じ
(3)成績のよい方から入学を辞退する

虚飾値=合格者の偏差値 - 入学者の偏差値
'
f <- function(p,sd=10){
m=sample(100,1)
ma=integrate(function(x)x*dnorm(x,m,sd)/(1-p),-Inf,qnorm(1-p,m,sd))$value
m-ma
}
f=Vectorize(f)
pp=seq(0.001,0.999,0.001)
plot(pp,f(pp),bty='l',type='l',xlab='辞退率',ylab='虚飾値',lwd=2)

p=seq(0.1,0.9,0.1)
data.frame(辞退率=p,虚飾値=round(f(p),1))
卵の名無しさん [sage] 2019/01/20(日) 08:46:51.24:cvbKrpB0

虚飾値がmの値によらないのは興味深いな。
卵の名無しさん [] 2019/01/20(日) 18:02:46.35:4pPRgzzq
明日は月曜
暗い日曜日
卵の名無しさん [sage] 2019/01/20(日) 18:31:46.86:vchoPnFo

明日の午後から火曜日まで代休。
卵の名無しさん [sage] 2019/01/20(日) 18:32:59.56:vchoPnFo

以下の(1)(2)(3)を前提にして計算

(1)予備校の発表する偏差値は合格者の偏差値の平均値
(2)合格者の成績分布は正規分布で標準偏差は母集団と同じ
(3)成績のよい方から入学を辞退する

虚飾値=合格者の偏差値 - 入学者の偏差値

と定義して、辞退率と虚飾値の関係をグラフにすると


ttp://i.imgur.com/7WQQPKu.png


辞退率 虚飾値
0.1 1.9
0.2 3.5
0.3 5.0
0.4 6.4
0.5 8.0
0.6 9.7
0.7 11.6
0.8 14.0
0.9 17.5
卵の名無しさん [] 2019/01/20(日) 19:47:26.59:4pPRgzzq
負〜け負け負け負け〜負け〜
働いたら〜負け〜負け〜
働い〜たら〜負〜け〜な〜の〜ら〜♪
卵の名無しさん [sage] 2019/01/21(月) 06:45:51.44:20jAC8Su
教養がないのが負け組
卵の名無しさん [] 2019/01/21(月) 07:02:55.12:zCz5KSqt
ダルい
疲れた
働いたら負け
卵の名無しさん [] 2019/01/21(月) 11:08:16.93:Ed3wv7za
国試諦めてくれてありがとう。
卵の名無しさん [sage] 2019/01/21(月) 13:41:29.97:ulNFNnBT
先週は祝日だったので今日は内視鏡予約が多くて
この時間にステーキハウス。

眠剤のんでる老人はsedationの効きが悪いぜい。
卵の名無しさん [sage] 2019/01/21(月) 14:28:43.64:ulNFNnBT

この証明は難しいな。
数値積分での実感は簡単(ド底辺シリツ医を除く)だけどね。
卵の名無しさん [sage] 2019/01/21(月) 14:33:18.08:ulNFNnBT
オセロやルービックをプログラムで解く秀才は尊敬するな。
医学部にはいない。
卵の名無しさん [] 2019/01/21(月) 14:57:25.09:Ed3wv7za
良かったなー本当にありがとうございます。医者にならないで。良かったなー。
卵の名無しさん [] 2019/01/21(月) 15:04:18.32:Ed3wv7za
ありがとうございます。患者さんや医療従事者にとっては医者を諦めていただいて良かったです。
卵の名無しさん [sage] 2019/01/21(月) 15:04:35.86:ulNFNnBT
馬鹿でもできるのが臨床医。

算数の掛け算すら怪しいのがシリツ医がこういう事故を起こすわけなんだな。

ttp://i.imgur.com/ArPaux9.png
卵の名無しさん [] 2019/01/21(月) 15:12:33.23:Ed3wv7za
問題のある人物を医療の世界に入れることぐらい怖いものはないです。本当にありがとうございます。
卵の名無しさん [] 2019/01/21(月) 15:40:19.56:Ed3wv7za
医師の道を諦められたことに 同意いたします。その判断は正しいです。
卵の名無しさん [] 2019/01/21(月) 15:49:54.66:Ed3wv7za
ホッと一息 大学 厚生労働省。良かったね。
卵の名無しさん [] 2019/01/21(月) 15:58:20.70:xX0sMtrn
カネが欲しいから医学部にいくんや
文句あっか
卵の名無しさん [] 2019/01/21(月) 16:06:43.94:Ed3wv7za
危な過ぎて 許容できない。by 大学 厚生労働省
卵の名無しさん [sage] 2019/01/21(月) 16:34:11.82:5GFeLbpQ
東京医大が本来合格者に追加合格させても

本来不合格者を除籍処分しないのだから

シリツ=裏口容疑者が確定だよ。

シリツ出身者こそ、裏口入学に厳しい処分せよを訴えるべき。

裏口入学医師の免許剥奪を!の国民運動の先頭に立てばよいぞ。

僕も裏口入学とか、言ってたら信頼の回復はない。
卵の名無しさん [sage] 2019/01/21(月) 16:37:46.83:5GFeLbpQ

証明は複雑な定積分が必要だな。
俺には無理なので数値積分で確認。
中心極限定理もそうだな。
卵の名無しさん [sage] 2019/01/21(月) 16:38:36.40:5GFeLbpQ

接客業は賤業。
卵の名無しさん [] 2019/01/21(月) 18:54:15.63:guiK2BJ8

仕事は何をしてるのかね?

いまどき正規職員でないものは完全に負け組だぞ

ゆっくり霊夢はFランク大学の就職課に就職したようです【第16話】
ttp://https://www.youtube.com/watch?v=SmTtzGIIjN8
卵の名無しさん [sage] 2019/01/21(月) 19:06:50.31:5GFeLbpQ

これを一般式でするのは大変だろうな。

f(x) = 1/{σ√2π)} exp[-(x-m)^2/ 2σ^2],

下位30% ・・・・ 偏差値(m-0.5244σ)以下

f(x)

ma = ∫[-∞, m-0.5244σ] x・f(x) dx } / ∫[-∞, m-0.5244σ] f(x) dx{
 = m + ∫[-∞, m-0.5244σ] (x-m) f(x) dx / 0.3
 = m + (σ/√2π)∫[-∞, -0.5244] t・exp(-tt/2) dt / 0.3
 = m + (σ/√2π) [ -exp(-tt/2) ](t=-∞, -0.5244) / 0.3
 = m + (σ/√2π) [ -0.8715 / 0.3 ]
 = m - 1.159σ
 = m - 11.59
卵の名無しさん [sage] 2019/01/21(月) 19:07:33.35:5GFeLbpQ
累積密度関数の逆関数が必要になる:(
卵の名無しさん [] 2019/01/21(月) 23:54:21.71:zCz5KSqt
タバコって燃えるゴミかな?
有害物質を発生するからプラゴミと同じかな?
灰皿は不燃ゴミ
電子タバコは家電ゴミでいいのかな?
卵の名無しさん [sage] 2019/01/22(火) 00:16:37.39:7DkisZz5

吸ってる椰子がゴミ
卵の名無しさん [sage] 2019/01/22(火) 17:20:22.09:XyJ4p7WH
f <-function(a){
qa=qnorm(a,50,10,lower=F)
ma=integrate(function(x) x*dnorm(x,50,10)/a,qa,Inf)$value
va=integrate(function(x) (x-ma)^2*dnorm(x,50,10)/a,qa,Inf)$value
c(mean=ma,sd=sqrt(va))
}
m1=f(0.27)[1]
s1=f(0.27)[2]
m2=f(0.50)[1]
s2=f(0.50)[2]

g <- function(x){
y= (x-50)/s1*10+m1
50+(y-m2)/s2*10
}
x=40:70
g(x)
卵の名無しさん [sage] 2019/01/22(火) 17:40:34.59:XyJ4p7WH
f <-function(a){
qa=qnorm(a,50,10,lower=F)
ma=integrate(function(x) x*dnorm(x,50,10)/a,qa,Inf)$value
va=integrate(function(x) (x-ma)^2*dnorm(x,50,10)/a,qa,Inf)$value
c(mean=ma,sd=sqrt(va))
}
m1=f(0.27)[1]
s1=f(0.27)[2]
m2=f(0.50)[1]
s2=f(0.50)[2]

g <- function(x){
y= (x-50)/s1*10+m1
50+(y-m2)/s2*10
}

g(c(50,55,57.5))

母集団(例えば18歳人口)の成績が平均値50点標準偏差10点の正規分布に従うとする。

上位27%が進学すると
平均値62.2点標準偏差5.01点の集団Aとなる。
(成績が62.2点なら偏差値50に67.21点なら偏差値60になる)

上位50 %が進学すると
平均値58.0標準偏差6.03の集団Bとなる。

集団Aでの偏差値50, 55, 57.5は各々
集団Bでは偏差値57.0, 73.0, 81.9になる。
卵の名無しさん [sage] 2019/01/22(火) 18:22:22.34:XyJ4p7WH

バグ修正

f <-function(a){
qa=qnorm(a,50,10,lower=F)
ma=integrate(function(x) x*dnorm(x,50,10)/a,qa,Inf)$value
va=integrate(function(x) (x-ma)^2*dnorm(x,50,10)/a,qa,Inf)$value
c(mean=ma,sd=sqrt(va))
}
m1=f(0.27)[1]
s1=f(0.27)[2]
m2=f(0.50)[1]
s2=f(0.50)[2]

g <- function(x){
y= (x-50)/10 *s1+m1
50+(y-m2)/s2*10
}

g(c(50,55,57.5))

母集団(例えば18歳人口)の成績が平均値50点標準偏差10点の正規分布に従うとする。

上位27%が進学すると
平均値62.2点標準偏差5.01点の集団Aとなる。
(成績が62.2点なら偏差値50に67.21点なら偏差値60になる)

上位50 %が進学すると
平均値58.0標準偏差6.03の集団Bとなる。

集団Aでの偏差値50, 55, 57.5は各々
集団Bでは偏差値57.0, 61.2 63.3になる。
卵の名無しさん [sage] 2019/01/22(火) 18:32:41.55:XyJ4p7WH
f <-function(a){
qa=qnorm(a,50,10,lower=F)
ma=integrate(function(x) x*dnorm(x,50,10)/a,qa,Inf)$value
va=integrate(function(x) (x-ma)^2*dnorm(x,50,10)/a,qa,Inf)$value
c(mean=ma,sd=sqrt(va))
}
p1=0.27
p2=0.50
m1=f(p1)[1]
s1=f(p1)[2]
m2=f(p2)[1]
s2=f(p2)[2]

g <- function(x){
y= (x-50)/10 *s1+m1
50+(y-m2)/s2*10
}

g(c(50,55,57.5))
xx=seq(40,80,0.1)
plot(xx,g(xx))
卵の名無しさん [sage] 2019/01/22(火) 18:47:08.16:XyJ4p7WH
f <-function(a){
qa=qnorm(a,50,10,lower=F)
ma=integrate(function(x) x*dnorm(x,50,10)/a,qa,Inf)$value
va=integrate(function(x) (x-ma)^2*dnorm(x,50,10)/a,qa,Inf)$value
c(mean=ma,sd=sqrt(va))
}

sim <- function(x=50,p1=0.3,p2=0.5){
m1=f(p1)[1]
s1=f(p1)[2]
m2=f(p2)[1]
s2=f(p2)[2]
y= (x-50)/10 *s1+m1
50+(y-m2)/s2*10
}

sim()
卵の名無しさん [] 2019/01/22(火) 23:57:18.92:poZn4cZ2

仕事は何をしてるのかね?

いまどき正規職員でないものは完全に負け組だぞ
卵の名無しさん [sage] 2019/01/23(水) 00:04:12.53:p2qfG+zh

何のプログラムかわかる?
卵の名無しさん [sage] 2019/01/24(木) 01:16:27.12:sxN7Of5+
テロ工作機関
福山友愛病院

なんと朝木明代市議のような他殺だと日本人に騒がれるから
日本国警察が、
朝鮮殺戮殺人教団に乗っとられたことにより警察から与えられていたのは、


犯罪ライセンス!!!!!!


病院で医師から処方された薬は、何ら疑いを持つことなく飲む人も少なくないだろう。

医学や薬学の知識がある人や、持病で何年も投薬治療を行っている人などは、
また違った見方をしているかもしれないが、一般的に「医師からの処方薬」に対する信頼は篤い。
しかし、そんな「信頼」を揺るがすとんでもない事件が話題となっている。

■「在庫処理」で不要な治療薬を投与広島県の福山友愛病院は、昨年11〜12月の間に、
統合失調症などの患者6名に、本来必要のないパーキンソン病の治療薬を投与していたことが判明。

これは、病院を運営する医療法人会長の指示によるもので、病院側は「使用期限が迫った薬の在庫処理がきっかけのひとつ。」と説明しているとのこと。

会長は、同病院で精神科としても勤務しており、パーキンソン病の治療薬である
「レキップ」の錠剤を統合失調症患者など6人に投与するよう看護師らに指示。
投薬は複数回行われ、末丸会長は通常の


8倍の量を



指示していたという。
卵の名無しさん [] 2019/01/24(木) 07:39:17.09:YHL/Shf0
ところで、タバコって燃えるゴミですか?
有害物質を発生するのでプラゴミと同じ扱いでしょうか?
電子タバコは家電ゴミですよね

今度、小学校に教育実習に行くので
お家のタバコ用具を全てゴミに出すように指導してきます
卵の名無しさん [sage] 2019/01/24(木) 11:08:18.87:EfYrEwvB
ttp://https://www.niid.go.jp/niid/images/flu/resistance/20190121/dr18-19j20190121-1.pdf
H3N2で 2/21vs0/21で有意差あるか?
n<5だとΧ二乗検定はあてにならない。
卵の名無しさん [] 2019/01/24(木) 15:16:53.44:7fT+1bS6
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2019/01/24(木) 18:59:58.86:oaTB7QH8
テロ工作機関が日本にあることが判明


福山友愛病院


日本人への薬物大量投与テロも発覚


また他は、
単純に、朝鮮殺戮殺人革命の為に、
日本人被害者側を、
カルト医師が医師免許を犯罪に使用し、
偽造カルテをでっち上げているにすぎない

でっち上げる理由は、カルト会社の犯罪にごねている、
だから、
警察から犯罪ライセンス与えられているので、

虚偽説明して騙して閉鎖病棟に閉じ込め、
携帯とりあげ、
監禁罪やり精神保健福祉法違反をやり偽造カルテ書きますね

それだけw

だって、警察がグルで共同組織犯罪をしているから、
犯罪を犯罪でないことにしてくれるんだもの
日本人被害者側を拉致していることがバレたしな


それをやらかしていたので、
福山友愛病院には電凸し、
インターネット上に書いていることを通告もしている

ケースワーカーのイソムラという女性曰わく、

カミサカ先生インターネットに書かれて辛いみたいで〜・・・



日本国内にいるテロリストが辛くなることは、
日本人の喜びだっつーのww
卵の名無しさん [sage] 2019/01/24(木) 20:31:49.63:H5DL72sh
Rnorm<-function(n,m,s){
x=rnorm(n,m,s)
m + s*(x-mean(x))/sd(x)
}

N=1e3
x=replicate(5,Rnorm(N,50,10))
f <- function(){ # simulated test results of 3 or 5 subjects
y=numeric()
for(i in 1:5) y[i]=sample(x[,i],1)
y3=sum(y[1:3])
y5=sum(y[1:5])
c(y3,y5)
}

p2h <- function(x){ # points to hensa-chi
m=mean(x)
s=sd(x)
x=50+10*(x-m)/s
}

re=replicate(1e5,f())
y3=re[1,] # points of 3 subject test
y5=re[2,]

z3=p2h(y3) # hensa-ti of 3 subject test
z5=p2h(y5)
卵の名無しさん [sage] 2019/01/24(木) 20:32:02.08:H5DL72sh
hc <- function(h,d=0.5){ # hensa-chi conversion
idx=which(h-d<z5 & z5<h+d) # hensa-chi range in 5 subject test
mean(z3[idx]) # mean of its hensa-chi in 3 subject
}
hc=Vectorize(hc)
hh=40:80
plot(hh,hc(hh),bty='l',asp=1,xlab='5 subject',ylab='3 subject',
pch=19)
abline(a=0,b=1,col='gray')
卵の名無しさん [sage] 2019/01/24(木) 20:51:53.08:H5DL72sh
実行結果

ttp://i.imgur.com/hOhq2y8.png
卵の名無しさん [sage] 2019/01/27(日) 05:17:22.65:Ba4uprm1
札幌ひばりが丘病院
麻薬取締法違反で書類送検
ttp://https://video.fc2.com/content/20180607uZCBN0zX
卵の名無しさん [] 2019/01/28(月) 11:16:13.00:C5thEPa8
ゆっくり霊夢はFランク大学の就職課に就職したようです
ttp://https://www.youtube.com/playlist?list=PLCjQBaWqLbQ3PSHosCZE-stWkEtyUZ051
卵の名無しさん [] 2019/01/28(月) 17:29:00.31:AVoD+Cyq
働いたら負け
卵の名無しさん [] 2019/01/28(月) 21:53:43.21:+PCpJyrP
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2019/02/09(土) 22:33:46.30:F1R4fVG9
f=function(p,q=0.99){
a=13*q
c=13*(1-q)
b=13000*p
d=13000*(1-p)
(a/(a+b)-c/(c+d)) / (a/(a+b))
}
p=q=seq(0.01,0.99,0.1)
z=outer(p,q,f)
contour(p,q,z)

g=Vectorize(f)
g((1:19)/20)
卵の名無しさん [sage] 2019/02/10(日) 12:37:21.35:9eXx3CuI
options(digits=3)
f=function(p,q=0.99){ # p:pyroli in population, q:pyroli in cancer
a=13*q
c=13*(1-q)
b=13000*p
d=13000*(1-p)
x=(a/(a+b)-c/(c+d)) / (a/(a+b)) # attributable to pyroli(+)
y=(c/(c+d)-a/(a+b)) / (c/(c+d)) # qtteibutabel to pyroli(-)
round(ifelse(x>0,x,y),3)
}

g=Vectorize(f)
g((1:19)/20)

p=seq(0.01,0.99,0.01) # pylori in population
q=seq(0.01,0.99,0.01) # pylori in cancer
z=outer(p,q,f)
image(p,q,z,bty='l',nlevels=20,xlab='pyroli in population',
ylab='pyroli in cancer')
contour(p,q,z,bty='l',nlevels=20,xlab='pyroli in population',
ylab='pyroli in cancer',add=T)

contour(p,q,z,bty='l',nlevels=20,xlab='pyroli in population',
ylab='pyroli in cancer')

source('tools.R')
Persp(p,q,z)
Persp3d(p,q,z)
卵の名無しさん [sage] 2019/02/10(日) 12:37:47.54:9eXx3CuI
'
がん 非がん
感染  a  b
未感染 c  d

attributable risk : x
x={a/(a+b)-c/(c+d)} / {a/(a+b)}
'
卵の名無しさん [sage] 2019/02/10(日) 19:40:18.09:9eXx3CuI
q1=0.9934
q2=0.9958
f <- function(p,q){
a=13*q
c=13*(1-q)
b=13000*p
d=13000*(1-p)
(a/(a+b)-c/(c+d)) / (a/(a+b))
}
x0=0.985

f1=Vectorize(function(p)f(p,q=q1))
f2=Vectorize(function(p)f(p,q=q2))
curve(f1(x))
abline(h=0.985)
uniroot(function(x)f1(x)-x0,c(0,0.9))$root
curve(f2(x))
abline(h=0.985)
uniroot(function(x)f2(x)-x0,c(0,0.9))$root
卵の名無しさん [sage] 2019/02/11(月) 12:56:16.04:rzg7XY57
一般論として医療統計って全然科学じゃないって、研究者の中ではバカにされてますよ。
卵の名無しさん [sage] 2019/02/11(月) 14:44:26.58:Pny0jm5M
統計で使われる数学って難し過ぎてついていけないよね。
AICとかわからないままにソフトで出させているだけ。
卵の名無しさん [] 2019/02/13(水) 12:53:38.65:hLnbSCPn
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [sage] 2019/02/16(土) 13:25:47.75:QaizKjLi

裏口馬鹿にもわかるように原文もつけなきゃ。


原文はこれな。

私は昭和の時代に大学受験したけど、昔は今よりも差別感が凄く、慶応以外の私立医は特殊民のための特殊学校というイメージで開業医のバカ息子以外は誰も受験しようとすらしなかった。
常識的に考えて、数千万という法外な金を払って、しかも同業者からも患者からもバカだの裏口だのと散々罵られるのをわかって好き好んで私立医に行く同級生は一人もいませんでした。
本人には面と向かっては言わないけれど、俺くらいの年代の人間は、おそらくは8−9割は私立卒を今でも「何偉そうなこと抜かしてるんだ、この裏口バカが」と心の底で軽蔑し、嘲笑しているよ。当の本人には面と向かっては絶対にそんなことは言わないけどね。
卵の名無しさん [] 2019/02/17(日) 22:18:47.40:rglxpU9N
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

According to the experience of entrance exam to medical school in the era of Showa, when the sense of discrimination against
privately-founded medical schools were more intense than it is now,
all such schools but for Keio had been so compared to some specialized institution for educable mentally retarded kids that nobody but imbecile successors of physicians in private practice had applied for admission.

There had been NOT a single classmate who chose willingly against his/her common sense to go to the Do-Teihen(exclusively bottom-leveled medical school, currently also known as Gachi'Ura),
which would have cost outrageous money and its graduates are destined to be called Uraguchi morons who bought thier way into the Do-Teihen, by thier colleagues and even by thier own clients.

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.
卵の名無しさん [] 2019/02/19(火) 19:34:53.54:5dzWj+iV
俺は医者ではない。
卵の名無しさん [sage] 2019/02/19(火) 22:25:59.08:j+jAYShv
医学統計は苦手だ
できなきゃ論文読めんけど
卵の名無しさん [sage] 2019/02/20(水) 09:47:48.92:P0P24ylG

>456の問題点を指摘できないなら不正統計に騙される素養があるね。
卵の名無しさん [] 2019/02/27(水) 17:12:27.40:L7SdQ9d/
まあ落ち着いて
萌え動画でもどうぞ

ttp://https://m.youtube.com/watch?v=FmTtUVKjmEs
卵の名無しさん [sage] 2019/03/01(金) 20:33:40.05:CpB3LdCN
「もし君の妻子や友人にいつまでも生きていてもらいたいと思うならば、君は愚かである。というのは、君は、君の力の及びうる範囲内にないものまでも君の力の及びうる範囲内にあることを欲し、よそのものまでも君のものであることを欲しているからである。」
卵の名無しさん [sage] 2019/03/04(月) 13:04:58.69:PhmNbZK3


これでも見て落ちつけ

ttp://https://www.youtube.com/watch?v=mB3ZVIc4EF4
卵の名無しさん [] 2019/03/14(木) 16:45:10.23:JBQs0yPH
韓国で大麻が医療解禁した
国際条約では臨床試験や学術研究(輸出輸入など)が認められているんで一度訪ねてみては?

ttp://livedoor.blogimg.jp/denkyupikaso-rwceiylt/imgs/9/7/97a40f97.png
ttp://livedoor.blogimg.jp/denkyupikaso-rwceiylt/imgs/c/6/c6fc0285.png

韓国で使われてる大塚製薬の大麻製剤は日本の医師会員向けに和訳も開始されている。
ttp://https://news.nicovideo.jp/watch/nw4912539
卵の名無しさん [] 2019/03/18(月) 15:05:39.58:pTprsItO
まあ落ち着いて
萌え動画でもどうぞ

ttp://https://www.youtube.com/watch?v=y2b95D23sEA&t=134s
卵の名無しさん [sage] 2019/03/27(水) 22:03:49.30:Kh2JcAUc
統計楽しいね
卵の名無しさん [sage] 2019/03/28(木) 00:45:03.92:8PkLLiIS
ttp://https://www3.nhk.or.jp/news/html/20190327/k10011863181000.html

インフルエンザの新しい治療薬「ゾフルーザ」を投与されたA香港型のインフルエンザ患者30人を調べたところ、
70%余りに当たる22人から、この薬が効きにくい耐性ウイルスが検出されたことが国立感染症研究所の調査で分かりました。
調査件数は多くないものの、専門家は現在のような使用を続けると、耐性ウイルスが広がるおそれがあるとして使用基準を見直すべきだと指摘しています。

ttp://https://www3.nhk.or.jp/news/html/20190327/k10011863181000.html

問題:耐性発生率の95%信頼区間は? 👀
Rock54: Caution(BBR-MD5:1341adc37120578f18dba9451e6c8c3b)
卵の名無しさん [sage] 2019/03/28(木) 00:49:17.10:8PkLLiIS
95%CI 0.541 0.877なので過半数に耐性出現と言っていいな。
卵の名無しさん [sage] 2019/03/28(木) 01:30:14.34:uQgP69pk
耐性出現率が過半数である確率はいくらか?
卵の名無しさん [] 2019/06/25(火) 16:00:08.86:ZxTc5GC6

あんた医科歯科大卒だろ?
学部1〜2回生の時に線形代数と微分積分はやった?
卵の名無しさん [] 2019/06/25(火) 16:01:39.44:ZxTc5GC6
線形代数と微分積分を知らんと統計学の勉強は無理だね。
まあ、上を見れば切りがないけどね。
卵の名無しさん [sage] 2019/06/28(金) 10:53:20.90:30gP48kS

Rが使えれば統計扱えるよ。
今どき分布表で補間値計算なんてしないし。
非心t分布もRが出してくれる。


ttp://https://www3.nhk.or.jp/news/html/20190327/k10011863181000.html

インフルエンザの新しい治療薬「ゾフルーザ」を投与されたA香港型のインフルエンザ患者30人を調べたところ、70%余りに当たる22人から、この薬が効きにくい耐性ウイルスが検出されたことが国立感染症研究所の調査で分かりました。
調査件数は多くないものの、専門家は現在のような使用を続けると、耐性ウイルスが広がるおそれがあるとして使用基準を見直すべきだと指摘しています。

耐性化率が50%以上である確率は
pbeta(0.5,1+22,1+8,lower=F)
[1] 0.9946631
卵の名無しさん [sage] 2019/06/28(金) 12:35:11.06:30gP48kS
こんな質問があったからRを使って答えておいた。
他の人も同じ数値出していたな。

655 名無しさん@1周年 sage 2019/06/28(金) 12:05:50.17 ID:vuCIc6fU0
偏差値72.5ってIQにするとどれくらいなの?

ttps://asahi.2ch.net/test/read.cgi/newsplus/1561682615/655
卵の名無しさん [sage] 2019/06/28(金) 20:16:59.55:30gP48kS
統計学のための数学

あんまり公式を使うことないなぁ。
定積分も数値積分でやっちゃうから

ttp://http://www.data-arts.jp/math_for_statistics/calculus/integration.html
卵の名無しさん [sage] 2019/10/02(水) 15:20:15.02:nv8GYZZt
kk=(88+96)/2/100 #TP: kessei kando
kt=(89+100)/2/100 #TN: kessei tokuido
pLHk=kk/(1-kt) #TP/FP
nLHk=(1-kk)/kt #(1-TP)/(1-FP)=FN/TN

bk=(90+98)/2/100 #ben kando
bt=(87+100)/2/100 #ben tokuido
pLHb=bk/(1-bt)
nLHb=(1-bk)/bt

prep=0.5 # pre-possibility
preo=prep/(1-prep) # pre-odds
posto=preo*nLHk*pLHb # kessei(-)&ben(+)
(postp=posto/(1+posto))

#
posto=preo*nLHk*nLHb # kessei(-)&ben(-)
(postp=posto/(1+posto))
卵の名無しさん [sage] 2019/10/02(水) 17:26:13.36:nv8GYZZt
#
# 尿素呼気試験(B) 90〜100 80〜99
# 血清抗体(S) 88〜96 89〜100
# 尿中抗体(U) 89〜97 77〜95
# 便中抗原(F) 90〜98 87〜100

U=c(90/2+100/2,80/2+99/2)/100
S=c(88/2+96/2,89/2+100/2)/100
U=c(89/2+97/2,77/2+95/2)/100
F=c(90/2+98/2,87/2+100/2)/100

DOR <- function(T){
TP=T[1] ; FN=1-TP
TN=T[2] ; FP=1-TN
pLR=TP/FP
nLR=FN/TN
pLR/nLR
}
DOR(U)
DOR(S)
DOR(U)
DOR(F)
卵の名無しさん [sage] 2019/10/02(水) 17:34:50.26:nv8GYZZt
B=c(90/2+100/2,80/2+99/2)/100
S=c(88/2+96/2,89/2+100/2)/100
U=c(89/2+97/2,77/2+95/2)/100
F=c(90/2+98/2,87/2+100/2)/100

DOR <- function(T){
TP=T[1] ; FN=1-TP
TN=T[2] ; FP=1-TN
pLR=TP/FP
nLR=FN/TN
pLR/nLR
}

> DOR(B)
[1] 161.9524
> DOR(S)
[1] 197.5909
> DOR(U)
[1] 81.61224
> DOR(F)
[1] 225.359
>
卵の名無しさん [sage] 2019/11/25(月) 07:37:28.66:ZvHlCyJI
# ゴルゴ13は100発100中
# ゴルゴ14は10発10中
# ゴルゴ15は1発1中
# とする。
# 各々10000発撃ったとき各ゴルゴの命中数の期待値はいくらか?

G13 <- function(N,n,r){
pp=0:N
f <- function(x) choose(x,r)*choose(N-x,n-r)/choose(N,n)
sum(pp*f(pp)/sum(f(pp)))
}

G13(10000,100,100)
G13(10000,10,10)
G13(10000,1,1)

#.n発r中の狙撃手が.N発狙撃するときの命中数を返す
Go13 <- function(.N, .n, r, k=10^3){ # k:シミュレーション回数
f <-function(S,N=.N,n=.n){
y=c(rep(1,S),rep(0,N-S))
sum(sample(y,n))
}
xx=r:.N
SS=NULL
for(i in 1:k){
x=sapply(xx,f)
SS=c(SS,which(x==r)-1+r)
}
print(summary(SS))
invisible(SS)
}
卵の名無しさん [sage] 2019/11/27(水) 20:32:52.68:s7+UeQPF
a=c(1,10,100)
curve(dbeta(x,1+a[1],1),bty='l')
curve(dbeta(x,1+a[2],1),bty='l')
curve(dbeta(x,1+a[3],1),bty='l')
1000*qbeta(0.95,a+1,1,lower=F)
卵の名無しさん [sage] 2019/11/27(水) 20:34:40.15:s7+UeQPF
> a=c(1,10,100)
> curve(dbeta(x,1+a[1],1),bty='l')
> curve(dbeta(x,1+a[2],1),bty='l')
> curve(dbeta(x,1+a[3],1),bty='l')
> 10000*qbeta(0.95,a+1,1,lower=F)
[1] 2236.068 7615.958 9707.748
>
卵の名無しさん [sage] 2019/11/30(土) 09:56:41.57:bijshzSl
# 安倍総理招待枠(60-****)が招待状から
# 254x 2409 357xだという。
# ttp://https://youtu.be/6-pYMPg5yR0?t=3981
# 通し番号がふられているとして
# 357xを3570と低めに見積もる。
#>いや、それどころか、今年はそれ以上の数字も確認されている。
#選挙で安倍首相が遊説をおこなうとかなりの頻度で目撃されている熱烈な支持者であるM氏という人物がいるのだが、
#氏が菅官房長官や杉田水脈議員とのツーショット写真などとともにSNSにアップしていた
# 今年の「桜を見る会」の受付票には「60-4908」とナンバリングされているのだ。
#ttps://fate.5ch.net/test/read.cgi/seijinewsplus/1574717426/
# 他に今年は254? 2409 357? という番号が国会で発言されている。
#参加者の18200の半数9100が官邸枠の可能性があると仮定して官邸枠招待者数の期待値と95%CIを算出せよ。

Nmin=4908
Nmax=9100
n=Nmin:Nmax
m=4
pmf=choose(Nmax-1,m-1)/choose(n,m) #Pr(max=60|n)
plot(n,pmf,ylab='probability')
pdf=pmf/sum (pmf)
plot(n,pdf,ylab='density',bty='l')
sum(n*pdf) #E(n)

plot(n,cumsum(pdf))
abline(h=0.95,lty=3)
idx=min(which(cumsum(pdf)>0.95))
n[idx]
卵の名無しさん [sage] 2019/11/30(土) 10:28:03.80:bijshzSl
> Nmin=4908
> Nmax=9100
> n=Nmin:Nmax
> m=4
> pmf=choose(Nmax-1,m-1)/choose(n,m) #Pr(max=60|n)
> plot(n,pmf,ylab='probability')
> pdf=pmf/sum (pmf)
> plot(n,pdf,ylab='density',bty='l')
> sum(n*pdf) #E(n)
[1] 6191.377
> plot(n,cumsum(pdf))
> abline(h=0.95,lty=3)
> idx=min(which(cumsum(pdf)>0.95))
> n[idx]
[1] 8406
>
卵の名無しさん [sage] 2019/12/09(月) 08:25:56.61:zd3bijjh
# サイコロ

# 正6面体のサイコロがある.4面は青色、2面は赤色である.
# このサイコロを合計20回振るとき、最も起こりそうな順番はどれか?
# 1.赤 青 赤 赤 赤
# 2.青 赤 青 赤 赤 赤
# 3.青 赤 赤 赤 赤 赤

sim <- function(){
a=sample(0:1,20, replace=TRUE, prob=c(4,2))
b=as.character(a)
c=paste(b,collapse="")
s1=paste(c(1,0,1,1,1),collapse="")
s2=paste(c(0,1,0,1,1,1),collapse="")
s3=paste(c(0,1,1,1,1,1),collapse="")
res=c(grepl(s1,c),grepl(s2,c), grepl(s3,c))
return(res)
}
k=1e5
re=replicate(k,sim())
mean(re[1,])
mean(re[2,])
mean(re[3,])
卵の名無しさん [sage] 2019/12/10(火) 08:45:53.53:k/8kaoYw
seqNp <- function(N=100,K=5,p=0.5){
if(p==0) return(0)
if(N==K) return(p^K)
q=1-p
a=numeric(N) # a(n)=P0(n)/p^n , P0(n)=a(n)*p^n
for(i in 1:K) a[i]=q/p^i # P0(i)=q
for(i in K:(N-1)){ # recursive formula
a[i+1]=0
for(j in 0:(K-1)){
a[i+1]=(a[i+1]+a[i-j])
}
a[i+1]=q/p*a[i+1]
}
P0=numeric(N)
for(i in 1:N) P0[i]=a[i]*p^i # P0(n)=a(n)*p^n
MP=matrix(rep(NA,N*K),ncol=K)
colnames(MP)=paste0('P',0:(K-1))
MP[,'P0']=P0
MP[1,'P1']=p
for(i in (K-2):K) MP[1,i]=0
for(k in 2:K){
for(i in 1:(N-1)) MP[i+1,k]=p*MP[i,k-1]
} # Pk(n+1)=p*P(k-1)(n)
ret=1-apply(MP,1,sum)
ret[N]
}
卵の名無しさん [sage] 2019/12/10(火) 08:46:19.44:k/8kaoYw
seqNpJ <- function(N,K,p) seqNp(N,K,p)-seqNp(N,K+1,p)
seqNpJ(100,5,0.5)

seq2pCI <- function(N,K,alpha=0.05,Print=T){
vp=Vectorize(function(p)seqNp(N,K,p)-seqNp(N,K+1,p))
if(Print){curve(vp(x),lwd=2,bty='l',xlab='Pr[head]',ylab=paste('Pr[max',K,'-head repetition]'))
abline(h=alpha,lty=3)}
peak=optimize(vp,c(0,1),maximum=TRUE)$maximum
mean=integrate(function(x)x*vp(x),0,1)$value/integrate(function(x)vp(x),0,1)$value
lwr=uniroot(function(x,u0=alpha) vp(x)-u0,c(0.01,peak))$root
upr=uniroot(function(x,u0=alpha) vp(x)-u0,c(peak,0.99))$root
c(lower=lwr,mean=mean,mode=peak,upper=upr)
}
seq2pCI(100,5,0.05,T)


vs=Vectorize(function(K)seq2pCI(N=100,K,alpha=0.05,Print=F))
x=2:23
y=vs(x)
head(y)
y=y*100
plot(x,y['mean',],bty='l',pch=19,ylim=c(0,100),
xlab="最大連続数",ylab="推定裏口入学者数")
points(2:23,y['mode',],bty='l')
segments(x,y['lower',],x,y['upper',])
legend('right',bty='n',pch=c(19,1),legend=c("期待値","最頻値"))
卵の名無しさん [sage] 2019/12/10(火) 08:46:54.30:k/8kaoYw
# pdfからcdfの逆関数を作ってhdiを表示させて逆関数を返す
# 0,1での演算を回避 ∫[1/nxxx,1-1/nxx]dxで計算
pdf2HDI <- function(pdf,xMIN=0,xMAX=1,cred=0.95,nxx=1001){
xx=seq(xMIN,xMAX,length=nxx)
xx=xx[-nxx]
xx=xx[-1]
xmin=xx[1]
xmax=xx[nxx-2]
AUC=integrate(pdf,xmin,xmax)$value
PDF=function(x)pdf(x)/AUC
cdf <- function(x) integrate(PDF,xmin,x)$value
ICDF <- function(x) uniroot(function(y) cdf(y)-x,c(xmin,xmax))$root
hdi=HDInterval::hdi(ICDF,credMass=cred)
c(hdi[1],hdi[2])
}

# N試行で最大K回連続成功→成功確率pの期待値、最頻値と95%HDI
# max K out of N-trial to probability & CI
mKoN2pCI <- function(N=100 , K=4 , conf.level=0.95){
pmf=Vectorize(function(p)seqNp(N,K,p)-seqNp(N,K+1,p))
mode=optimize(pmf,c(0,1),maximum=TRUE)$maximum
auc=integrate(pmf,0,1)$value
pdf=function(x) pmf(x)/auc
mean=integrate(function(x)x*pdf(x),0,1)$value
curve(pdf(x),lwd=3,bty='l',xlab='Pr[head]',ylab='density')
lu=pdf2HDI(pdf,cred=conf.level)
curve(pdf(x),lu[1],lu[2],type='h',col='lightblue',add=T)
c(lu[1],mean=mean,mode=mode,lu[2])
}
mKoN2pCI(100,4) # one minute plz
mKoN2pCI(100,5)
卵の名無しさん [sage] 2019/12/10(火) 08:47:01.63:k/8kaoYw
# N試行で最大K回連続成功→成功確率pの期待値、最頻値と95% Quantile
# max K out of N-trial to probability & CI_quantile
mKoN2pCIq <- function(N=100 , K=4 , alpha=0.05){
pmf=Vectorize(function(p)seqNp(N,K,p)-seqNp(N,K+1,p))
mode=optimize(pmf,c(0,1),maximum=TRUE)$maximum
auc=integrate(pmf,0,1)$value
pdf=function(x) pmf(x)/auc
curve(pdf(x),bty='l')
mean=integrate(function(x)x*pdf(x),0,1)$value
cdf=function(x) MASS::area(pdf,0,x)
vcdf=Vectorize(cdf)
lwr=uniroot(function(x)vcdf(x)-alpha/2,c(0,mode))$root
upr=uniroot(function(x)vcdf(x)-(1-alpha/2),c(mode,1))$root
c(lower=lwr,mean=mean,mode=mode,upper=upr)
}
mKoN2pCIq(100,4)
mKoN2pCIq(100,5)
卵の名無しさん [sage] 2019/12/10(火) 08:48:13.55:2lYn70em
## simulation
mKoN2pCIga<-function(N=100,K=4,Print=T){
pmf=Vectorize(function(p)seqNp(N,K,p)-seqNp(N,K+1,p))
auc=integrate(pmf,0,1)$value
pdf=function(x) pmf(x)/auc
(mode=optimize(pmf,c(0,1),maximum=TRUE)$maximum)
(mean=integrate(function(x)x*pdf(x),0,1)$value)
(var=integrate(function(x)(x-mean)^2*pdf(x),0,1)$value)
(sd=sqrt(var))
#正規分布で近似してみる
if(Print){
curve(pdf,bty='l',col='red')
curve(dnorm(x,mean,sd),add=T,col='blue')}
c(lower=qnorm(0.025,mean,sd),mode=mode,mean=mean,upper=qnorm(0.975,mean,sd))
}
mKoN2pCIga(100,5)
vmK=Vectorize(function(K) mKoN2pCIga(100,K))
(y=cbind(0,vmK(2:30)))
plot(1:30,y['mean',],pch=19)
points(1:30,y['mode',])
卵の名無しさん [sage] 2019/12/17(火) 22:26:20.29:MXFfIsV3
# 10円硬貨を投げて5回連続で表が出ると
# 稀な現象(0.5の5乗は 0.03125)なので表の出る確率は0.5ではない、というのが頻度主義統計の結論。
# この硬貨はどの程度歪(いびつ)なのかを推論するのがベイズ推論の面白さである。
# この硬貨で表がでる確率の95%信頼区間を計算してみよう。
#
# 表のでる確率分布をβ分布β(a,b)でa=bとすれば、0.5を頂点とする対象な事前確率分布となる。
# 事後分布はβ(a+5,a+0)となるのだが、問題はパラメータaをいくらに設定するかである。
# aを変数として95%信頼区間下限値をグラフにすると最小値があることがわかる。
# ttp://i.imgur.com/MA4ztAU.jpg
# 最尤法で算出させるとa=11.25のとき0.406となる。
# あとは95%区間を計算して、この硬貨が表が出る確率の95%信頼区間は0.406 0.763となる。
# ttp://i.imgur.com/8swQPMH.jpg
HDInterval::hdi(qbeta,shape1=1+5,shape2=1)
卵の名無しさん [sage] 2019/12/18(水) 12:46:29.75:HkAD959b
n=5
l <- function(a) HDInterval::hdi(qbeta,shape1=a+n,shape2=a)['lower']
vl=Vectorize(l)
curve(vl(x),0.5,1000,bty='l',lwd=2)
(lo=optimise(vl,(c(0.5,1000))))
HDInterval::hdi(qbeta,shape1=lo$min + n,shape2=lo$min)
卵の名無しさん [sage] 2019/12/18(水) 13:45:30.88:HkAD959b
コインをなげたら5回続けて表が出た。
表が出る確率は、平均値が0.5のベータ分布(一様分布もベータ分布の一つ)に従うように鋳造されているとする。
このコインの表の出る確率を95%信頼区間で推定するとき
区域下限値の最小値はいくらか?
つまり、95%以上の信頼性で表の出る確率はいくつ以上と言えるか?
卵の名無しさん [] 2019/12/18(水) 16:26:08.99:j32hgbYi
rm(list=ls())

n=5
l <- function(a) HDInterval::hdi(qbeta,shape1=a+n,shape2=a)['lower']
vl=Vectorize(l)
curve(vl(x),0.5,100,bty='l',lwd=2)
(lo=optimise(vl,(c(0.5,1000))))
HDInterval::hdi(qbeta,shape1=lo$min + n,shape2=lo$min)

#
binom::binom.confint(5,5)
f <- function(x) binom::binom.bayes(5,5,prior.shape1=x,prior.shape2=x)$lower
curve(f(x),0.5,50,bty='l',lwd=2)
optimize(f,c(0.5,50))
卵の名無しさん [sage] 2019/12/18(水) 19:35:43.82:HkAD959b

95%CIをグラフ化
ttps://i.imgur.com/U6eVEYN.jpg
卵の名無しさん [sage] 2019/12/18(水) 19:59:58.70:HkAD959b
一般化 

#
"コインをなげたらn回続けて表が出た。
表が出る確率は、平均値が0.5のベータ分布(一様分布もベータ分布の一つ)に従うように鋳造されているとする。
このコインの表の出る確率を95%信頼区間で推定するとき区域下限値の最小値はいくらか?
つまり、95%以上の信頼性で表の出る確率はいくつを下回らないと言えるか?"
seq2lowest <- function(n){
l <- function(a) HDInterval::hdi(qbeta,shape1=a+n,shape2=a)['lower']
vl=Vectorize(l)
opt=optimise(vl,(c(0.5,1000)))
hdi=HDInterval::hdi(qbeta,shape1=lo$min + n,shape2=lo$min)
c('shape'=opt$minimum,opt$objective,hdi['upper'])
}
seq2lowest(5)
graphics.off()
nn=2:50
plot(nn,sapply(nn,seq2lowest)['lower',],pch=19,bty='l')
卵の名無しさん [sage] 2019/12/18(水) 22:08:27.48:RWipilhS
よくわからないけど面白そう
卵の名無しさん [sage] 2019/12/19(木) 07:45:22.67:mtJFYvZ2
rm(list=ls())

gambling <- function(A=2,B=1,w=3,p=0.5,k=1e5){ # k : how many simulate
sim <- function(){
while(A < w & B < w){
g = rbinom(1,1,p)
if(g==1){
A=A+1
}else{
B=B+1
}
}
A > B
}
mean(replicate(k,sim())) # Pr[A wins]
}
gambling(1,0,4) # 日本シリーズ
卵の名無しさん [sage] 2019/12/19(木) 07:45:58.37:mtJFYvZ2
# 日本シリーズ

f <- function(num, N=2, digit = 7){ # winner sequence of 7 games
r=num%%N
q=num%/%N
while(q > 0 | digit > 1){
r=append(q%%N,r)
q=q%/%N
digit=digit-1
}
return(r)
}
vf=Vectorize(f)
dat=t(vf(0:(2^7-1))) # matrirx of winner sequence of 7 games
(dat1=dat[dat[,1]==1,-1]) # winner sequence of 6 games

g <- function(s,A=1,B=0,w=4){ # A beats B T/F?
i=0
while(A < w & B < w){
i=i+1
r = s[i]
if(r==1){
A=A+1
}else{
B=B+1
}
}
A > B
}
sum(apply(dat1,1,g))/nrow(dat1)
卵の名無しさん [sage] 2019/12/19(木) 08:17:50.32:mtJFYvZ2
# 通算勝率に従って次の試合に勝つ確率が決まるという設定
# 先勝したAの日本シリーズ前の対戦成績がa勝b負とする
rm(list=ls())
N_series <- function(A=1,B=0,w=4,a=10,b=10,k=1e5){
sim <- function(){
p=(A+a)/(A+B+a+b)
while(A < w & B < w){
g = rbinom(1,1,p)
if(g==1){
A=A+1
p=(A+a+1)/(A+B+a+b+1)
}else{
B=B+1
p=(A+a)/(A+B+a+b+1)
}
}
A > B
}
mean(replicate(k,sim())) # Pr[A wins]
}
N_series()
卵の名無しさん [sage] 2019/12/19(木) 09:38:09.07:+FZyQ+1V
互角と言っても1勝1敗と1000勝1000敗だ結果が変わるな
> rm(list=ls())
> N_series <- function(A=1,B=0,w=4,a=10,b=10,k=1e5){
+ sim <- function(){
+ p=(A+a)/(A+B+a+b)
+ while(A < w & B < w){
+ g = rbinom(1,1,p)
+ if(g==1){
+ A=A+1
+ p=(A+a+1)/(A+B+a+b+1)
+ }else{
+ B=B+1
+ p=(A+a)/(A+B+a+b+1)
+ }
+ }
+ A > B
+ }
+ mean(replicate(k,sim())) # Pr[A wins]
+ }
>
> N_series(a=1,b=1)
[1] 0.76425
> N_series(a=10,b=10)
[1] 0.67035
> N_series(a=100,b=100)
[1] 0.65629
> N_series(a=1000,b=1000)
[1] 0.65802
卵の名無しさん [sage] 2019/12/19(木) 10:00:45.03:+FZyQ+1V
> N_series(a=1,b=1)
[1] 0.76266
> N_series(a=10,b=10)
[1] 0.6716
> N_series(a=100,b=100)
[1] 0.65707
> N_series(a=1000,b=1000)
[1] 0.65695
>
卵の名無しさん [sage] 2019/12/19(木) 16:11:38.16:mtJFYvZ2
NS <- function(w,A,B,p){ # 先にw点得点した方が勝者、A,B:現在の点数 ,p:甲の勝率
ans=0
for(k in 0:(w-B-1)){ # k: Aが勝者になるまでのBの点数
ans=ans+choose(w-A-1+k,w-A-1)*(1-p)^k*p^(w-A)
}
return(ans)
}

NS(3,2,1,0.5)
卵の名無しさん [sage] 2019/12/21(土) 11:16:13.81:JyjCwOQx
日本シリーズで賭けをする。

日本シリーズは先に4勝したチームが優勝。
勝率はそれまでの引き分けを除いた通算勝率に従うとする。
開始前の通算成績はA:2勝、B:4勝であった。
今、シリーズでAが先勝(第一試合に勝利)した。
この時点でA,Bのどちらに賭ける方が有利か?
卵の名無しさん [sage] 2019/12/21(土) 21:55:53.22:NW9TiMNu
# 小数点付きの数numをN進法で表示する

rm(list=ls())
dec2basen <- function(num, N, kmin = 5){ # kmin:最小小数点後桁
int=floor(num)
r=int%%N
q=int%/%N
while(q > 0){
r=append(q%%N,r)
q=q%/%N
} # rに整数のN進法表示を格納

x=num-floor(num)
k=max(nchar(x)-2,kmin) # 同長もしくはkminの長さの小数表示
a=numeric(k)
for(i in 1:k){
y=x*N
a[i]=floor(y)
x=y-a[i] # r . a[1] a[2] a[3] ... a[k]
}
if(N<=10){ # Nが10以下は数値として表示
cat(r,paste(".",paste(a,collapse = ''),sep=''),'\n',sep='')
}
else{ # Nが11以上は整数部分と小数部分を数列で表示
print(list(int=r,decimal=a))
}
invisible()

}
卵の名無しさん [sage] 2019/12/21(土) 23:15:54.59:NW9TiMNu
戻り値がある方がいいな。

# 小数点付きの数numをN進法で表示する

rm(list=ls())
dec2basen <- function(num, N, kmin = 5){ # kmin:最小小数点後桁
int=floor(num)
r=int%%N
q=int%/%N
while(q > 0){
r=append(q%%N,r)
q=q%/%N
} # rに整数のN進法表示を格納

x=num-floor(num)
k=max(nchar(x)-2,kmin) # 同長もしくはkminの長さの小数表示
a=numeric(k)
for(i in 1:k){
y=x*N
a[i]=floor(y)
x=y-a[i] # r . a[1] a[2] a[3] ... a[k]
}
b=list(int=r,decimal=a)
if(N<=10){ # Nが10以下は数値として表示
cat(r,paste(".",paste(a,collapse = ''),sep=''),'\n',sep='')
}
else{ # Nが11以上は整数部分と小数部分を数列で表示
print(b)
}
invisible(b)
}
卵の名無しさん [sage] 2019/12/21(土) 23:26:15.77:NW9TiMNu
> dec2basen(5/9,3)
0.120000000000000
>
> dec2basen(3.14159265359,7)
3.06636514320
> dec2basen(3.14159265359,8)
3.11037552421
> dec2basen(3.14159265359,9)
3.12418812407
> dec2basen(3.14159265359,14)
$int
[1] 3

$decimal
[1] 1 13 10 7 5 12 13 10 8 1 4

>
> re=dec2basen(sqrt(3),16) # √3の16進法表示
$int
[1] 1

$decimal
[1] 11 11 6 7 10 14 8 5 8 4 12 10 10 0 0

> b=re$decimal
> cat(re$int,'.',paste0(c('0':'9','A','B','C','D','E','F')[b+1],sep='',collapse=''),sep='')
1.BB67AE8584CAA00
卵の名無しさん [sage] 2019/12/22(日) 13:49:45.74:D+p3chog
# 小数点付きの数numをN進法で表示する
floor((1.2-1)*5) != floor(1)
rm(list=ls())
decN <- function(num, N, kmin = 5){ # kmin:最小小数点後桁
int=floor(num)
r=int%%N
q=int%/%N
while(q > 0){
r=append(q%%N,r)
q=q%/%N
} # rに整数のN進法表示を格納

x=num-floor(num)
k=max(nchar(x)-2,kmin) # 同長もしくはkminの長さの小数表示
a=numeric(k)
for(i in 1:k){
y=x*N
a[i]=floor(y+2e-13) # n=1:9 ;trunc((1+1/n-1)*n) ;trunc((1+1/n-1)*n+5e-14)対応
x=y-a[i] # r . a[1] a[2] a[3] ... a[k]
}
b=list(integer=r,decimal=a,num=sum(c(int,a)*(1/N)^(0:k)))
fig=c(0:9,letters)[1:N]
if(N<=36){ # Nが36以下は数値として表示
cat(b$integer,'.',paste(fig[b$decimal+1],sep='',collapse=''),sep='')
cat('\n')
}
else{ # Nが11以上は整数部分と小数部分を数列で表示
print(b[1:2])
}
invisible(b)
}
卵の名無しさん [sage] 2019/12/22(日) 13:50:03.28:D+p3chog
> decN(5/9,3)
0.120000000000000
> decN(0.728,5,10)
0.331004444
> decN(3.14159265359,7)
3.06636514320
> decN(3.14159265359,14)
3.1da75cda814
卵の名無しさん [sage] 2019/12/22(日) 14:24:46.39:D+p3chog
# 小数点付きの数numをN進法で表示する
rm(list=ls())
decN <- function(num, N, kmin = 5){ # kmin:最小小数点後桁
int=floor(num)
r=int%%N
q=int%/%N
while(q > 0){
r=append(q%%N,r)
q=q%/%N
} # rに整数のN進法表示を格納

x=num-floor(num)
k=max(nchar(x)-2,kmin) # 同長もしくはkminの長さの小数表示
a=numeric(k)
for(i in 1:k){
y=x*N
a[i]=trunc(y+2e-13) # n=1:9 ;trunc((1+1/n-1)*n) ;trunc((1+1/n-1)*n+5e-14)対応
x=y-a[i] # r . a[1] a[2] a[3] ... a[k]
}
b=list(integer=r,decimal=a,num=sum(c(int,a)*(1/N)^(0:k)))
fig=c(0:9,letters)[1:N]
if(N<=36){ # Nが36以下は数値として表示
cat(b$integer,'.',paste(fig[b$decimal+1],sep='',collapse=''),sep='')
cat('\n')
}
else{ # Nが37以上は整数部分と小数部分を数列で表示
print(b[1:2])
}
invisible(b) # b$num:検証用
}
卵の名無しさん [sage] 2019/12/22(日) 16:52:54.78:D+p3chog
# 小数点付きの数numをN進法で表示する
rm(list=ls())
decN <- function(num, N, kmin = 5){ # kmin:最小小数点後桁
int=floor(num)
r=int%%N
q=int%/%N
while(q > 0){
r=append(q%%N,r)
q=q%/%N
} # rに整数のN進法表示数列を格納
k=max(nchar(num)-nchar(floor(num))-1,kmin) # 同長もしくはkminの長さの小数表示
a=numeric(k)
x=round(num-floor(num),k) # e.g. 7.28-floor(7.28)-0.28 != 0に対応
for(i in 1:k){
y=round(x*N,k) # e.g. 0.728*5-3.64 !=0 に対応
a[i]=floor(y)
x=y-a[i] # r . a[1] a[2] a[3] ... a[k]
}
b=list(integer=r,decimal=a,num=sum(c(int,a)*(1/N)^(0:k)))
fig=c(0:9,letters)[1:N]
if(N<=36){ # Nが36以下は数値として表示
cat(paste(fig[b$integer+1],sep='',collapse=''),
'.',paste(fig[b$decimal+1],sep='',collapse=''),sep='')
cat('\n')
}
else{ # Nが37以上は整数部分と小数部分を数列で表示
print(b[1:2])
}
invisible(b) # b$num:検証用
}
卵の名無しさん [sage] 2019/12/22(日) 23:14:45.02:D+p3chog
rm(list=ls())
NS <- function(w,A,B,p){ # 先にw点得点した方が勝者、A,B:現在の点数 ,p:甲の勝率
ans=0
for(k in 0:(w-B-1)){ # k: Aが勝者になるまでのBの点数
ans=ans+choose(w-A-1+k,w-A-1)*(1-p)^k*p^(w-A)
}
return(ans)
}
NS(3,2,1,0.5)
NS(4,1,0,0.5)
curve(NS(4,1,0,x),bty='l',lwd=2)
abline(h=0.5,col='gray')

# 日本シリーズで先勝したときに優勝する確率がx以上であるために必要な勝率vf(x)は?
f <- function(u0) uniroot(function(p) NS(4,1,0,p)-u0,c(0,1))$root
f(0.5)
vf=Vectorize(f)
curve(vf(x),bty='l')
vf(seq(0,1,0.1))
卵の名無しさん [sage] 2019/12/23(月) 13:09:52.68:WZg+GXSV
デバッグした
# 通算勝率に従って次の試合に勝つ確率が決まるという設定
# 先勝したAの日本シリーズ前の対戦成績がa勝b負とする
rm(list=ls())
N_series <- function(A=1,B=0,w=4,a=2,b=4,k=1e5){
sim <- function(){
while(A < w & B < w){
p=(A+a)/(A+B+a+b)
g = rbinom(1,1,p)
if(g==1){
A=A+1
}else{
B=B+1
}
}
A > B
}
mean(replicate(k,sim())) # Pr[A wins]
}
N_series()
卵の名無しさん [sage] 2019/12/23(月) 15:14:31.94:+ZpAQitI
日本シリーズは先に4勝したチームが優勝。
勝率はそれまでの通算勝率に従うとする。引き分けはないものとする。
勝負がつくごとに次回の勝率が変化する。
(第二試合にAが勝つ確率は通算勝率の3/7
Aが勝ったら第三試合に勝つ確率は4/8
Aが負けたら第三試合に勝つ確率は3/8
になるという設定)
シリーズ開始前の通算成績はA:2勝、B:4勝であった。
今シリーズでAが先勝(第一試合に勝利)した。
この時点でどちらが優勝するか賭けをする。
A,Bのどちらに賭ける方が有利か?"
卵の名無しさん [sage] 2019/12/26(木) 13:19:39.94:Andgk16C
poisson.test(c(11, 6+8+7), c(800, 1083+1050+878))
prop.test(c(11, 6+8+7), c(800, 1083+1050+878))
卵の名無しさん [sage] 2019/12/26(木) 13:47:03.52:Andgk16C
poisson.test(c(11, 6+8+7), c(800, 1083+1050+878))
prop.test(c(11, 6+8+7), c(800, 1083+1050+878))
library(fmsb)
ratedifference(11, 6+8+7, 800, 1083+1050+878)
rateratio(11, 6+8+7, 800, 1083+1050+878)
source('tools.R')
jags4prop(11, 6+8+7, 800, 1083+1050+878)
卵の名無しさん [sage] 2019/12/27(金) 17:58:44.40:pKcbCDhI
ZooG <- function(L=1,M=1,N=1,A=30,B=60){
alpha=B/180*pi
beta=A/180*pi
a=M/N # length of 0P
b=L/N # length of PQ
P=a*(cos(alpha)+1i*sin(alpha))
Q=P+b*(cos(alpha+pi-beta)+1i*sin(alpha+pi-beta))
(pi-Arg(Q-1))/pi*180 # degree of Q-I-0
max(Arg(Q-P)/pi*180 - Arg(Q-1)/pi*180, Arg(Q-P)/pi*180 - Arg(Q-1)/pi*180+360) # degree of P-Q-I
abs(Q-1) # length of QI
xlim=ylim=max(a,b)*c(-1,2)
plot(0,xlim=xlim,ylim=ylim,bty='l',type='l',axes=FALSE, ann=FALSE,asp=1)
# draw segment of complex a to complex b
seg <- function(a,b,color=2,...) segments(Re(a),Im(a),Re(b),Im(b),col=color,...)
# draw text y at complex x
pt <- function(x,y=NULL,...) text(Re(x),Im(x), ifelse(is.null(y),'+',y), ...)
seg(0,1) ; seg(0,P) ; seg(P,Q)
pt(0,paste('O',B,'°')) ; pt(1,'I') ; pt(P,paste('P ',A,'°')) ; pt(Q,'Q')
pt((P+Q)/2, paste('L = ',L)) ; pt((P+0)/2, paste('M = ',M)) ; pt(1/2, paste('N = ',N))
seg(1,Q,col=1,lty=2)
angleI=(pi-Arg(Q-1))/pi*180 # degree of Q-1-0
if(angleI<0)angleI=angleI+360
if(angleI>360)angleI=angleI-360
if(angleI>180 & angleI<360) angleI=360-angleI
angleQ=Arg(Q-P)/pi*180 - Arg(Q-1)/pi*180 # degree of P-Q-1
if(angleQ<0)angleQ=angleQ+360
if(angleQ>360)angleQ=angleQ-360
if(angleQ>180 & angleQ<360) angleQ=360-angleQ
length=abs(Q-1)*N # length of Q1
c(angleQ=angleQ,angleI=angleI,QIlength=length)
}
卵の名無しさん [sage] 2019/12/27(金) 17:59:16.31:pKcbCDhI
# 長さL,M,NのZ尺を角度A°(LとMのなす角)、B°(MとNのなす角)で折り曲げたとき
# 先端と終端を結ぶ線とZ尺の作る角度および先端と終端の距離

ZooG(1,1,1,36,24)
ZooG(sample(10,1),sample(10,1),sample(10,1),sample(179,1),sample(179,1))
卵の名無しさん [sage] 2019/12/31(火) 20:45:37.19:caKR9jL7
# The ambulance arrives X hours ealier at hospital,
# when the patient leave clinic s hours earlier than planned
# and encounter the ambulance t hours later,
# ambulance runs with the velocity of v0 without patient, and v1 with patient
# clinic car runs with the velocity of w


Earlier <- # s hour earlier departure, X hour earlier arrival
function(s=NULL,X=NULL,t=NULL,v0=60,v1=45,w=30){
if(is.null(s)) re=c(s=X/(v0/(v0+w)*w*(1/v0+1/v1)),t=X/w/(1/v0+1/v1))
if(is.null(X)) re=c(X=s*v0/(v0+w)*w*(1/v0+1/v1),t=s*v0/(v0+w))
if(!is.null(t)) re=c(s=t + t*w/v0, X = t*w*(1/v0+1/v1))
return(re)
}
Earlier(X=10/60)*60
Earlier(s=30/60)*60
Earlier(t=30/60)*60
卵の名無しさん [sage] 2020/01/24(金) 09:01:51.18:p9O7hNNU
TE=cbind(rep(0:1,c(3,3)),rep(0:2,2))
colnames(TE)=c('JD','service')
TE
cond1 <- function(P,Q) !(P&!Q)
cond2 <- function(P,Q) cond1(P,Q) & cond1(!P,!Q)
f <- function(x){
all(c(
x[1]==1 & cond2(cond2(x[1]==1,x[2]!=1),x[2]>0) | x[1]==0 & !cond2(cond2(x[1]==1,x[2]!=1),x[2]>0)
))
}
TE[(apply(TE,1,f)),]
卵の名無しさん [sage] 2020/01/24(金) 10:26:25.09:p9O7hNNU
> TE[(apply(TE,1,f)),]
JD service
[1,] 0 2
[2,] 1 2
卵の名無しさん [sage] 2020/01/24(金) 10:40:22.42:9ccIONJj
TE=cbind(rep(0:1,c(3,3)),rep(0:2,2))
colnames(TE)=c('JD','service')
TE
cond1 <- function(P,Q) !(P&!Q)
cond2 <- function(P,Q) P==Q
f <- function(x){
all(c(
x[1]==1 & cond2(cond2(x[1]==1,x[2]!=1),x[2]>0) | x[1]==0 & !cond2(cond2(x[1]==1,x[2]!=1),x[2]>0)
))
}
TE[(apply(TE,1,f)),]
卵の名無しさん [sage] 2020/01/24(金) 10:42:15.05:9ccIONJj
> TE=cbind(rep(0:1,c(3,3)),rep(0:2,2))
> colnames(TE)=c('JD','service')
> TE
JD service
[1,] 0 0
[2,] 0 1
[3,] 0 2
[4,] 1 0
[5,] 1 1
[6,] 1 2
> cond1 <- function(P,Q) !(P&!Q)
> cond2 <- function(P,Q) P==Q
> f <- function(x){
+ all(c(
+ x[1]==1 & cond2(cond2(x[1]==1,x[2]!=1),x[2]>0) | x[1]==0 & !cond2(cond
<(x[1]==1,x[2]!=1),x[2]>0) | x[1]==0 & !cond2(cond2 (x[1]==1,x[2]!=1),x[2]>0)
+ ))
+ }
> TE[(apply(TE,1,f)),]
JD service
[1,] 0 2
[2,] 1 2
>
卵の名無しさん [sage] 2020/01/24(金) 15:17:02.19:p9O7hNNU
"某女子大には決して嘘をつかない女子大生と必ず嘘をつく女子大生がいることがわかっている。
この女子大の学生(嘘つきかどうかは不明)から
「あなたのいうことが正しければ手コキかフェラをしてあげる、間違っていれば何もしてあげない」と言われた。
女子大生にフェラをしてもらうには何と言えばいいか?
"
rm(list=ls())
TE=cbind(rep(0:1,c(4,4)),rep(0:3,2))
colnames(TE)=c('JD','service')
TE # JD 0:嘘つき 1:正直, service 0:何もしない 1:手コキ 2:フェラ 3:手コキ+フェラ
cond1 <- function(P,Q) !(P&!Q) # pならばQ
cond2 <- function(P,Q) cond1(P,Q) & cond1(!P,!Q) # (pならばQ) かつ(pでないならQでない)
f <- function(x){
x[1]==1 & cond2(cond2(x[1]==1,x[2]!=1),x[2]>0) | x[1]==0 & !cond2(cond2(x[1]==1,x[2]!=1),x[2]>0)
}
TE[(apply(TE,1,f)),]

cond3 <- function(P,Q) P==Q
f <- function(x){
x[1]==1 & cond3(cond3(x[1]==1,x[2]!=1),x[2]>0) | x[1]==0 & !cond3(cond3(x[1]==1,x[2]!=1),x[2]>0)
}
TE[(apply(TE,1,f)),]
卵の名無しさん [sage] 2020/01/25(土) 07:15:52.06:v8nYWWGU
TEnr <- function(n,r,one=1){ # n(=5),r(=3)を指定して 0 0 1 1 1から1 1 1 0 0までの順列行列を作る
f=function(x){
re=numeric(n) # 容れ子
re[x]=one # 指定のindexにoneを代入
re
}
t(combn(n,r,f)) # oneを入れる組み合わせに上記関数fを実行して転置
}
卵の名無しさん [sage] 2020/01/25(土) 07:43:20.46:v8nYWWGU
0 1 以外の場合もあるからこうした方がいいな

TEnr <- function(n,r,zero=0,one=1){ # n(=5),r(=3)を指定して 0 0 1 1 1から1 1 1 0 0までの順列行列を作る
f=function(x){
re=rep(zero,n) # 容れ子
re[x]=one # 指定のindexにoneを代入
re
}
t(combn(n,r,f)) # oneを入れる組み合わせに上記関数fを実行して転置
}
卵の名無しさん [sage] 2020/01/25(土) 13:21:20.50:v8nYWWGU
"
7段の階段を上るさい、1段上るか、2段上るかのいずれかを組合わせて上るこ
ととする。上り方は何通りあるか。
"
# Σxi=n xi<=r 一度にr(=3)段まで上がれる時、総数n(=7)段上がる場合の数
stairway <- function(n,r){
count=numeric(n)
m=ceiling(n/r)
for(i in m:n){
pi=gtools::permutations(r,i,rep=T)
pn=pi[apply(pi,1,sum)==n,]
count[i]=ifelse(is.vector(pn),1,nrow(pn))
}
sum(count)
}

stairway(7,2)
卵の名無しさん [sage] 2020/01/27(月) 15:33:10.59:54kq03+D
ここまで複雑だと推論での結論はかなり困難だと思う。

AからHの8人はそれぞれ正直者か嘘つきであり、誰が正直者か嘘つきかはお互いに知っている。
A,B,C,D,Eは嘘つきなら必ず嘘をつくが、F,G,Hは嘘つきでも正しいことを言う場合がある。
次の証言から誰を確実に正直者と断定できるか?

A「嘘つきの方が正直者より多い」
B「Hは嘘つきである」
C「Bは嘘つきである」
D「CもFも嘘つきである」
E「8人の中に、少なくとも1人嘘つきがいる」
F「8人の中に、少なくとも2人嘘つきがいる」
G「Eは嘘つきである」
H「AもFも正直者である」

プログラム解で解くのはたやすい。
TE=expand.grid(0:1,0:1,0:1,0:1,0:1,0:1,0:1,0:1)
colnames(TE)=LETTERS[1:8]
f <- function(x){
all(c(
x[1]==1 & sum(x==0)>sum(x==1) | x[1]!=1 & !(sum(x==0)>sum(x==1)),
x[2]==1 & x[8]==0 | x[2]!=1 & x[8]!=0,
x[3]==1 & x[2]==0 | x[3]!=1 & x[2]!=0 ,
x[4]==1 & (x[3]==0 & x[6]==0) |  x[4]!=1 & !(x[3]==0 & x[6]==0),
x[5]==1 & sum(x==0)>=1 | x[5]!=1 & !(sum(x==0)>=1),
x[6]==1 & sum(x==0)>=2 | x[6]==1 & !(sum(x==0)>=2),
x[7]==1 & x[5]==0 | x[7]!=1 & x[5]!=0,
x[8]==1 & (x[1]==1 & x[6]==1) | x[8]!=1 & !(x[1]==1 & x[6]==1)
))
}
TE[apply(TE,1,f),]
卵の名無しさん [sage] 2020/01/27(月) 15:49:58.32:54kq03+D
ここまで複雑だと推論での結論はかなり困難だと思う。

AからHの8人はそれぞれ正直者か嘘つきであり、誰が正直者か嘘つきかはお互いに知っている。
A,B,C,D,Eは嘘つきなら必ず嘘をつくが、F,G,Hは嘘つきでも正しいことを言う場合がある。
次の証言から誰を確実に正直者と断定できるか?

A「嘘つきの方が正直者より多い」
B「Hは嘘つきである」
C「Bは嘘つきである」
D「CもFも嘘つきである」
E「8人の中に、少なくとも1人嘘つきがいる」
F「8人の中に、少なくとも2人嘘つきがいる」
G「Eは嘘つきである」
H「AもFも正直者である」

プログラムで解くのはたやすいが正しいプログラムを書くには注意力が必要。  ,や)のミス一つで誤答がでる
TE=expand.grid(0:1,0:1,0:1,0:1,0:1,0:1,0:1,0:1)
colnames(TE)=LETTERS[1:8]
f <- function(x){
all(c(
x[1]==1 & sum(x==0)>sum(x==1) | x[1]!=1 & !(sum(x==0)>sum(x==1)),
x[2]==1 & x[8]==0 | x[2]!=1 & x[8]!=0,
x[3]==1 & x[2]==0 | x[3]!=1 & x[2]!=0 ,
x[4]==1 & (x[3]==0 & x[6]==0) |  x[4]!=1 & !(x[3]==0 & x[6]==0),
x[5]==1 & sum(x==0)>=1 | x[5]!=1 & !(sum(x==0)>=1),

x[6]==1 & sum(x==0)>=2 | x[6]==0,
x[7]==1 & x[5]==0 | x[7]==0,
x[8]==1 & (x[1]==1 & x[6]==1) | x[8]==0
))
}
TE[apply(TE,1,f),]
卵の名無しさん [] 2020/01/28(火) 08:12:46.55:xazq0gTe
では次の問題です
次の動画をみさくら語で解説しましょう
ttp://https://www.youtube.com/watch?v=ckO9d_-qiPw

国試浪人の事務員でなければできるはずだねW
卵の名無しさん [sage] 2020/01/28(火) 09:10:54.29:G+B9uPjF

みさくら語ってド底辺頭脳の言語か?
RとかPythonなら使えるけど。
コンブ薬屋 [] 2020/01/28(火) 10:56:41.57:xazq0gTe
ほほう、どうやら
底辺の国試浪人には解けないようだね
卵の名無しさん [sage] 2020/01/28(火) 10:59:24.13:G+B9uPjF
rm(list=ls())
graphics.off()
seg <- function(a,b,...){
segments(Re(a),Im(a),Re(b),Im(b),col='gray',...)}

plot(0:10,type='n',xlim=c(0,10),ylim=c(0,10),asp=1,bty='l')
seg(10,10+10i,lwd=5) ; seg(0,10,lwd=5) ; seg(0,10i,lwd=5) ; seg(10i,10+10i,lwd=5)

cir <- function(a,b=0,r){
x=seq(a-r,a+r,by=0.01)
x=x[0<x & x<10]
y=b+sqrt(r^2-(x-a)^2)
lines(x,y)
}
for(i in 0:10) cir(i,0, 10-i*0.5)

cir2 <- function(a=10,b,r){
y=seq(b-r,b+r,by=0.01)
y=y[0<y & y<10]
x=a-sqrt(r^2-(y-b)^2)
lines(x,y)
}
for(i in 0:10) cir2(10,i,5-i*0.5)
卵の名無しさん [sage] 2020/01/28(火) 11:00:43.78:G+B9uPjF
cir3 <- function(a=0,b,r){
y=seq(b-r,b+r,by=0.01)
y=y[0<y & y<10]
x=a+sqrt(r^2-(y-b)^2)
lines(x,y)
}
for(i in 0:10) cir3(0,i,10-i*0.5)

cir4 <- function(a,b=10,r){
x=seq(a-r,a+r,by=0.01)
x=x[0<x & x<10]
y=b-sqrt(r^2-(x-a)^2)
lines(x,y)
}
for(i in 0:10) cir4(i,10,5-i*0.5)

ttps://i.imgur.com/92wYLCv.jpg
コンブ薬屋 [] 2020/01/28(火) 12:07:50.04:xazq0gTe
さあ、みさくら語に翻訳しよう


「何?街の薬剤師?大学教授の娘が、街の一薬剤師と結婚したいと言うのか?」
「いけませんの? 」
「絶対に反対だよ。何代も続いている有名な製薬会社オーナーは別として、一般の薬剤師になるものは、会社に残りたくても残れず、仕方なく街の薬剤師になる場合が多いのだ」

「医学部教授と街の薬剤師。比較するだけでもおかしいよ」
卵の名無しさん [] 2020/01/28(火) 12:28:48.28:zoyO6+ty
社交性が無く、職場で干されているアスペルガー医者が建てたスレはここですか?
卵の名無しさん [sage] 2020/01/28(火) 13:27:34.27:G+B9uPjF

みさくら語ってド底辺頭脳の言語は知らんから、リンクも踏んでないよ。
卵の名無しさん [sage] 2020/01/28(火) 13:29:40.54:G+B9uPjF
新型コロナウイルスの統計処理が自分の計算と合わないのが不思議なんだよね。


2019-nCov(2019年新型コロナウイルス)の論文
ttp://https://www.thelancet.com/journals/lancet/article/PIIS0140-6736(20)30183-5/fulltext
は生データがついているので自分で統計処理が再現できるので遊べる。

2019-nCov感染者41例中ICU収容13例(うち現喫煙者0),28例非収容(うち現喫煙者3)である。
このことから、煙草を吸うと重症化が防げると結論できるか?

エントリーに0を含むときにはχ二乗検定は無効なのでFisher testで計算していると思うのだが
Fisher's Exact Test for Count Data

data: cbind(hit, shot - hit)
p-value = 0.539
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.000000 5.257728
sample estimates:
odds ratio
となって、論文のp値 0.31とは合致しないなぁ。
卵の名無しさん [sage] 2020/01/28(火) 13:47:56.68:G+B9uPjF
I hate the so-called Fisher exact test: a pointer to one of my favorite articles

ttp://https://statmodeling.stat.columbia.edu/2009/05/15/i_hate_the_so-c/

ベイズで計算してみるか。


# contingency stan for reproducibility of p.value
library(rstan)
options(mc.cores = parallel::detectCores())
rstan_options(auto_write = TRUE)
contingency2stan <- function(mat,alpha=0.05){
N=apply(mat,1,sum)
data <- list(mat=mat,N=N)
stanModel=readRDS('contingency.rds')
fit=sampling(stanModel,data=data, chain=1, iter=10000)
pars=c('y1','n1_y1','y0','n0_y0','d','RR','OR','NNT')
print(fit, pars=pars,digits=4,prob=c(0.025,0.5,0.975))
ms=rstan::extract(fit)
p.sim=NULL ;attach(ms) ; for(i in 1:length(p11)){
MAT=round(matrix(c(y1[i],n1_y1[i],y0[i],n0_y0[i]),ncol=2,byrow=TRUE))
p.sim=append(p.sim,chisq.test(MAT)$p.value)
}; detach(ms)
BEST::plotPost(p.sim,compVal = 0.05, xlab='p.value')
cat('Pr(p.value < ',alpha,') = ', mean(p.sim<alpha),'\n')
cat('Original p.value = ',chisq.test(mat)$p.value,'\n')
}
卵の名無しさん [sage] 2020/01/28(火) 13:57:41.14:G+B9uPjF

ド底辺スレでの宿題はまだできてないのか?

ド底辺シリツ医大卒の裏口バカは、空室なしの10人5部屋割付の数をまだ出せないのか?

部屋の名前を '底辺','私立','ガチ','裏口','バカ'と命名すると
このように

ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ
ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ バカ
ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ 私立
ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ 底辺
ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ 裏口
ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ バカ ガチ
から
裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 底辺 裏口
裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 ガチ
裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 バカ
裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 私立
裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 底辺
裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口
まで並べて
裏口 底辺 裏口 バカ ガチ 底辺 底辺 私立 私立 バカ
バカ 裏口 私立 私立 私立 バカ ガチ 裏口 ガチ 底辺
バカ 私立 バカ バカ ガチ 裏口 底辺 バカ 裏口 裏口
裏口 裏口 ガチ 裏口 私立 底辺 裏口 裏口 バカ ガチ
底辺 バカ ガチ バカ ガチ 私立 裏口 バカ バカ 裏口

部屋が5種類あるのを数えるだけだぞ。
ド底辺シリツ医大卒の裏口バカって数もろくに数えられないのか?
コンブ薬屋 [] 2020/01/28(火) 14:21:54.71:xazq0gTe
ほら、んほおぉぉぉっ、って言ってみな
んほおぉぉぉっ、ってW
卵の名無しさん [sage] 2020/01/28(火) 15:35:57.65:G+B9uPjF
最新のLancetに掲載された論文:新型コロナウイルスの治療に少量〜中等量のステロイド(メチルプレドニゾロンで40〜120mg/日)使用の有無による死亡例の数字は

Death 4/9 (44.4%) 2/32 (6.3%)

なぜか、他の項目にあったp値が掲載されていない。

Fisher's Exact Test for Count Data

data: mat
p-value = 0.01481456
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
1.217274433 151.944072111
sample estimates:
odds ratio
10.93370175

なんでも確率変数にするのがベイズ統計。

ここで問題

p値の95%信頼区間とp値が0.05未満になる確率を求めよ。
卵の名無しさん [sage] 2020/01/28(火) 15:37:06.96:G+B9uPjF
0.05未満になる確率は

これを持って統計的に有意だというどの程度の信頼度を持っていえるか、ってことなんだな。
卵の名無しさん [sage] 2020/01/28(火) 15:48:52.17:G+B9uPjF
## 2x2 tableからsensitivity,specificity,PPV,NPVの信頼区間を計算
cont2ci<- function(TP,FP,FN,TN){ # contingency table 2 confidence interval
library(BEST)
sensitivity=TP/(TP+FN)
specificity=TN/(TN+FP)
pLR=TP/FP # sensitivity/(1-specificity)
nLR=FN/TN # (1-TP)/(1-FP) = (1-sensitivity)/specificity
PPV=TP/(TP+FP)
NPV=TN/(TN+FN)

par(mfrow=c(3,2))
col=sample(colours(),1)
plotPost(sensitivity,showMode = F,col=col)
plotPost(specificity,showMode = F,col=col)
plotPost(PPV,showMode = F,col=col)
plotPost(NPV,showMode = F,col=col)
plotPost(pLR,showMode = F,col=col)
plotPost(nLR,showMode = F,col=col)
sn=hdi(sensitivity)[1:2]
sp=hdi(specificity)[1:2]
ppv=hdi(PPV)[1:2]
npv=hdi(NPV)[1:2]
plr=hdi(pLR)[1:2]
nlr=hdi(nLR)[1:2]
par(mfrow=c(1,1))
rbind(sn,sp,ppv,npv,plr,nlr)
}
卵の名無しさん [sage] 2020/01/28(火) 15:50:33.03:G+B9uPjF
# ポアソンモデル
k=1e5
TP=rpois(k,43)
FP=rpois(k,2)
FN=rpois(k,35)
TN=rpois(k,25)
cont2ci(TP,FP,FN,TN)

# 二項分布モデル(周辺度数固定)
k=1e5
TP=rbinom(k,43+35,43/(43+35))
FP=rbinom(k, 2+25, 2/( 2+25))
FN=rbinom(k,35+43,35/(35+43))
TN=rbinom(k,25+ 2,25/(25+ 2))
cont2ci(TP,FP,FN,TN)

# 二項分布モデル(総数固定)
k=1e5
mat=matrix(c(43,2,35,25),ncol=2)
colnames(mat)=c("逆転陽性","逆転陰性")
rownames(mat)=c("除菌成功","除菌失敗")
mat
N=apply(mat,1,sum) # 78 vs 27
N.total=sum(mat)
Succ=rbinom(k,N.total,78/N.total)
Fail=rbinom(k,N.total,27/N.total)

FP=rbinom(k,Fail, 2/Fail)
FN=rbinom(k,Succ,35/Succ)
TN=Fail - FP
TP=Succ - FN
cont2ci(TP,FP,FN,TN)
コンブ薬屋 [] 2020/01/28(火) 17:55:30.50:xazq0gTe
では次の問題です
この病棟における入院期間の平均値と治癒率を求めよ
ttp://https://togetter.com/li/1432976
卵の名無しさん [sage] 2020/01/28(火) 19:19:47.40:vtD6D8ed
0がエントリーにあると扱いが難しいな。

rm(list=ls())
mat.smoke=cbind(c(0,3),c(13,28)-c(0,3))
mat.smoke # 喫煙のICU入院のクロス表
Epi::twoby2(mat.smoke)
fmsb::oddsratio(mat.smoke)
library(BayesFactor)
library(BEST)

k=1e3
bfp=contingencyTableBF(mat.smoke,'poisson',post=T,iter=k)
matp=as.data.frame(bfp) # ポアソン分布で乱数化
apply(matp,2,mean)


bfi=contingencyTableBF(mat.smoke,'indepMulti','rows',post=T,iter=k)
bfi=as.data.frame(bfi) # 行の周辺度数固定の二項分布で乱数化
mati=bfi[,1:4]*sum(mat.smoke)
apply(mati,2,mean)

bfj=contingencyTableBF(mat.smoke,'jointMulti',post=T,iter=k)
matj=as.matrix(bfj)*sum(mat.smoke) # 総数数固定の二項分布で乱数化
apply(matj,2,mean)
卵の名無しさん [sage] 2020/01/28(火) 19:19:58.78:vtD6D8ed
mat2pf <- function(x){
fisher.test(matrix(round(x),nrow=2))$p.value # roundで整数化してFisherテスト
}

mat2pc <- function(x){
chisq.test(matrix(x,nrow=2))$p.value # χ二乗検定
}

ppf=apply(matp,1,mat2pf)
plotPost(ppf,compVal=0.05)
ppc=apply(matp,1,mat2pc)
plotPost(ppc,compVal=0.05)

pif=apply(mati,1,mat2pf)
plotPost(pif,compVal=0.05)
pic=apply(mati,1,mat2pc)
plotPost(pic,compVal=0.05)

pjf=apply(matj,1,mat2pf)
plotPost(pjf,compVal=0.05)
pjc=apply(matj,1,mat2pc)
plotPost(pjc,compVal=0.05)

source('tools.R')
jags4prop(0,3,13,28)
卵の名無しさん [sage] 2020/01/28(火) 19:22:05.70:vtD6D8ed
リンクは踏まないから、こういう風に問題を書けよ。

"某女子大には決して嘘をつかない学生と必ず嘘をつく学生がいることがわかっている。
この女子大の学生(嘘つきかどうかは不明)から
「あなたのいうことが正しければ手コキかフェラをしてあげる、間違っていれば何もしてあげない」と言われた。
この女子大生にフェラをしてもらうには何と言えばいいか?
卵の名無しさん [] 2020/01/28(火) 19:47:42.30:xazq0gTe
ここは下品ないんたねっとですね

まさにこのスレはド底辺と呼ぶにふさわしいですねW
卵の名無しさん [sage] 2020/01/28(火) 20:34:26.25:vtD6D8ed
これで、
# 2x2のクロス表からstanを使ってMCMCサンプリングしてFisherテストしてp.valueの配列からその分布を表示させる

library(rstan)
options(mc.cores = parallel::detectCores())
rstan_options(auto_write = TRUE)

contingency2stan2pf <- function(mat,alpha=0.05,print=T){
N=apply(mat,1,sum)
data <- list(mat=mat,N=N)
stanModel=readRDS('contingency.rds')
fit=sampling(stanModel,data=data, chain=1, iter=25000,warmup=5000)
pars=c('y1','n1_y1','y0','n0_y0','d','RR','OR','NNT')
if(print) print(fit, pars=pars,digits=4,prob=c(0.025,0.5,0.975))
ms=rstan::extract(fit)
p.sim=NULL
for(i in 1:length(p11)){
MAT=round(with(ms,matrix(c(y1[i],n1_y1[i],y0[i],n0_y0[i]),ncol=2,byrow=TRUE)))
p.sim=append(p.sim,fisher.test(MAT)$p.value)
}
BEST::plotPost(p.sim,compVal = 0.05, xlab='p.value')
cat('Pr(p.value < ',alpha,') = ', mean(p.sim<alpha),'\n')
cat('Original p.value = ',fisher.test(mat)$p.value,'\n')
print(summary(p.sim))
invisible(p.sim)
}

サンプル数を増やしてpを小さくして信用させるという手法を見破れるかな。
卵の名無しさん [sage] 2020/01/28(火) 20:35:30.81:vtD6D8ed

ちゃんと答えないとフェラしてもらえないよ。
卵の名無しさん [sage] 2020/01/28(火) 20:38:30.25:vtD6D8ed
> (mat.steroid=cbind(c(4,2),c(9,32)-c(4,2))) # ステロイドと死亡数
[,1] [,2]
[1,] 4 5
[2,] 2 30
> contingency2stan2pf(mat.steroid,p=F)

Pr(p.value < 0.05 ) = 0.7024
Original p.value = 0.01481455782
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.0000121509 0.0055484536 0.0148145578 0.0481260381 0.0611450791 1.0000000000
卵の名無しさん [sage] 2020/01/28(火) 21:01:49.02:vtD6D8ed

フィッシャー検定は非負整数しか許さないから、こんな感じで
ttps://i.imgur.com/b4musi9.jpg
グラフにすると途切れができてしまうのが美しくない。

χ二乗検定版を作ってみよう。
卵の名無しさん [] 2020/01/28(火) 21:03:52.80:IbKEPttD
国試浪人の素人童貞のスレはここですか?
卵の名無しさん [sage] 2020/01/28(火) 21:07:29.78:vtD6D8ed


# χ二乗テスト版
contingency2stan2pc <- function(mat,alpha=0.05,print=T){
N=apply(mat,1,sum)
data <- list(mat=mat,N=N)
stanModel=readRDS('contingency.rds')
fit=sampling(stanModel,data=data, chain=1, iter=25000,warmup=5000)
pars=c('y1','n1_y1','y0','n0_y0','d','RR','OR','NNT')
if(print) print(fit, pars=pars,digits=4,prob=c(0.025,0.5,0.975))
ms=rstan::extract(fit)
p.sim=NULL
for(i in 1:length(p11)){
MAT=with(ms,matrix(c(y1[i],n1_y1[i],y0[i],n0_y0[i]),ncol=2,byrow=TRUE))
p.sim=append(p.sim,chisq.test(MAT)$p.value)
}
BEST::plotPost(p.sim,compVal = 0.05, xlab='p.value')
cat('Pr(p.value < ',alpha,') = ', mean(p.sim<alpha),'\n')
cat('Original p.value = ',chisq.test(mat)$p.value,'\n')
print(summary(p.sim))
invisible(p.sim)
}
(mat.smoke=cbind(c(0,3),c(13,28)-c(0,3))) # 喫煙とICU入院のクロス表
contingency2stan2pc(mat.smoke,p=F)
(mat.steroid=cbind(c(4,2),c(9,32)-c(4,2))) # ステロイドと死亡数
p.sim=contingency2stan2pc(mat.steroid,p=F)
sapply(c(0.0001,0.001,0.01,0.05),function(x) mean(p.sim<x))
lines(density(p.sim))

この方が美しいな。
ttps://i.imgur.com/RBXeR57.jpg
卵の名無しさん [sage] 2020/01/28(火) 21:08:19.29:vtD6D8ed

これできないとフェラしてもらえないよ。

"某女子大には決して嘘をつかない学生と必ず嘘をつく学生がいることがわかっている。
この女子大の学生(嘘つきかどうかは不明)から
「あなたのいうことが正しければ手コキかフェラをしてあげる、間違っていれば何もしてあげない」と言われた。
この女子大生にフェラをしてもらうには何と言えばいいか?
卵の名無しさん [sage] 2020/01/28(火) 21:10:44.10:vtD6D8ed
人類の三大発明は

言語・貨幣・フェラチオである。

by 吉田戦車
卵の名無しさん [] 2020/01/28(火) 21:52:45.89:cUmejCEO
お兄ちゃん、イサキは、イサキは獲れたのっ?
卵の名無しさん [sage] 2020/01/28(火) 21:57:08.65:vtD6D8ed
比率の比較でなくて平均値の比較のときはp値の信頼区間算出はブートストラップを使えば簡単にだせるな。

知能指数が平均101と99の各々500人からなる集団の比較
# t検定(等分散)
T.test=function(n1,n2,m1,m2,sd1,sd2){
SE12=sqrt((1/n1+1/n2)*((n1-1)*sd1^2+(n2-1)*sd2^2)/((n1-1)+(n2-1)))
T=(m1-m2)/SE12
p.value=2*pt(abs(T),n1-1+n2-1,lower.tail = FALSE)
return(c(p.value=p.value,t.statistic=T))
}

n=500
a=99
b=101
A=a+scale(rnorm(n))*15
B=b+scale(rnorm(n))*15
T.test(n,n,a,b,15,15)
t.test(A,B,var=T)$p.value
sim <- function(x=n) t.test(sample(A,x,rep=T),sample(B,x,rep=T))$p.value
k=1e4
pv=replicate(k,sim())
summary(pv)
quantile(pv,prob=c(0.005,0.025,0.5,0.975,0.995))
BEST::plotPost(pv,compVal = 0.05,showMode = T,breaks=50)
卵の名無しさん [sage] 2020/01/28(火) 22:00:00.87:vtD6D8ed

釣り人(嘘つきかどうかは不明)から
「あなたのいうことが正しければイサキかイサキの餌のどちらかをあげる、間違っていれば何もあげない」と言われた。
この釣り人からイサキをもらうには何と言えばいいか?
卵の名無しさん [sage] 2020/01/29(水) 05:29:27.06:qmYv2xxr
少し一般化、復元抽出するか否かや個数が不均等でも計算できるように改変。

# 母集団Na,Nb個 平均Ma,Mb 標準偏差SDa,SDbからna,nbを抽出しt検定比較ときのp値の分布
pCI <- function(Na=500,Nb=Na,Ma=99,Mb=101,SDa=15,SDb=SDa,na=50,nb=na,
rep=FALSE,k=1e3,print=TRUE){
A=Ma+scale(rnorm(Na))*SDa
B=Mb+scale(rnorm(Nb))*SDb
sim <- function(m) t.test(sample(A,na,replace=rep),sample(B,nb,replace=rep))$p.value
pv=replicate(k,sim())
if(print){
print(T.test(n,n,a,b,15,15))
print(summary(pv))
BEST::plotPost(pv,compVal = 0.05,showMode = T,breaks=50)}
invisible(pv)
}
卵の名無しさん [sage] 2020/01/29(水) 05:46:52.67:qmYv2xxr
デフォルト設定では母集団から1/10の標本を抽出するように変更

# 母集団Na,Nb個 平均Ma,Mb 標準偏差SDa,SDbからna,nbを抽出しt検定比較ときのp値の分布
pCI <- function(Na=500,Nb=Na,Ma=99,Mb=101,SDa=15,SDb=SDa,na=Na/10,nb=Nb/10,
rep=FALSE,k=1e3,print=TRUE){
A=Ma+scale(rnorm(Na))*SDa
B=Mb+scale(rnorm(Nb))*SDb
sim <- function(m) t.test(sample(A,na,replace=rep),sample(B,nb,replace=rep))$p.value
pv=replicate(k,sim())
if(print){
print(t.test(A,B))
print(summary(pv))
BEST::plotPost(pv,compVal = 0.05,showMode = T,breaks=50)}
invisible(pv)
}
卵の名無しさん [sage] 2020/01/29(水) 05:53:26.38:qmYv2xxr
標準大学の新入生の知能指数の平均を100とする。
ド底辺シリツ医大の新入生の知能指数の平均が85であった。

各々から1/10を無作為抽出して知能指数をt検定したときのp値の期待値、中央値を求めよ。
また、p値が0.05以上になってド底辺シリツ医の新入生の知能指数は統計的に有意差はないと主張できる確率はいくらか?


# 母集団Na,Nb個 平均Ma,Mb 標準偏差SDa,SDbからna,nbを抽出しt検定比較ときのp値の分布
pCI <- function(Na=500,Nb=Na,Ma=99,Mb=101,SDa=15,SDb=SDa,na=Na/10,nb=Nb/10,
rep=FALSE,k=1e3,print=TRUE){ # IQ:m=100,sd=15
A=Ma+scale(rnorm(Na))*SDa
B=Mb+scale(rnorm(Nb))*SDb
sim <- function(m) t.test(sample(A,na,replace=rep),sample(B,nb,replace=rep))$p.value
pv=replicate(k,sim())
if(print){
print(t.test(A,B))
print(summary(pv))
BEST::plotPost(pv,compVal = 0.05,showMode = T,breaks=50)}
invisible(pv)
}

pCI(Na=100,Ma=100,Mb=85)
卵の名無しさん [sage] 2020/01/29(水) 05:56:48.55:qmYv2xxr

この手法で新薬の血中濃度は老人でも統計的に有意差はないので、安心して老人にも処方できます
という商用パンプを目にする。

底辺シリツ医=裏口容疑者はこういうのに騙されるんだよなぁ。
卵の名無しさん [sage] 2020/01/29(水) 07:45:56.70:qmYv2xxr

平均値100 標準偏差15で定義される知能指数で
標準大学の新入生の知能指数の平均が100
裏口シリツ医大の新入生の知能指数の平均が85であったとする。
1学年は100人として
各大学から1/10を無作為抽出して知能指数をt検定したときのp値の期待値、中央値を求めよ。
また、p値が0.05以上になって裏口シリツ医大の新入生の知能指数は統計的に有意差はないと主張できる確率はいくらか?
卵の名無しさん [] 2020/01/29(水) 10:58:46.40:wNUvDIoi

大漁っ!!イサキぃぃ!!おにいちゃんかっこいいいいぃぃぃい ぃくううううう!
卵の名無しさん [] 2020/01/29(水) 12:49:44.99:NU71nZE3
私立出身医が一番多いスレであろう「開業医が集うスレ」のほうには書き込みせんのな?
卵の名無しさん [sage] 2020/01/29(水) 15:37:18.14:qmYv2xxr

書いているよ。
開業医スレでもシリツは馬鹿にされているじゃん。

ttps://egg.5ch.net/test/read.cgi/hosp/1579579161/54">ttps://egg.5ch.net/test/read.cgi/hosp/1579579161/54

卵の名無しさん [sage] 2020/01/29(水) 15:37:56.49:qmYv2xxr

そんなにレスじゃ、フェラもイサキも手に入れることはできんぞ。
卵の名無しさん [] 2020/01/29(水) 17:41:57.38:wNUvDIoi
では次の問題です
タバコは脳の病気です
この事実を証明せよ
ttp://https://togetter.com/li/1432976
卵の名無しさん [sage] 2020/01/29(水) 17:46:37.77:qmYv2xxr
>853
卵の名無しさん [sage] 2020/01/29(水) 19:50:54.32:qmYv2xxr

俺が書かなくてもこういう投稿を目にする。
まあ、シリツ医という表記は俺の影響かもしれん。
自治医大とかを除外する意味で私立と書いていないわけだが。
>>
優秀な女子はぜひ国立医に入ってほしい
シリツ医は開業医のアホ子弟専用の専門学校
卵の名無しさん [] 2020/01/29(水) 21:34:38.87:wNUvDIoi
まあたしかに私立は学費が高いのは認める
わしも経済的理由で
合格した慶応は学費が高いので蹴って
地元イナカの国立にいった
卵の名無しさん [sage] 2020/01/30(木) 05:17:39.51:m/EdOA9B

イナカも東京も国立なら学費は同じだぞ。
卵の名無しさん [] 2020/01/30(木) 08:20:09.67:b9qEKmQr

イナカモノにしてみれば
地元以外のところに大学が存在しているという時点で
学費以外にもアパート代や食費などの参入障壁があるんだな
卵の名無しさん [sage] 2020/01/30(木) 08:31:17.69:17lSJR5q

シリツ医大専門受験予備校のバイトは一コマ90分で手取り2万円だったな。大学の授業料が年間14万4千円の頃の話。
地方にはそんな割のいいバイトはない。
卵の名無しさん [sage] 2020/01/30(木) 20:25:51.32:m/EdOA9B
Rで困ったらstackoveflow.comだな。

library(Rmpfr)

vect = rep(0, 5)

for(i in 1:5){
vect[i] = mpfr(x=10^-(10*i), precBits=100)
}
# My vector has just turned to a list
vect

# Sum of list is an error
sum(vect)


# Turn it to a vector
converted_vect = Rmpfr::mpfr2array(vect, dim = length(vect))
converted_vect

# Now my sum and prod work fine and the precision is not lost
sum(converted_vect)
prod(converted_vect)
卵の名無しさん [sage] 2020/01/30(木) 21:10:39.28:m/EdOA9B
パッケージの内部関数を使って解決してくれた。

The function mpfr2array is not suposed to be called by the user, it is an internal tool for the package. However it's one way to solve the problem.
卵の名無しさん [sage] 2020/01/30(木) 21:21:54.99:m/EdOA9B
Rはデフォルトでは不定長さ整数を扱えないので工夫がいる。
その点はpythonやHaskellの方が有利。

"
H(n) = Σ[k=1,2,...,n] 1/k
とする。H(n)を既約分数で表したときの分子の整数をf(n)と表す。
(1)lim[n→∞] H(n) を求めよ、答えのみで良い。
(2)n=1,2,...に対して、f(n)に現れる1桁の整数を全て求めよ
"
rm(list=ls())

H <- function(n,prec=1000){ # Σ 1/kを既約分数表示する
GCD <- function(a,b){  # ユークリッドの互除法
r = a%%b # a=bq+r ⇒ a%%b=b%%rで最大公約数表示
while(r!=0){a = b ; b = r ; r = a%%b}
b }
library(Rmpfr)
one = mpfr(1, prec) # 1(one)を1000桁精度に設定
nn = 1:n # nn : 1 2 3 ... n
nume=numeric(n) # 分子の容器
for(i in nn) nume[i] = prod(nn[-i])*one # nnからi番目の要素を除いて乗算し精度アップ
nume = mpfr2array(nume, dim = length(nume)) # mpfr2arrayで加算を可能にする
Nume = sum(nume) # numeの総和を計算して分子に
Deno = factorial(n)*one # 分母のn!を精度アップ
gcd = GCD(Nume,Deno) # Numerator/Denominator約分するため最大公約数を計算
res=list(nume = Nume/gcd,deno=Deno/gcd,ratio=as.numeric(Nume/Deno)) # 最大公約数で除算して
cat(as.numeric(res$nume),'/',as.numeric(res$deno),'\n') # 数値化して分数表示
invisible(res)
}
卵の名無しさん [sage] 2020/01/30(木) 23:51:43.56:m/EdOA9B
#Reed-Frost Model
ReedFrost=function(
p=0.04,
N=100,
T=40)
{
q=1-p
I=numeric(T)
S=numeric(T)
I[1]=1
S[1]=N-I[1]
for(t in 1:(T-1)){
I[t+1]=S[t]*(1-q^I[t])
S[t+1]=S[t]-I[t+1]
}

plot(1:T,I,type="l",lwd=2, ylim=c(0,N),xlab="time",ylab="persons",main=paste("Reed-Frost Model p= ",p))
lines(S,lty=2,col=2,lwd=2)
lines(N-S,lty=3,col=3,lwd=2)
legend("topright",bty="n",legend=c("Infected","Susceptible","Immunized"),lty=1:3,col=1:3,lwd=2)
}

par(mfrow=c(1,2))
ReedFrost(0.04)
ReedFrost(0.015)

ReedFrost(0.30)
ReedFrost(0.03)
ReedFrost(0.003)
卵の名無しさん [sage] 2020/01/30(木) 23:53:06.51:m/EdOA9B
こっちは、モンテカルロによるシミュレーション

# Reed-Frost and Greenwood epidemic models
# written by Dennis Chao (1/2009)

# reedfrost - the Reed-Frost epidemic model
# p = probability of transmission
# I0 = initial number of infecteds
# S0 = initial number of susceptibles
# n = number of trials
# greenwood = set to TRUE for the Greenwood model, otherwise run Reed-Frost
# outputs the number of infected and susceptibles over time (as I and S)
reedfrost <- function(p, I0, S0, n, greenwood=FALSE) {
S <- St <- rep(S0, n)
I <- It <- rep(I0, n)
q <- 1-p

time <- 0
while (sum(It)>0) {
if (greenwood)
It <- rbinom(n, St, ifelse(It>0, p, 0))
else
It <- rbinom(n, St, 1-(q^It))
St <- St-It
I <- rbind(I, It)
S <- rbind(S, St)
time <- time+1
}
I <- as.matrix(I)
S <- as.matrix(S)
list(I0=I0,S0=S0,p=p,n=n,I=I,S=S)
}
卵の名無しさん [sage] 2020/01/31(金) 00:59:52.85:24QiZJ0Y
f <- function(n,prec=1000){ # Σ 1/kを既約分数表示する
if(n==1){
cat(1,'\n')
invisible(1)
}else{
GCD <- function(a,b){  # ユークリッドの互除法
r = a%%b # a=bq+r ⇒ a%%b=b%%rで最大公約数表示
while(r!=0){a = b ; b = r ; r = a%%b}
b }
library(Rmpfr)
one = mpfr(1, prec) # 1(one)を1000桁精度に設定
nn = 1:n # nn : 1 2 3 ... n
nume=numeric(n) # 分子の容器
for(i in nn) nume[i] = prod(nn[-i])*one # nnからi番目の要素を除いて乗算し精度アップ
nume = mpfr2array(nume, dim = length(nume)) # mpfr2arrayで加算を可能にする
Nume = sum(nume) # numeの総和を計算して分子に
Deno=factorialZ(n) # 分母 n! = factorial(n*one)
gcd = GCD(Nume,Deno) # Numerator/Denominator約分するため最大公約数を計算
res=list(nume = Nume/gcd,deno=Deno/gcd,ratio=as.numeric(Nume/Deno)) # 最大公約数で除算して
 # 分数表示 give.head=FALSEでheader除去,digits.dで桁数を指定
# capture.outputで変数に取り込み
nm = capture.output(str(res$nume, give.head=FALSE,digits.d = prec))
dn = capture.output(str(res$deno, give.head=FALSE,digits.d = prec))
cat(paste0(nm,'/',dn,'\n'))
invisible(res)
}}
for(i in 1:30) f(i)
卵の名無しさん [sage] 2020/01/31(金) 01:00:30.29:24QiZJ0Y
> for(i in 1:30) f(i)
1
3 / 2
11 / 6
25 / 12
137 / 60
49 / 20
363 / 140
761 / 280
7129 / 2520
7381 / 2520
83711 / 27720
86021 / 27720
1145993 / 360360
1171733 / 360360
1195757 / 360360
2436559 / 720720
42142223 / 12252240
14274301 / 4084080
275295799 / 77597520
55835135 / 15519504
18858053 / 5173168
19093197 / 5173168
122755644038509457 / 32872539188238750
186187999757029099 / 49308808782358125
14112026408124257248 / 3698160658676859375
185305423634953775872 / 48076088562799171875
5051322526706550956032 / 1298054391195577640625
11894590428248250515456 / 3028793579456347828125
1043915747995966839455744 / 263505041412702261046875
2255784105806550548873216 / 564653660170076273671875
卵の名無しさん [sage] 2020/01/31(金) 01:12:13.74:24QiZJ0Y

H(n) = Σ[k=1,2,...,n] 1/k
とする。H(n)を既約分数で表したときの分子の整数をf(n)と表す。
f(77)を求めよ。

> f(77)
17610982920730618962802441030965952272844514966520010106103127939813509744122599441432576
/ 3574019481870823559764745233429885438685864430565417716720215849457565210956573486328125
卵の名無しさん [sage] 2020/01/31(金) 07:13:25.20:24QiZJ0Y

n=100と大きいとNAが混ざるな
卵の名無しさん [sage] 2020/01/31(金) 07:15:08.03:24QiZJ0Y
f <− function(n,prec=10000){ # Σ 1/kを既約分数表示する
  if(n==1){
    cat(V V,1,V\nV)
    invisible(1)
  }else{
   GCD <− function(a,b){  # ユークリッドの互除法 
    r = a%%b               # a=bq+r ⇒ a%%b=b%%rで最大公約数表示
    while(r!=0){a = b ; b = r ; r = a%%b}
    b }
卵の名無しさん [sage] 2020/01/31(金) 07:15:14.10:24QiZJ0Y
  library(Rmpfr)
  one = mpfr(1, prec) # 1(one)を10000桁精度に設定
  nn = 1:n            # nn : 1 2 3 ... n
  nume=numeric(n)     # 分子の容器
  for(i in nn) nume[i] = prod(nn[−i])*one # nnからi番目の要素を除いて乗算し精度アップ
  nume = mpfr2array(nume, dim = length(nume)) # mpfr2arrayで加算を可能にする
  Nume = sum(nume) # numeの総和を計算して分子に
  Deno=factorialZ(n) # 分母 n! = factorial(n*one)
  gcd = GCD(Nume,Deno) # Numerator/Denominator約分するため最大公約数を計算
  res=list(nume = Nume/gcd,deno=Deno/gcd,ratio=as.numeric(Nume/Deno)) # 最大公約数で除算して
  # 分数表示 give.head=FALSEでheader除去,digits.dで桁数を指定
  # capture.outputで切り取りsubstrで[1]を除去
  # nm = capture.output(str(res$nume, give.head=FALSE,digits.d = prec)) NAが混ざるバグあり
  nm =substr(capture.output(res$nume)[2],5,nchar(res$nume)) # W[1] 1234..W 文字列の5文字目から最後まで
  dn =substr(capture.output(res$deno)[2],5,nchar(res$deno))
  cat(paste0(nm,V/V,dn,V\nV))
  invisible(res)
}}
卵の名無しさん [sage] 2020/01/31(金) 07:15:42.75:24QiZJ0Y
> f(100)
3055216077446868329553816926933899676639525195878807877583434152044192757431459126874725081455196840519615954410565802448075620352
/ 588971222367687651371627846346807888288472382883312574253249804256440585603406374176100610302040933304083276457607746124267578125
卵の名無しさん [sage] 2020/01/31(金) 07:45:49.87:24QiZJ0Y
Reed-Frost モデル

(1) 集団内の感染者と感受性のあるものとの接触はランダムに起こる
(2) 感染者と感受性のあるものが接触して伝播する確率は一定である
(3) 感染のあと必ず免疫が起こる(再感染はしない)
(4) その集団は他の集団から隔離されている
(5) 上記の条件は各時間経過中一定である

ReedFrost=function(
p=0.04, # 1期間内での伝播確率
N=100, # 集団の人数
T=40) # 全期間
{
q=1-p # 伝播させない確率
I=numeric(T) # 感染者数 Infecteds
S=numeric(T) # 感受性のある人数 Susceptibles
I[1]=1 #一人から始まったとする
S[1]=N-I[1]
for(t in 1:(T-1)){
I[t+1]=S[t]*(1-q^I[t]) # Reed-Frost Model
S[t+1]=S[t]-I[t+1]
}
return(list(I,T))
}
卵の名無しさん [sage] 2020/01/31(金) 11:25:54.82:24QiZJ0Y
# simulation model using binominal random number
rm(list=ls())
reedfrost <- function(p, I0, S0, n, greenwood=FALSE) {
S <- St <- rep(S0, n) # St : Suscepibles @ time t, S:
I <- It <- rep(I0, n) # It : Infected @ time t
q <- 1-p # probability of non-transmission

time <- 0
while (sum(It)>0) { # until no new transmission
if (greenwood)
It <- rbinom(n, St, ifelse(It>0, p, 0))
else
It <- rbinom(n, St, 1-(q^It)) # how many ppl newly trannsmitted among St
St <- St-It # how many ppl left non-infected
I <- rbind(I, It)
S <- rbind(S, St)
time <- time+1
}
Inames=NULL
for(i in 0:(nrow(I)-1)) Inames[i+1]=paste0('I',i)
rownames(I)=Inames
Snames=NULL
for(i in 0:(nrow(I)-1)) Snames[i+1]=paste0('S',i)
rownames(S)=Snames
list(I0=I0,S0=S0,p=p,n=n,I=I,S=S)
}
re=reedfrost(0.05,1,99,100)
nr=nrow(re$I)
plot(0:(nr-1),re$I[,1],bty='l',type='l',lwd=2,
ylim=c(0,max(re$I)),xlab='time',ylab='Infecteds')
for(i in 2:n) lines(0:(nr-1),re$I[,i],lwd=2,col=sample(colours()))
卵の名無しさん [sage] 2020/01/31(金) 15:00:17.56:24QiZJ0Y
# SEIR MODEL
"
dS(t)/dt=-bS(t)I(t),
dE(t)/dt=bS(t)I(t)-aE(t) ,
dI(t)/dt=aE(t)-gI(t) ,
dR(t)/dt=gI(t)
a:発症率,b:感染率,g:回復率
"
remove (list = objects() )
graphics.off()

SEIR <- function(
# Parameters
contact_rate = 10, # number of contacts per day
transmission_probability = 0.07, # transmission probability
infectious_period = 5, # infectious period
latent_period = 2, # latent period
# Initial values for sub-populations.
s = 9990, # susceptible hosts
e = 9, # exposed hosts
i = 1, # infectious hosts
r = 0, # recovered hosts
# Output timepoints.
timepoints = seq (0, 100, by=0.5)
){
卵の名無しさん [sage] 2020/01/31(金) 15:00:39.55:24QiZJ0Y
library(deSolve)
# Function to compute derivatives of the differential equations.
seir_model = function (current_timepoint, state_values, parameters)
{
# create state variables (local variables)
S = state_values [1] # susceptibles
E = state_values [2] # exposed
I = state_values [3] # infectious
R = state_values [4] # recovered

with (
as.list (parameters), # variable names within parameters can be used
{
# compute derivatives
dS = (-beta * S * I)
dE = (beta * S * I) - (delta * E)
dI = (delta * E) - (gamma * I)
dR = (gamma * I)

# combine results
results = c (dS, dE, dI, dR)
list (results)
}
)
}

# Compute values of beta (tranmission rate) and gamma (recovery rate).
beta_value = contact_rate * transmission_probability
gamma_value = 1 / infectious_period
delta_value = 1 / latent_period
卵の名無しさん [sage] 2020/01/31(金) 15:00:45.24:24QiZJ0Y
# Compute Ro - Reproductive number.
Ro = beta_value / gamma_value

# Disease dynamics parameters.
parameter_list = c (beta = beta_value, gamma = gamma_value, delta = delta_value)

# Compute total population.
N = s + i + r + e

# Initial state values for the differential equations.
initial_values = c (S = s/N, E = e/N, I = i/N, R = r/N)

# Simulate the SEIR epidemic.
# ?lsoda # Solver for Ordinary Differential Equations (ODE), Switching Automatically Between Stiff and Non-stiff Methods
output = lsoda (initial_values, timepoints, seir_model, parameter_list)

# Plot dynamics of Susceptibles sub-population.
plot (S ~ time, data = output, pch='S', type='b', col = 'blue', bty='l', cex=0.75,
ylab='SEIR')
points(E ~ time, data = output, pch='E', type='b', col = 'yellow', cex=0.75)
points(I ~ time, data = output, pch='I', type='b', col = 'red', cex=0.75)
points(R ~ time, data = output, pch='R', type='b', col = 'green', cex=0.75)
}

SEIR()
args(SEIR)
SEIR(contact_rate=0.5,transmission_probability=0.05,infectious_period=365,latent_period=7,s=99,e=0,i=1,r=0,timepoints = 0:365*6)
卵の名無しさん [sage] 2020/01/31(金) 17:42:44.66:24QiZJ0Y
エンデミックな定常状態を(S?, I?)とおけば、S?N=1R0,I?N=μμ+γ(1?1R0)(15)である。すなわちエンデミックな状態における感受性人口比率と基本再生産数は逆数関係にあり、有病率(prevalence)I?/Nは1?1/R0に比例していて、その比例係数は、感染状態における平均滞在時間1/(μ+γ)とホストの寿命1/μの比である。これらの式はエンデミックな感染症におけるR0の推定式ともみなせる
卵の名無しさん [sage] 2020/01/31(金) 17:45:07.01:24QiZJ0Y
Rv?1という条件はワクチン接種率の条件として書き直せばv?1?1R0=H
卵の名無しさん [sage] 2020/02/01(土) 15:12:17.98:hIisy8jC
H(n) = Σ[k=1,2,...,n] 1/k
とする。H(n)を既約分数で表したときの分子の整数をf(n)と表す。
(1)lim[n→∞] H(n) を求めよ、答えのみで良い。
(2)n=1,2,...に対して、f(n)に現れる1桁の整数を全て求めよ
"
H <- function(n) sum(1/(1:n))
plot(sapply(1:1000,H),bty='l')

f <- function(n,prec=10000){ # Σ 1/kを既約分数表示する n>>=23で誤計算
if(n==1){
cat(n, ':' ,1,'\n')
invisible(1)
}else{
GCD <- function(a,b){  # ユークリッドの互除法
r = a%%b # a=bq+r ⇒ a%%b=b%%rで最大公約数表示
while(r!=0){a = b ; b = r ; r = a%%b}
b }
nn = 1:n # nn : 1 2 3 ... n
nume=list() # 分子の容器
length(nume)=n
Nume=0
library(gmp)
for(i in nn) Nume = Nume + prod.bigz(nn[-i]) # nnからi番目の要素を除いて乗算して総和を分子に
Deno=factorialZ(n) # 分母
gcd = GCD(Nume,Deno) # Numerator/Denominator約分するため最大公約数を計算
NUME=Nume/gcd
DENO=Deno/gcd
ratio=as.numeric(Nume/Deno)
RE=list(NUME,DENO,ratio) # 最大公約数で除算して約分
cat(n, ':' ,as.character(NUME),'/',as.character(DENO),'\n')
invisible(RE)
}}
卵の名無しさん [sage] 2020/02/01(土) 22:05:31.53:hIisy8jC
H(n) = Σ[k=1,2,...,n] 1/k
とする。H(n)を既約分数で表したときの分子の整数をf(n)と表す。

f <- function(n){ # Σ 1/kを既約分数表示する
if(n==1){
cat(n, ':' ,1,'\n')
invisible(1)
}else{
GCD <- function(a,b){  # ユークリッドの互除法
r = a%%b # a=bq+r ⇒ a%%b=b%%rで最大公約数表示
while(r!=0){a = b ; b = r ; r = a%%b}
b }
nn = 1:n # nn : 1 2 3 ... n
nume=list() # 分子の容器となるlist
length(nume)=n # を設定
Nume=0
library(gmp)
for(i in nn) Nume = Nume + prod.bigz(nn[-i]) # nnからi番目の要素を除いて乗算して総和を分子に
Deno=factorialZ(n) # 分母
gcd = GCD(Nume,Deno) # 約分するため最大公約数を計算
NUME=Nume/gcd
DENO=Deno/gcd
ratio=as.numeric(Nume/Deno)
RE=list(NUME,DENO,ratio)
cat(n, ':' ,as.character(NUME),'/',as.character(DENO),'\n')
invisible(RE)
}}
卵の名無しさん [sage] 2020/02/02(日) 13:53:23.64:+5dNqMpE
tbl <- function(x,v){ # vの要素がxにいくつあるか集計する
n=length(v)
hme=numeric(n) # how many entries?
for(i in 1:n) hme[i]=sum(x==v[i])
rbind(v,hme)
}

tbl(sample(10,rep=T),1:10)
卵の名無しさん [sage] 2020/02/04(火) 16:35:57.11:b64IHQrg
"ttp://https://this.kiji.is/597220008571339873?c=39550187727945729
中国湖北省武漢市からチャーター機で日本へ帰国した邦人の新型コロナウイルス感染率が高いと、
中国で驚きの声が上がっている。中国当局が発表した同市の感染者の割合に比べ「39倍も高い」というのだ。
現地は医療現場が混乱しているため、実際には発表よりかなり多くの感染者がいる可能性がある。
日本政府はチャーター機計3便を武漢市に派遣し、邦人565人が帰国した。厚生労働省によると、
チャーター機に乗っていた感染者は、症状のない人も含め計8人。感染率は1.416%だ。
一方、1月31日現在、武漢市の感染者数は3215人で、感染率は0.036%にとどまった。"
r1=8
r2=3215
n1=565
n2=round(3215/(0.036/100))
poisson.test(c(r1,r2),c(n1,n2))
prop.test(c(r1,r2),c(n1,n2))
library(BayesFactor)
mat=cbind(c(r1,r2),c(n1,n2)-c(r1,r2))
fisher.test(mat)
chisq.test(mat)$p.value
bf=BayesFactor::contingencyTableBF(mat,sampleType = 'poisson',posterior = TRUE,iteration=1e5)
rbf=round(bf)
(r1/n1)/(r2/n2)
frp <- function(x) (x[1]/(x[1]+x[2]))/ (x[3]/(x[3]+x[4]))
rrp=apply(rbf,1,frp)
hist(rrp)
BEST::plotPost(rrp)
(r1/(n1-r1))/(r2/(n2-r2))
fop <- function(x) (x[1]/x[2])/ (x[3]/x[4])
orp=apply(rbf,1,fop)
BEST::plotPost(orp)
quantile(orp,c(0.005,0.025,0.5,0.975,0.995))
library(exact2x2)
exact2x2::fisher.exact(mat)
fisher.test(mat)
卵の名無しさん [sage] 2020/02/04(火) 16:57:56.53:b64IHQrg
# Reed-Frost Model 時刻t+1での感染者数=時刻tでの感受性人数*(少なくとも一人の感染者がでる確率)
# p=0.04;N=100;I0=1;T=8
ReedFrost=function(
p=8/565, # 1期間内での伝播確率
N=565, # 集団の人数
I0=8, # 最初の感染者数
T=30, # 全期間
print=TRUE # グラフ表示
)
{
q=1-p # 伝播させない確率
I=numeric(T) # 感染者数 newly Infecteds
S=numeric(T) # 感受性のある人数 Susceptibles
I[1]=I0 # I0人から始まったとする
S[1]=N-I[1]
for(t in 1:(T-1)){
I[t+1]=S[t]*(1-q^I[t]) # Reed-Frost Model
S[t+1]=S[t]-I[t+1]
}
if(print){
plot(1:T,I,type='b',pch=19,lwd=2, ylim=c(0,N),bty='l',
xlab="time",ylab="persons",main=paste("Reed-Frost Model p= ",round(p,3)))
points(S,lty=2,col=2,lwd=2,type='b',pch=19)
points(N-S,lty=3,col=3,lwd=2,type='b',pch=19)
legend("right",bty="n",legend=c("New Infection","Susceptible","Immunized"),lty=1:3,col=1:3,lwd=2)}
list(newly_infecteds=round(I),susceptibles=round(S))
}
ReedFrost(T=7)
卵の名無しさん [sage] 2020/02/06(木) 22:51:49.26:WriFO9uC
"厚生労働省によりますと、新型コロナウイルスに感染した香港の男性が乗っていたクルーズ船で、
症状がみられる人やその濃厚接触者などにウイルス検査を実施した結果、10人が感染していたことが新たに確認されました。
これまでにこのクルーズ船の乗員乗客で感染が確認されたのは、合わせて20人です。

厚生労働省によりますと、クルーズ船「ダイヤモンド・プリンセス」の船内では
乗客と乗組員全員の合わせて3700人余りの検疫が行われ、発熱やせきなどの症状があった120人と、
症状がある人と濃厚接触した153人の合わせて273人から検体を採取して順次、ウイルス検査を実施しています。
6日、新たに71人分の結果が判明しこのうち10人がウイルスに感染していたことが確認されました。
"

NN=3700

N=273
n=71
r=10

(re=binom::binom.confint(r,n,conf=0.95))
cbind(re[,1],re[,5:6]*N)



library(BayesFactor)
(mat=cbind(c(r,r),c(n-r,n-r)))
bf=BayesFactor::proportionBF(r,n,r/n,posterior = TRUE,iterations=10000)
plot(bf)
head(bf)
infct=bf[,'p']*N
summary(infct)
BEST::plotPost(N*bf[,2],credMass = 0.95)

勢い5万以上のスレをメールでお知らせするサービス、実施中!!
憧れボディをGETしたい!その夢、ボニックで!

新着レスの表示

2ch勢いランキング アーカイブ 病院・医者板ランキング

凡例:

レス番

100 (赤) → 2つ以上レスが付いている
100 (紫) → 1つ以上レスが付いている

名前

名無しさん (青) → sage のレス
名無しさん (緑) → age のレス

ID

ID:xxxxxxx (赤) → 発言が3つ以上のID
ID:xxxxxxx (青) → 発言が2つ以上のID

このページは2ch勢いランキングが作成したアーカイブです。削除についてはこちら