TOP カテ一覧 スレ一覧 100〜終まで 2ch元 削除依頼
続・病院にやってきたカルト宗教
筑波東病院横山治之上野浩中村恭子
勤務歯科医のスレ
職員の尻を触ってみたい
─── 医者の性癖 ────
療養病床勤務医・地域包括ケア勤務医・老健勤務医が集うスレ☆Part.6
医師への贈り物について
【死亡退院】【患者大量に薬殺】筑波東病院【横山治之品川区大井慈恵医大卒業】
医者はオワコンなのか?
慶應義塾大学病院

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


1 :2018/10/30 〜 最終レス :2020/04/24
 
 内科認定医受験の最低限の知識、
 製薬会社の示してくる臨床データ、
 論文の考察、
 論文を書くときの正当性、
 というのが、臨床統計の今までの目的の大きい部分でしたが、
 
 AI=機械学習の基本も、結局は統計学と確率に支配されます。
 そういう雑多な話をするスレです。
 
※前スレ
臨床統計もおもしろいですよ、その1
https://egg.2ch.sc/test/read.cgi/hosp/1493809494/

2 :
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

3 :
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])

4 :
人格障害者の精神科医 古根高
http://egg.2ch.sc/test/read.cgi/hosp/1497760609/

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

病的な虚言癖と妄想癖の精神科医 古根高の病名を診断するスレ
https://egg.2ch.sc/test/read.cgi/hosp/1529634250/

5 :
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))

6 :
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)

7 :
pythonからRを経てHaskellに移植の予定。

8 :
>>7
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)

9 :
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は誤答とわかる

10 :
>>9
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

11 :
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)

12 :
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)
}

13 :
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)

14 :
韓国「強制徴用は22万人で被害者が死亡しても遺族が訴訟可能」 元徴用工4人に損害賠償支払い判決
https://fate.2ch.sc/test/read.cgi/seijinewsplus/1540976520/

15 :
先に1個めの宝を見つけるには短軸探索と長軸探索とどちらが有利かは宝の数によって変わるのでグラフにしてみた。
縦5横6のとき宝の数を1から30まで増やして長軸探索が先にみつける確率と短軸探索がさきにみつける確率の差を描いてみた。
http://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

グラフにしてみた。
http://i.imgur.com/PiL9xyH.png

16 :
各人にとっての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のコードはここに置いたので数値を変えて実行可能。

http://tpcg.io/Ph7TUQ

17 :
こういう解き方していると馬鹿になるなぁ、と
思いつつ便利なので使ってる。
Wolframで方程式を解かせて計算式をスクリプトに組み込むとかやってるな。結果は具体例でシミュレーションして確認。

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

>>311
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)]

18 :
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]

19 :
広島県の福山友愛病院で、
患者の病状と関係ない薬を大量に投与した。
しかも、意図的にです!



国は違うがドイツの場合

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

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

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


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


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

https://youtu.be/BnHYCZqyZKY

20 :
安倍総理も使っていて警察も使える医療大麻オイル
国連で今月解禁勧告が出されるという
解禁されれば憲法第98条によって大麻取締法が解禁され、店頭への商品陳列、広告表示等、医薬品としての処方ができるようになります
https://plaza.rakuten.co.jp/denkyupikaso/diary/201806090001/

21 :
医療法人潤和会を麻薬取締法違反の罪で略式起訴
https://seiyakuonlinenews.com/news/42856/

22 :
広島県の福山友愛病院で、
患者の病状と関係ない薬を大量に投与した。
しかも、意図的にです!


国は違うがドイツの場合

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

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

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


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


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

https://youtu.be/BnHYCZqyZKY

23 :
大麻取締法 22条の3に大麻を所持使用できるって書いてある

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

こりゃ解禁しなきゃな!

24 :
国試浪人の事務員は裏口バカだから
レスするだけ無駄である

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

ジョーカーを含む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になる計算式を書いてみ!

26 :
図形の問題って2ch(2Ch)じゃあ、投稿しにくいんだよなぁ。

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

https://rio2016.2ch.sc/test/read.cgi/math/1532824890/90

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

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

ド底辺シリツの馬鹿だらけってことかなぁ?

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

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

の計算式書いてみ!

28 :
臨床統計の問題です

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

この指標を元に医師板の主だった依存症患者を
1日のレス数を数えてピックアップしましょう

29 :
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.

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

これ答えてみ!

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

Take it or leave it !!


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

昨年入学者の留年者や退学者が0として、
大学が公式認定した裏口入学者が少なくとも今年は133人中50人、昨年が113人中19人ということになる。
裏口入学率の期待値、最頻値、およびその95%信頼区間を求めよ。

31 :
>>29

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

推敲歓迎!!

32 :
>>29

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

推敲歓迎!!

33 :
臨床統計の問題です

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

この指標を元に医師板の主だった依存症患者を
1日のレス数を数えてピックアップしましょう

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


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

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

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


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

2060507550845146798433160823128452341/202070319366191015160784900114134073344

になったが、これであっているか検算してくれ。

35 :
ここの国では硬貨は7種類流通しています
この7種類の硬貨を使って1円〜70円の70通りの支払いができます
ただし一度に使用できる硬貨は3枚以下(同じ硬貨複数使いは可)です
7種類の硬貨はそれぞれ何円だったのでしょうか?

36 :
>>35
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)
}
(続く)

37 :
>>36
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)
}
}
}
}
}
}
}
}

38 :
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]]

39 :
>>38
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]]

40 :
数学板に超初心者のコードを書いたら、達人が高速化してくれた。
プログラム解を毛嫌いする向きもあるけど、初心者のコードを改善してくれたり、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]

41 :
>>40
文字化けを修正

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]

42 :
>>39
-- 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]]

43 :
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)

44 :
## 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]
}

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

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)))

46 :
事務員さん

47 :
いくらド底辺シリツ医大卒の裏口バカでも
これくらいは計算できるだろ?

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

その結果の検証に100人を調査したら4人続けて裏口入学生であった、という。
この検証から裏口入学率が10%であるか否かを有意水準5%で検定せよ。

48 :
>>44
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)
}

49 :
トランプの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))

50 :
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)

51 :
コインを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')

52 :
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)

53 :
>>51
# 有理数表示したかったので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)

# ここで実行可能
# http://tpcg.io/rMOVCB

54 :
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)

55 :
>>53
泥タブだと普通にみえるが、Win10のPCだと コードのインデントがなくなって左揃えされてしまうなぁ。

56 :
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)

57 :
愛の妖精ぷりんてぃん

58 :
# 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()))

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

その結果の検証に100人を調査したら4人続けて裏口入学生であった、という。
この検証から裏口入学率が10%であるか否かを有意水準1%で検定せよ。

60 :
グリーンねえさん

61 :
>>59
## 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)

62 :
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]

63 :
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)


64 :
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)

65 :
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.

66 :
Hutanari Ti〇po

67 :
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.
ド底辺特殊シリツ医大卒は裏口入学の負い目から裏口馬鹿を暴く人間を偽医者扱いしたがる。

68 :
第一法則の英文の意図的な文法誤謬を指摘してみ!

69 :
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.

70 :
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.

71 :
(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
>

72 :
(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

73 :
実行速度

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

74 :
「お゙ぉおォおん、お゙ぉおォおんにいぃひゃぁん、大漁らったのぉおお?」
「ぁあああ あぉぁあああ あぉ、大漁らったよお゛お゛お゛ぉ」 「ぁあああ あぉぁぁ゛ぁ゛ぁぁ゛ぁ゛ぁぁ゛ぁ゛ぁあああ あぉぁぁ゛ぁ゛しゅごいぃのぉおおょぉぉぅぃぃっよぉおお゙いぃぃいぃぃ!、、にゃ、にゃにが、、ハァハァにゃにが捕れたのぉおお?」
乳首を舌れやしゃしく舐めにゃがらオレは答えたのぉおお
「…鯛とか、、、ヒラメがいぃっぱいぃ捕れたよお゛お゛お゛ぉ」
セリフを聞き、オジサンはびくんびくんと身体をひきちゅらせたのぉおお
「はっ!はぁぁ゛ぁ゛ぁぁ゛ぁ゛ぁぁ゛ぁ゛ぁあああ あぉんっ!イ、イサキは?イサキは、と、取れたのぉおお??」
「ぁあああ あぉぁあああ あぉ。れかいぃイサキが取れたよお゛お゛お゛ぉ。今年一番のぉおお大漁ら。」
「大漁っ!!イサキぃぃ!!お゙ぉおォおんにいぃひゃぁんかっこいぃぃぃっよぉおお゙いぃぃぃっよぉおお゙ぃぃぃいぃ ぃくううううう!」

75 :
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.

76 :
"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! "

77 :
import numpy as np
from fractions import Fraction
# 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])

78 :
RからPythonへの移植がようやく終わった。

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

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

http://tpcg.io/5xvZhU

79 :
"""
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)
"""

80 :
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 .

81 :
# 全体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)

82 :
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)

83 :
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.

84 :
次の課題はこれだな。

コインを100回投げて表が連続した最大数が10であったとき
このコインの表がでる確率の95%信頼区間はいくらか?

85 :
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.

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

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

英文コピペで荒らしているド底辺シリツ医大の裏口馬鹿には検算すらできんないだろうな。

87 :
>>86
呼び出す関数として、これが必要
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]
}

ここに上げておいた。
http://tpcg.io/kuNvWl

88 :
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.

89 :
恵方巻き

90 :
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.

91 :
>>86
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)
}

92 :
aiueo700

93 :
最大連続数を増やしてグラフ化
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')

94 :
幼稚な事務員

95 :
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

96 :
>>435
確率密度関数が左右対象でないから、
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])
}

97 :
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]
}

98 :
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の方が信頼区間幅が小さいのがみてとれる。

99 :
とりあえず>84のプログラムは完成。

100 :
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

あまり、差はないなぁ。

101 :
# 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)
}

確率密度関数を正弦波とか円周にしても計算できるはず。

102 :
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.

103 :
ド底辺シリツ裏口調査団が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から、平均値と標準偏差がもっと簡単に導出できれば正規分布近似計算できるのだが
まあ、プログラムが組めたから正規分布近似計算する必要はないな。

104 :
>>102
原文はこれな。

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

105 :
作 牧村みき

106 :
開脚率の期待値を計算してみた。

ゆるゆる女子大生の開脚率期待値: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)

107 :
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)

累積質量関数をグラフにすると
http://imagizer.imageshack.com/img924/9020/nxNiAP.jpg

108 :
NNN臨時放送

109 :
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.

110 :
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.

111 :
東京医大、本来合格者入学許可へ 今年の受験生50人

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

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

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

学年 第1学年 第2学年

在学者数 133 113

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

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

裏口入学率の期待値、最頻値、およびその95%信頼区間を求めよ。

112 :
>>111
これで求めた確率分布を事前分布として
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%信頼区間を述べよ。

113 :
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)

114 :
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 ) )
}

115 :
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')

116 :
>>115
> 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

で今年と去年で裏口率が有意に異なることになるのだが、裏口入学者を除籍処分しないようなシリツ医大の発表は盲信できないね。

117 :
あるタクシー会社のタクシーには1から通し番号がふられている。
タクシー会社の規模から保有タクシー台数は100台以下とわかっている。
この会社のタクシーを5台みかけた。最大の番号が60であった。
この会社の保有するタクシー台数の期待値を分数で答えよ

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

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

小数だと71.48850431950537

118 :
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)

119 :
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)
で済むが 分数では算出できず

120 :
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

121 :
> 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

122 :
いあいあ ふんぐるい むぐるうなふ くとぅるう るるいえ うがふなぐる ふたぐん

123 :
# 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)))

124 :
5030556272103101/70368744177664
71.48850431950537
93

結果は、同じだが分数計算が他の人の結果との照合に便利

125 :
エコエコアザラク エコエコザメラク
地獄のキュエーン

126 :
算数の問題です
円周率をサンスクリット語で暗唱せよ

127 :
コインを1000万回投げた。連続して表がでる確率が最も高いのは何回連続するときか?

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

数字を0と1を書いて数を数えて割り算するだけ。
3010300桁の数の集計する単純作業だから、おまえにもできるだろ?

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

http://fast-uploader.com/file/7097473535472/

129 :
いやー、昨日のセカンドはやられました。はめられました。
第一ロッター・・・・・小カタメ少なめ 第二ロッター・・・・・小カタメ
第三ロッター・・・・・小カタメ麺半分 第四ロッター(俺)・・・大

見事デスロットです。今思うと前の三人、確信犯だったと思う。
知り合い同士みたいだったし(てかよく見る奴らw)、第三ロッターのメガネが俺の食券見た後、前二人とひそひそ喋ってた。
『あいつ、ロット乱しにして恥かかしてやらない?w』こんな会話してたんだろうな・・・
いつも大を相手にしてる俺に嫉妬してんだろうな。。陰険なやり方だよ。正々堂々と二郎で勝負しろよ。

130 :
★★【盗聴盗撮犯罪者・井口千明(東京都葛飾区青戸6−23−17)の激白】★★

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

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


⊂⌒ヽ            γ⌒⊃
  \ \  彡 ⌒ ミ   / /
    \ \_<(゚)д(゚)>_./ /  食糞ソムリエ・高添沼田の親父どえーす 一家そろって低学歴どえーす 孫も例外なく阿呆どえーす
      \ \_∩_/ /    東京都葛飾区青戸6−26−6に住んどりマッスル
      /(  (::)(::)  )\    盗聴盗撮つきまとい嫌がらせの犯罪をしておりマッスル
    ⊂_/ ヽ_,*、_ノ \_⊃      くれぐれも警察に密告しないでくらはい お願いしまふ
 ̄][ ̄ ̄]            [ ̄ ̄][ ̄
 ̄ ̄][ ̄]            [ ̄][ ̄ ̄
 ̄][ ̄ ̄]            [ ̄ ̄][ ̄
 ̄ ̄][ ̄]            [ ̄][ ̄ ̄
 ̄][ ̄ ̄]            [ ̄ ̄][ ̄
"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~

131 :
# 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

132 :
#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;
}

133 :
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)


134 :
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.

135 :
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.

136 :
臨床問題です
事務員のアスペ指数を計測せよ

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

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

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

きちんと検算してから、臨床統計スレに書き込めよ。

138 :
誰からも相手にされない ド底辺事務員

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

他人のコード読むのは勉強になるね。

140 :
この問題、俺にはプログラミング解が精いっぱい。
解析解出せる頭脳は尊敬するな。


N枚のコインを投げて表が連続する確率が最も大きい回数をsとする。
例:N=10でs=2、N=15でs=3
(1) N=777のときのsを述べよ。
(2)s=7となるNの範囲を述べよ。

141 :
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)
}
"

142 :
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="留年確率")

143 :
binom::binom.confint(sum(y),sum(N))

144 :
>>117
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)

145 :
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)

146 :
"マラソン大会の選手に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)

これを検証するシミュレーションプログラムを作れ、というのが課題。

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

# 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

148 :
最大値でなく平均値が与えられたときの参加人数の推定、

"マラソン大会の選手に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))])) # 最頻値

149 :
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

150 :
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.

151 :
このスレは事務員が日がな一日妄想を垂れ流し
見物人たちがそれを見てフルボッコにするスレである

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

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

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.
ド底辺特殊シリツ医大卒は裏口入学の負い目から裏口馬鹿を暴く人間を偽医者扱いしたがる。

153 :
平均値を「四捨五入」するか、しないかを指定できるようにして
平均値が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')

154 :
ド底辺シリツ医大のある学年にひとりずつ裏口入学登録証があることが判明したがその数は公表されていないとする。
ある裏口入学調査員が無作為に10枚選んで番号を記録して元に戻した。
別の裏口入学調査員が無作為に20枚選んで番号を記録してして元に戻した。
二人の調査官の記録した番号を照合すると3人分の番号が一致していた。
この情報からこの学年の裏口入学者数の95%信頼区間を求めよ。

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

156 :
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.

157 :
二郎をすすりつつ裏口事務員をさわさわと触る
「お、おにいちゃん、大漁だった?」
「ああ、大漁だったよ」
「あぁぁぁあぁすごいいいぃいぃ!、、な、なにが、、ハァハァなにが捕れたの?」
焼豚を舌でやさしく舐めながら国試浪人は答えた
「…鯛とか、、、ヒラメがいっぱい捕れたよ」
セリフを聞き、オジサンはびくんびくんと身体をひきつらせた
「はっ!はぁぁぁあんっ!イ、イサキは?イサキは、と、取れたの??」
ド底辺事務員をしごく
「ああ。でかいイサキが取れたよ。今年一番の大漁だ。」
「大漁っ!!イサキぃぃ!!おにいちゃんかっこいいいいぃぃぃい ぃくううううう!」

158 :
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.

159 :
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!"

160 :
ここは くるくるぱー アスペ 事務員が
ナゾナゾを出したり アプリ翻訳したインチキ英語で
自作自演したりするスレです

161 :
>155の計算結果は最頻値と期待値が大幅に乖離するので
計算に自信が持てずシミュレーションとの合致でようやく納得。
数学板に貼ったら2時間で期待値のHaskellでの算出値のレスが来た。それで信頼区間も確信を持って計算できた。
確率密度はこんな感じなので期待値と最頻値がずれるわけだな。
http://i.imgur.com/paJnhr9.png

162 :
>>160
>155の算出式書けばド底辺シリツ医大卒でも基礎学力があると示せるのに裏口馬鹿を実証してどうすんの?
Rのスクリプトすら読めない裏口バカなんだろ?

163 :
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

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

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)

165 :
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.

166 :
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.

167 :
医師国家試験にこういうの問題を出してシリツ医大の裏口馬鹿を排除すればいいのにね。

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

168 :
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.

169 :
ド底辺事務員の今日のおかず

くいこみ戦隊ブルマちゃん

170 :
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

171 :
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]))
}

172 :
実際こんな職員が病院にいたら大変だね

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

この事務員も同レベルのカスなんだろうな

173 :
 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;
}

174 :
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))
}
}
}

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

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

875 名前:卵の名無しさん[sage] 投稿日:2018/11/14(水) 20:29:50.55 ID:lTkyjX2F
>>874
俺は肝弯より脾損傷の方がやだね。
開腹手術での受動時の経験と透視でのファイバーの動きを見る機会があるとこんなに可動性あったっけとか思う。
幸い脾損傷の経験はないけど、検査後に左肩への放散痛があったら疑わなくてはと思っている。

176 :
手技の議論だけじゃなくて、こういう計算もできる。
せっかく、一般解がだせるようにプログラムまで組んだやったんだがなぁ。


【現役医師】専門医資格取得について、どうお考えですか? 第2章
https://egg.2ch.sc/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で定速走行する。

何時以降の病態悪化は診療所の車を使わずに救急車の到着を待つ方が病院に早く着くか?

177 :
>>174
配列の要素ごとの演算をしてくれるRが使い勝手がいいなぁ。
シミュレーターとして使うのは遅いけど。

178 :
>>172
カスとは
>167の答も出せない
おまえのことだよ。

179 :
医師なら事務員というワードには反応しないよねW

180 :
>>179
ド底辺シリツというのに反応する椰子はw

181 :
>>179
https://egg.2ch.sc/test/read.cgi/hosp/1499746033/875
とそれへのレスみて事務員だと思うならお前の頭は相当悪いぞ。
あぁ、ド底辺シリツ医大卒の裏口バカだよなぁ?
>167に即答してみ。裏口入学じゃなきゃできるだろ。

182 :
>>174
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

183 :
今日も事務員は発狂中

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






とか書くと
また自作自演しまくるんだろうなー

184 :
>>183
あらら、>167に即答できないって相当頭が悪いぞ。
裏口入学??

185 :
専門医スレで誰も正当できなかった>176の方に答えてくれてもいいぞ、国立卒ならこれくらいの四則演算はできるだろ?

186 :
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.

187 :
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)
}

188 :
>>186
which deserves to be called a bona fide moron は何故、whoでなくて文法破格のwhichが用いられているか、その理由を述べてみ!

189 :
>>187
一応完成

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))

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

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


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

再捕獲法での個体数推定の限界だな。

191 :
池の鯉を網で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)

192 :
>>191
これでモード値が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)
}

193 :
>>183
鉄則を思い出しましょう

算数事務員はド底辺の裏口バカだから
対話するだけムダである

194 :
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))

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

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

即答できないって、馬鹿なんだね。

196 :
専門医スレで誰も正当できなかった>176の方に答えてくれてもいいぞ、国立卒ならこれくらいの四則演算はできるだろ?

197 :
正当 WWW

発狂バカが やりがちの 漢字誤変換 WWW

198 :
>>197
そういう指摘する暇があれば即答すればいいのに
やっぱり馬鹿なのね。

199 :
覆面算の □/□ * □/□ = □□/□ 
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

200 :
タイムアウトせずにon lineでも動かせた。

http://tpcg.io/dbtTnK

201 :
これは最大値・最小値を求めてから組み合わせを出すことになるから時間がかかるなぁ。

-- 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)
-}

202 :
バックグラウンで放置してたら計算してくれていた。

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]]

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

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

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

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

204 :
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.

205 :
>>203

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


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

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

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

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

http://tpcg.io/TBD7MO

206 :
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

207 :
僕らの おち○ぽ

208 :
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.

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

負の二項分布で計算するとこっちはモード値が70の1個なんだなぁ。

210 :
>>209
このときの推測数の信頼区間の算出が次の課題だな。
3匹目印鯉捕獲目標が45匹目で達成されたときと比較したい。

211 :
>>210
DRAFT

212 :
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)

213 :
非対称分布の信頼区間算出にパッケージないのかな?

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)
}

214 :
>>210
> 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

215 :
> 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

負の二項分布でも超幾何分布のときとさほど変わらないなぁ

216 :
さて来週の3本は

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

でお送りしま~す、んっわっほっぅ

217 :
どうせ助からない(死ぬ奴)の集まりかよ 笑

218 :
数学板のこれ面白かった。情報量とか調べながら解答してきた。

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)の答えを出すまでの計算過程を教えていただきたいです。
よろしくお願い致します。

219 :
数時間潰しての結果がこれ、わずか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

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

{-
<問題>
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]

221 :
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.

222 :
# 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)))
}
# 相互情報量は不確実性(情報エントロピー)の減少量とみなすことができます

223 :
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

224 :
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

225 :
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.

226 :
事務員で遊ぶのも飽きてきたし
そろそろコミケの原稿を書き始めなきゃなぁ

227 :
中学入試を難問化した問題で遊んでみる。

池の鯉を網で56匹すくいました。
すくった56匹に目印をつけ、池にもどしました。
次の日に鯉45匹をすくったところ、36匹に目印がついていました。
(1)池の鯉の鯉の数の最尤値を述べよ(2つある)。
(2)最尤値が2つあるのは何匹の目印鯉が捕獲されたときか述べよ。

228 :
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.

229 :
>>223
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]

230 :
>>227
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)
}

231 :
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)
}

232 :
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

233 :
>>227
(2)の答は4個あるな。

234 :
>>224
プログラミンの練習に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))))

235 :
>>234
エラー処理はなしにして無理矢理、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]))))

236 :
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

237 :
2^3はpythonで1を返す
ビット演算子(~, &, |, ^, <<, >>)
2**3 か pow(2,3)で冪乗

238 :
練習に、これを移植したいなぁ。
http://www.geocities.jp/m_hiroi/puzzle/water_jug.html

239 :
すでにやった人がいた:P

http://dev.ariel-networks.com/Members/ohyama/haskell-6c345dee3057554f984c309289e3304f-with-perl-81ea7b547de8/

240 :
>>238
数が小さいので頭で考えると (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)]

241 :
>>240

問題はこれ

問題 : 4 リットルと 3 リットルの容器を使って 2 リットルの水を測るにはどうすればいい?

242 :
こっちの方が断然、難関。

油分け算

[問題] 油分け算

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

容器 B と C のサイズが 9 リットルと 5 リットルの場合の手順は?

243 :
>>239
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

244 :
>>239
これは可能な組み合わせを列挙しているだけで必ずしも手順をしめすプログラムじゃないな。

245 :
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

246 :
>>240
[(0,0),(0,3),(3,0),(3,3),(4,2),(0,2)] というのが数学板で返された

247 :
>>246 は国試に23回も落ちた挙句
婚活にも失敗してる素人童貞で
くるくるぱーの裏口バカに
なっちゃってるのらぁあぁぁ
Fラン事務員の濃ゆぅぅい生ガキ汁
ド底辺の臭いが落ちないよぉ
んほおぉぉぉおぉぉ

248 :
>>242
(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)
これでできるけど、最短かどうかは自信がないなぁ。

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

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

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

あれかな?

あれだよね?

あれ

あれ









250 :
[問題]
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]

251 :
ネットで口汚くあちこちのスレを荒らしている国試浪人の事務員だが
この世に彼奴を下回るカスがいるだろうか
いや居ない
リアルではだれも口にしないが、みな思っていることだ

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

よっぽど妬ましいんだろうなW

252 :
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)
}

253 :
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)))
}

254 :
http://ailaby.com/dfs_bfs/#id3

255 :
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)

256 :
https://jprogramer.com/catealgo/999

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

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

879 卵の名無しさん sage 2018/11/15(木) 07:18:18.94 ID:LT687Ilf
>>878
>875は脾弯越えの操作でpullする時の話。
http://i.imgur.com/ztM8yOL.png

んで、あんたどこ卒?
ド底辺シリツ医大へ裏口入学なんだろ?
中学入試を少し難問化した>227に答えてみ!

258 :
>>251
国立卒はちゃんとわかってる。

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

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

>https://egg.2ch.sc/test/read.cgi/hosp/1537519628/101-102
>https://egg.2ch.sc/test/read.cgi/hosp/1537519628/844-853
ID:RFPm1BdQ

>https://egg.2ch.sc/test/read.cgi/hosp/1537519628/869
>https://egg.2ch.sc/test/read.cgi/hosp/1537519628/874-875
>https://egg.2ch.sc/test/read.cgi/hosp/1537519628/874-880
>https://egg.2ch.sc/test/read.cgi/hosp/1537519628/882
ID:liUvUPgn

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

3.リアルでは皆思ってるだけで口に出してないだけ
http://ishikisoku.com/wp-content/uploads/2016/12/SQIR26V.jpg

259 :
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.

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

ド底辺シリツ裏口調査団が100人を順次調査した。
裏口判明人数をそのまま公表はヤバすぎる結果であったため、
連続して裏口がみつかった最大数は4人であったとだけ公表した。
公表結果が正しいとして裏口入学人数の期待値、最頻値、及び95%信頼区間を述べよ。

261 :
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)

262 :
>>251
んで、あんたどこ卒?

263 :
>>261
探索経路を記録するのと
移転で過去の状態に戻るのをカウントから外す必要があるなぁ。

264 :
ネットで口汚くあちこちのスレを荒らしている国試浪人の事務員だが
この世に彼奴を下回るカスがいるだろうか
いや居ない
リアルではだれも口にしないが、みな思っていることだ

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

よっぽど妬ましいんだろうなW

265 :
油分け算の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)
}

266 :
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)
}

267 :
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)
}

268 :
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

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

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

270 :
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

271 :
ようやくデバッグできた。

> 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

272 :
目的のノードを見つけたら終了する仕様だから、最短かどうかはわからないなぁ。

273 :
仕事しないとなぁ

274 :
>>264
>>251
んで、あんたどこ卒?
きっと凄いとこ出てますね、と言われるぞw

275 :
時給の良い仕事ないかなぁ?

276 :
ハローワークで警備の仕事があるなぁ。

277 :
# 問題 : 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

278 :
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.

279 :
人間関係のない時給の良い仕事はないかなぁ?いじめられるからなぁ

280 :
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.

281 :
仕事ください

282 :
なんの取り柄もない私に仕事をください

283 :
なんかの資格があったらなぁ 仕事がないなぁ 今になって悔やんでしまう

284 :
金がない!

285 :
もっと金になる勉強をすべきだった 仕事がないなぁ

286 :
このまま 社会に出ずに 人生が終わってしまうのか?なんだったんだろう俺の人生は?

287 :
明日 また ハローワーク行こう!

288 :
>268-269のバグを指摘できていたら見直すのだが
底辺学力でできるのは>197のような漢字の誤変換だけ。

289 :
ド底辺スレの定期上げ

290 :
じゃ、定期あげ

291 :
>>277
幅優先探索だとこんな感じだな。

.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
#

292 :
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.

293 :
非医師の人たちへむけて 今日の1曲

愛国戦隊大日本

294 :
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)

295 :
>>294
これへの回答

あるデータ群に対して、確率密度関数のパラメータをフィッティングさせる方法ってないですか?
ちなみに、フィッティングさせたいのはレブィフライト確率密度関数です。

296 :
量子力学は?www

297 :
ボーズ粒子の実態は確率

298 :
国試諦めたんだねw

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

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

875 名前:卵の名無しさん[sage] 投稿日:2018/11/14(水) 20:29:50.55 ID:lTkyjX2F
>>874
俺は肝弯より脾損傷の方がやだね。
開腹手術での受動時の経験と透視でのファイバーの動きを見る機会があるとこんなに可動性あったっけとか思う。
幸い脾損傷の経験はないけど、検査後に左肩への放散痛があったら疑わなくてはと思っている。

300 :
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.

301 :
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

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

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

裏口入学医師の免許剥奪を!の国民運動の先頭に立てばよいぞ。
僕も裏口入学とか、言ってたら信頼の回復はない。

303 :
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.

304 :
main = print $ length [(x,y)|x<-[-100..100],y<-[-100..100],7*x+3*y==5,abs x + abs y <= 100]

305 :
統計の話をしよう!!
サルを何千万匹殺しても無問題!!ただし、共産主義の香りづけをすれば

306 :
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) + ")")

307 :
>>306 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) + ")")

308 :
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]))

309 :
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)

310 :
# 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)

311 :
# ある医院に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

理論値通りだな。

312 :
http://www.f.waseda.jp/sakas/R/ROR/orQueue.html

313 :
1時間に平均値5人の患者がくる医院で
次の患者がくるまでの時間が10分以内である確率と
30分以上である確率はいくらか?

314 :
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.

315 :
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')

316 :
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)')

317 :
このスレの自称医者のほんまもん医師確率は?

検索した知識で医者を騙りMath
http://egg.2ch.sc/test/read.cgi/hosp/1541780622/

318 :
こういうのを見ればわかるだろうに

https://egg.2ch.sc/test/read.cgi/hosp/1499746033/879

>>878
>875は脾弯越えの操作でpullする時の話。
http://i.imgur.com/ztM8yOL.png

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

1時間に平均値5人の患者がくる医院で
次の患者がくるまでの時間が10分以内である確率と
30分以上である確率はいくらか?

319 :
>>316

これ用のスクリプト

18時から翌朝9時までの15時間の当直帯に平均5回のコールがある。当直室にデリヘル90分コースで呼んだとすると
デリヘル滞在中にコールされる確率はいくらか?

320 :
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)

321 :
救急車搬送数が日勤の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)]

322 :
>>321
日勤と夜勤でお看取り件数に差があるかも検定できるな。

323 :
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.

324 :
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)

325 :
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()

326 :
>>325
サッカーの勝敗確率

327 :
>>326 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)
}

328 :
ポイント乞食ご用達の楽天銀行に貯金していて、
楽天に口座凍結されて無一文になった世田谷のS君 元気??

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

慶応のOBらが泣いてるよww

329 :
マルコフの確認
(pexp(2+4,1/3)-pexp(2,1/3))/(1-pexp(2,1/3))
pexp(4,1/3)

330 :
k=15
a=20
b=30
(pexp(a+b,1/k)-pexp(a,1/k))/(1-pexp(a,1/k))
pexp(b,1/k)

331 :
k=15
a=20
b=30
y=function(x) 1-exp(-x/k)
(y(a+b)-y(a))/(1-y(a))
y(b)

332 :
>>327
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)
}

333 :
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))
}

334 :
>>333
if(A==B) return(c(c(Upset=0,Ordinal=0,Draw=1)))
は不要だな。

335 :
サッカーの特典はポアソン分布に従うとされている。

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

336 :
>>335
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

ほぼ同じした結果がでて、気分が( ・∀・)イイ!!

337 :
λ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)

338 :
>>331
答えから、指数分布のマルコフ性が導き出されていることを確認

339 :
# 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)

340 :
# 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)

341 :
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.

342 :
数学板の質問スレに俺でも答えられる問題がでるとホッとするな。
簡単すぎて誰も答えないからというのもあるが。

343 :
時刻表から平均待ち時間を算出する。

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)

344 :
ちっちっ×××× ちっち××××
××××ち××××
へいたんな×× おうとつない
×××だけぷっくりしてるの
あまいあじがするから××てほしいな?
にゃにゃにゃにゃにゃにゃにゃん☆

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

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

ちっちっ×××× ちっち××××
××××ち××××
すべすべの×× おおきくない
けんこうにすっごくいいんだよ
ゆびさきで××××ってしてほしいな? 👀
Rock54: Caution(BBR-MD5:1341adc37120578f18dba9451e6c8c3b)


345 :
>>343
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

346 :
>>343
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 ))

347 :
>>343
問題はこれ

東京駅からのぞみ号で朝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

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

ある駅のホームの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)

349 :
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.

350 :
>>348
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)

351 :
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))}

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

352 :
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))}

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)
}

353 :
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))

354 :
演習問題
&#61550; 問題
&#61550; 電話回線のチケット予約システムがあり、その窓口数は3であ

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

このとき、
&#61550; 話中である確率を求めなさい
&#61550; 話中となる確率を1%未満とするには、窓口はいくつ必要です
か?

355 :
>>354 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))

356 :
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))

357 :
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))

358 :
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)
}

359 :
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)

360 :
”お待たせしません”を謳い文句にした真面耶馬医院で
患者の来院は平均して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)

361 :
問題(第1種情報処理技術者試験・平成元年度春期午前問17を改題)

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

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

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

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

これに 
設問4  「平均待ち時間」を10分以下にするには同じ診察効率の医師が何人に必要か?

362 :
# ある医院では、患者が平均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)

363 :
# 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]

364 :
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.

365 :
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)

366 :
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.

367 :
レジが1台ある。客の到着が1時間あたり平均12人であり、
レジの所要時間が平均3分のとき,次の値を求めてみよう。
?到着したとき,すぐにサービスが受けられる確率
?系の中にいる人の平均人数
?サービスを待っている人の平均人数
?到着してからサービスを受けて去るまでの平均時間

?到着してからサービスを受けるまでの平均待ち時間
?客の到着が2倍の平均24人になった。到着してからサービスを受けて去るまでの平均時間を変えないようにするには
レジの平均サービス時間を何分にすればよいか?求めてみよう。

368 :
筆算は面倒。数値を変えても算出できるようにした。

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

369 :
# 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)

370 :
音楽の問題です

アヘ顔ダブルPEA〜〜〜CE
v(゜∀。)v

371 :
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)

372 :
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')

373 :
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

374 :
# ある医院に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

375 :
# 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)

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

https://www.tutorialspoint.com/tpcg.php?p=7psmrQ

377 :
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.

378 :
待ち行列理論の公式って
待ち行列の長さが変わらない定常状態での計算値だなぁ。

こういう設定に適応していいのか疑問があるな。
# 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

379 :
シミュレーターを改良

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

380 :
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))}

381 :
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)

382 :
来院数がポアソン分布(来院間隔は指数分布)、
診療時間はそれまでの患者の診療時間に影響されない(マルコフ性とか無記憶性と呼ばれる)ので指数分布
と仮定して、1時間に5人受診、診療時間は10分を平均値として受診数を40人としてシミュレーションすると
こんなにばらついた。
https://i.imgur.com/2HSJiRL.png
https://i.imgur.com/aG4ySWl.png
待ち時間行列理論でクリニックの待ち時間計算すると現実と大きく乖離すると思える。

383 :
来院数がポアソン分布(来院間隔は指数分布)、
診療時間はそれまでの患者の診療時間に影響されない(マルコフ性とか無記憶性と呼ばれる)ので指数分布
と仮定して、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

384 :
受診者数と平均待ち時間をシミュレーションしてみた。
受診者数が増えれば待ち行列時間の理論値50分に収束していくようだ。

https://i.imgur.com/iFN6eAN.png

385 :
sim = function(){
x=cumsum(rexp(5,5/15))
x[4] < x[3]+1
}
mean(replicate(1e5,sim()))

pexp(1,5/15)

386 :
>>384
定常状態での理論値
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

387 :
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.

388 :
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

389 :
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)

390 :
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')

391 :
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

392 :
数式を追うだけだと身につかないからプログラムに入力して自分でグラフを書いてみると理解が捗る。
自分がどこができていないもよく分かる。必要な計算ができないとグラフが完成できないから。
プログラムしておくとあとで数値を変えて再利用できるのが( ・∀・)イイ!!

https://i.imgur.com/P3jWTLx.png

393 :
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.

394 :
#
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 # 午後の部

395 :
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)) # 午後の待ち時間

396 :
午前の受付9時から12時30分まで午後の受付15時30分から19時までのクリニックに
図のような二峰性の分布で100人が来院するとする。
https://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分として待ち時間をグラフ化。
https://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

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

これやってみた。
ポアソン分布や指数分布を前提とせず、実際のヒストグラムから待ち時間のシミュレーション。
午前の受付9時から12時30分まで午後の受付15時30分から19時までのクリニックに
図のような二峰性の分布で100人が来院するとする。
https://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分として待ち時間をグラフ化。
https://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


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

診療終了23時w

398 :
午後から医師は二人に増やすとどうなるかシミュレーションしてみた。
診察時間は一人平均8分の設定は同じ。

https://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時!

399 :
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.

400 :
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')

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

https://i.imgur.com/1v72ST5.png

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

これにでも答えてみ!

あるド底辺裏口シリツ医大のある学年に100人の学生がいる。
100人の学生は全員裏口入学である。
裏口入学を自覚したら翌日に退学しなければならない。
学生は自分以外の学生が裏口入学であるとことは全員知っているが自分が裏口入学であることは知らない。
教授が全員の前で「この学年には少なくとも一人が裏口入学している」と発言した。
この後、どうなるかを述べよ。

403 :
この季節はいつも風邪気味になるなぁ
外来から貰ってんのかな
冬コミが近いのに原稿がまだできとらんが
体調管理はしっかりしていかんとなぁ
ジャンルはFTで良いかなぁ
ガチ百合にすっかなぁ

404 :
便秘薬をいろいろ試しているが
どれが良いかなぁ

405 :
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

406 :
おい、ド底辺。

1兆の階乗は末尾に0が
249999999997
並ぶと計算されたが、あってるか?
検算しておいてくれ。

407 :
今年の納税額は五千万超えるなぁ

冬コミはFTCW の新作出るかなぁ?

408 :
ふ◯◯◯ち◯◯れ◯◯◯◯

409 :
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.

410 :
あるド底辺裏口シリツ医大のある学年に100人の学生がいる。
100人の学生は全員裏口入学である。
裏口入学を自覚したら翌日に退学しなければならない。
学生は自分以外の学生が裏口入学であるとことは全員知っているが自分が裏口入学であることは知らない。
教授が全員の前で「この学年には少なくとも一人が裏口入学している」と発言した。
この後、どうなるかを述べよ。

411 :
# 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)

412 :
薬局の店舗数を増やそうかなぁ

413 :
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])

414 :
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))

415 :
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.

416 :
互いに相関のある5項目くらいのスコアの合計点から疾患の発生を予測するカットオフ値を求めました

単純に合計点した時の予測能は不十分であったため
主成分分析をして各主成分を線型結合して主成分スコアを出す時に、AUC値が最大になるように線型結合する係数に重み付けするのは一般的に大丈夫かしら?

417 :
# 一般化、全員嘘つきも可、重複する答も可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))

418 :
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

419 :
>>416
>互いに相関のある
なら変数減らせるんじゃね?
AUC?Area Under the Curve?
AICじゃなくて?

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

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

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

AUCはarea under curveです

421 :
>>420
統計テキストの演習問題によくあるから一般的だろね。
三角形の周囲長のデータから線形回帰で面積を出すというような意味のないことやってるかも。

422 :
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.

423 :
>>421
次数が減るのがメリットかなと…

424 :
>>423
長方形の周囲長者から面積をだすのに
データが100個あればラグランジェの補完式で100次元式で完璧に当てはめることができる。
フィボナッチ数列も同じ。

425 :
象の体表面積の計算に有用な数値ってどこだろ?
身長体重鼻の長さ耳の大きさ?

426 :
スリーサイズと身長体重の相関とか某女子大の講師が書いてたなw

427 :
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)

428 :
>>420
AICとかWAICで比較する方法があったはず。

429 :
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)

430 :
シリツ医の使命は裏口入学撲滅国民運動の先頭に立つことだよ。

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

裏口入学医師の免許剥奪を!の国民運動の先頭に立てばよいぞ。
僕も裏口入学とか、言ってたら信頼の回復はない。

431 :
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)

432 :
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)

433 :
> 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

434 :
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)

435 :
しゅごーいAWP

436 :
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)

437 :
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.

438 :
>>436
個数を表示するように改造

# 一般化、全員嘘つきも可、重複する答も可
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)

439 :
バスの到着間隔が平均30分の指数分布であるEバスと
平均30分の一様分布であるUバスではどちらが待ち時間の期待値が小さいか?

440 :
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.

441 :
-- 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]) [[]]

442 :
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.

443 :
# 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),]

444 :
正直者は嘘をつかないが
嘘つきは嘘をつくこともつかないこともある。

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

5人のうち、正直者と嘘つきは誰か?
可能性のある組合せをすべて示せ。

445 :
>>444
嘘つきが必ず嘘をつく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))
}

446 :
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)),]

447 :
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)),]

448 :
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')

449 :
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.

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


原文はこれな。

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

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

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

>https://egg.2ch.sc/test/read.cgi/hosp/1537519628/101-102
>https://egg.2ch.sc/test/read.cgi/hosp/1537519628/844-853
ID:RFPm1BdQ

>https://egg.2ch.sc/test/read.cgi/hosp/1537519628/869
>https://egg.2ch.sc/test/read.cgi/hosp/1537519628/874-875
>https://egg.2ch.sc/test/read.cgi/hosp/1537519628/874-880
>https://egg.2ch.sc/test/read.cgi/hosp/1537519628/882
ID:liUvUPgn

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

3.リアルでは皆思ってるだけで口に出してないだけ
http://ishikisoku.com/wp-content/uploads/2016/12/SQIR26V.jpg

452 :
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

453 :
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.

454 :
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)

455 :
https://www.tutorialspoint.com/execute_r_online.php?9gkFGD

https://i.imgur.com/72yk8Wk.jpg
https://i.imgur.com/uC9tNaW.jpg

456 :
呪文:「ド底辺シリツ医大が悪いのではない、本人の頭が悪いんだ」を唱えると甲状腺機能が正常化するという統計処理の捏造をやってみる。

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

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

ここで問題、この統計処理のどこが誤っているか?

457 :
アタマわるわる〜

458 :
>>457
頭が悪いのは誤りを指摘できないお前の頭な。

459 :
野獣先輩、オナシャス
アタマわるわるわ〜るわる〜
アタマわるわるわ〜るわる〜
あそれっ
アタマわるわるわ〜るわる〜
アタマわるわるわ〜るわる〜
あよいしょっ
アタマわるわるわ〜るわる〜
アタマわるわるわ〜るわる〜
あくしろよ
アタマわるわるわ〜るわる〜
アタマわるわるわ〜るわる〜
endless

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

平均0、分散1の正規分布の95%信頼区域は[-1.96,1.96]で区域長は約3.92である。
平均0、分散1の一様分布の95%信頼区域の区域長さはいくらか?

461 :
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.

462 :
おいこら
あっちでまた非医師仲間のコンプが湧いてるぞ
さっさと引き取れや

463 :
回答付きでレスできない椰子ってシリツ卒なんだろうな。

464 :
お前は今までに吐いたゲロの回数を覚えているのか?

465 :
>>464
ゲロの回数の従う事前分布をどう想定する?

466 :
ある女医が一日に5回屁をこいたとする。
屁の回数はポアソン分布と仮定して
この女医の一日にこく屁の回数の95%信頼区間を述べよ、
という問題にできるぞ。
答えてみ!

467 :
事前分布を想定して現実のデータからその分布の最適分布を算出する。当然、区間推定にある。
relocation of probability dustrubution
これがベイズ統計の基本的な考え方だよ。
上記の女医の屁の回数も区間推定できる。

468 :
ゲロの回数だとゼロ過剰ポアソン分布の方がいいだろうな。

469 :
http://kusanagi.hatenablog.jp/entry/2017/09/19/210333

470 :
臨床問題です
サブとアドンとBLの関連を原稿用紙30枚以上で考察せよ

471 :
>>470
んで、女医の放屁数は出せた?

472 :
>>470
問題の意味がわからないから詳述してくれ。
女医の屁の方は問題設定が明確だぞ。

473 :
ゲロの回数の事前分布なら
Zero-Inflated Negative Binomial Distribution
の方がいいかな。

Rにパッケージがあったような。
ポアソンよりパラメータが多くなるな。

474 :
VGAMに含まれてた。

https://www.rdocumentation.org/packages/VGAM/versions/0.7-7/topics/Zinb

475 :
今日はこれで遊ぶかな。

https://stats.idre.ucla.edu/r/dae/zip/

476 :
問題に回答できないとは
さては中卒ニートだな

477 :
>>476
>>470
問題の意味がわからないから詳述してくれ。
女医の屁の方は問題設定が明確だぞ。

478 :
こんな感じでゼロ過剰ポアソン分布モデルがつくれるな。

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年間に吐くゲロの回数の平均値を出してみ!

479 :
女医の放屁の方はポアソン分布でよさそうだな。

95%信頼区間を計算できたか?

480 :
自分で出した算数クイズは解けても
考察を要する問題は中卒には難しいようだな
解きやすいように少し簡単な問題にしてやろう

さて臨床問題です
ガチユリとフタナリの相関性について原稿用紙30枚以上で考察せよ

481 :
>>480
統計用語じゃないから、解説してくれ。

482 :
問題文が理解できない問題には答えられない。
当たり前のこと。
数学すれでも群論の話がでると俺は蚊帳の外。
図形とか確率なら理解できるから、取り組むよ。

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

ある女医が一日に5回屁をこいたとする。
屁の回数はポアソン分布と仮定して
この女医の一日にこく屁の回数の95%信頼区間を述べよ。

483 :
インフルエンザ迅速検査キットの感度が80%、偽陽性率1%とする。

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

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

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

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

という、検査前の有病率がいくら以上であればこの患者に抗ウイルス薬を処方することになるか?

484 :
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)

485 :
インフルエンザの流行期ならなら有熱で受診した患者がインフルエンザである確率分布はこんな感じ(青のヒストグラム)

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

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

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

平均値約20%、インフルエンザである確率が10%以上である可能性は74%と説明できる。

486 :
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)

487 :
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)

488 :
この程度の問題文が理解できないとは
さては中卒ニートだな

489 :
>>488
自分の出した問題も説明できないとはド底辺シリツか?

490 :
>>488
知らんことには回答できない。
答えてほしけりゃ問題を敷衍して書けよ。
統計ネタなら答えるぞ。

491 :
問題が理解すらできないとは
さては中卒ニートだな

492 :
>>491
>>488
自分の出した問題も説明できないとはド底辺シリツか?

493 :
試験で解答できなきゃ零点だ

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

ある女医が一日に5回屁をこいたとする。
屁の回数はポアソン分布と仮定して
この女医の一日にこく屁の回数の95%信頼区間を述べよ、

495 :
>>493
原稿用紙30枚以上の模範解答書いてみ!
はよ、はよ!

496 :
捏造データでお遊んでろ。

497 :
>>496
ベイズ統計における事前確認は捏造ではなく
無情報もしくは弱情報分布である。
日本人女性の平均身長を1〜2mの分布とする
というのが弱情報分布。

498 :
事前分布の分散は逆ガンマより半コーシーを使うのがGelman流ね。

499 :
事前確率分布を設定することでこういう計算も可能となる。
オマエの知識レベルじゃ無理だろうけど。

インフルエンザの迅速キットは特異度は高いが感度は検査時期によって左右される。
ある診断キットが開発されたとする。
このキットは特異度は99%と良好であったが、
感度については確かな情報がない。
事前確率分布として一様分布を仮定する。
50人を無作為抽出してこの診断キットで診断したところ40人が陽性であった。
この母集団の有病率の期待値と95%CIはいくらか?
またこの診断キットの感度の期待値と95%CIはいくらか

500 :
1年:進級失敗10人、うち1人放校
2年:進級失敗16人、放校なし
3年:進級失敗34人、うち放校9人
4年:進級失敗9人、うち放校2人
5年:進級失敗10人、うち放校1人
6年:卒業失敗26人、うち放校1人

https://mao.2ch.sc/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)

https://i.imgur.com/TptfCA8.jpg

501 :
算数の問題です
エリンギとマツタケの使用頻度を検証すると
あぁん いくいく いっひゃうのらぁ

502 :
このページ便利だな。

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

http://dwoll.de/rexrepos/posts/regressionPoisson.html

503 :
これも親切設計

wants <- c("lmtest", "MASS", "pscl", "sandwich", "VGAM")
has <- wants %in% rownames(installed.packages())
if(any(!has)) install.packages(wants[!has])

504 :
>>501
おい、上の過剰ゼロポアソンモデルから放校者数の期待値を計算してみ。
来年のド底辺シリツ医大の放校者の予想になるぞ。
まあ、ド底辺シリツが放校者ゼロ過剰というのは過大評価だがね。

505 :
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))
}

506 :
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 も カスタマイズすればわりと使えるな。

507 :
ニート ニート 働けニート

https://m.youtube.com/watch?v=qqA-oefg-m0

508 :
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))

509 :
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)

510 :
# ネットワークノード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]
}

511 :
#
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

512 :
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

513 :
minimize (2*b+4rα) where (θ-sinθ)/2+r^2(α-sinα)/2+(1-b)sinθ/2=pi/8 ,0<b<1,0<θ<pi/2


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

514 :
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

515 :
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

516 :
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

517 :
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

518 :
向学心のないコミュ障事務員のスレ

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

いや勘違いというか自分にそう言い聞かせなければいけないほど
人生終わってんだろうな
ハゲワロス

519 :
>>518
こういう野糞投稿しかできないのはド底辺シリツかな?
ド底辺スレから部屋割計算できなくて逃げ出したアホと同一人物?

520 :
>>518
向学心を語るなら>499の計算してからな。
ド底辺頭脳クン。

521 :
人生についての向学心は大学受験なんていう狭い領域で机上の空論をこねくり回すことではない
だがいつまでも不合格の受験生は、その領域から抜け出せなくなるんだなW

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

【因果応報】医学部再受験【自業自得】
https://medaka.2ch.sc/test/read.cgi/kouri/1543851603/

522 :
>>521
>499は受験に無関係な臨床問題だよ。
答えてみ!
はよ!はよ!
向学心を語るなら>499の計算してからな。
ド底辺頭脳クン。

523 :
このスレもお勧めだぞW

【悲報】ワイの医学部志望の妹、精神壊れる
http://vippers.jp/archives/9238137.html

524 :
>>523
>>518
向学心を語るなら>499の計算してからな。
ド底辺頭脳クン。

525 :
ド底辺頭脳でもこれくらいできるかな?

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

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

向学心も頭脳もないから答えられないだろうな。

526 :
さあそろそろ今日の宿題の問題を出題しといてやろうか
事務員には無理だろうけどな

さて問題です
ラブアンドピースとアヘ顔ダブルピースの相似性について原稿用紙30枚以上で考察せよ

527 :
>>525
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]

528 :
>>526
数値計算とか統計処理の必要な問題すらも作れないのは統計数理の素養がない馬鹿だからだろ。

臨床医ならこれくらいの計算ができる教養がほしいね。できなきゃド底辺シリツ医並の頭脳。


インフルエンザの迅速キットは特異度は高いが感度は検査時期によって左右される。
ある診断キットが開発されたとする。
このキットは特異度は99%と良好であったが、
感度については確かな情報がない。
事前確率分布として一様分布を仮定する。
50人を無作為抽出してこの診断キットで診断したところ40人が陽性であった。
この母集団の有病率の期待値と95%CIはいくらか?
またこの診断キットの感度の期待値と95%CIはいくらか

529 :
やはり低学歴ニートには答えられないんだな

参加賞で1曲あげといてやろう
https://www.youtube.com/watch?v=DMDnXwSiQA4

530 :
>>529
>>518
向学心を語るなら>499の計算してからな。
ド底辺頭脳クン。

531 :
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)

532 :
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)

533 :
インフルエンザ迅速検査キットの感度が80%、偽陽性率1%とする。

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

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

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

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

という。

臨床所見から疑われる有病率が70%程度(最頻値70%標準偏差10%)としたときにこの患者が仕事を休むことになる確率はいくらか?

534 :
バグに気づくのに時間がかかった、数学板に上げる前に気づいてよかった。

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)

535 :
こんな素朴な質問したら理解できない長文レスが数学化卒からきた。

4円弧モデルが最小ってどうすれば言えるの?

https://i.imgur.com/QK7tPmy.png
https://i.imgur.com/fvCMkmg.png
https://i.imgur.com/tsB0Xn2.png
の順に小さくなるのは計算できたけど。

536 :
暇つぶしにサムスカの太鼓持ち講演を聞いた。

相関係数を算出に全例調査しているのにp値を出していて

統計処理を理解していないアホだとわかったのが面白かった。

537 :
>>536
まあ、聞いているやつが(ド底辺シリツ医大卒のようなアホが多数で)p<0.001とか出せばエビデンスレベルが高いと誤解するだろうとわかっての所作なら策士だとは思うが。

538 :
こんなのがあんのね

電解質Na,K専用測定器 Fingraph

俺は夜間休日は血ガス測定で代用してたけど。

539 :
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

540 :
本日も事務員放送の終了時間となりました

https://m.youtube.com/watch?v=MMzpSqjIytg

541 :
>>540
相関係数を算出に全例調査しているのにp値を出だすのが
何でアホと言われるかわかる?

542 :
>>541
わからないからp値だしているのか
わからない>540のような馬鹿につけこんでいるのか、
どっちだろうな。

サイコロが2回続けて1の目出ました。

その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?

これに即答できんアホはこのスレに書く基礎学力なし。

543 :
さて問題です

ガチユリとガチムチの違いを原稿用紙30枚以上で述べよ

544 :
>>543
>>540
相関係数を算出に全例調査しているのにp値を出だすのが
何でアホと言われるかわかる?

サイコロが2回続けて1の目出ました。

その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?

オマエ、これに即答できんアホだろ。

545 :
問題に即答できんとは
さてはニートだな

546 :
>>545
統計スレで統計問題を書けないとはド底辺シリツ頭脳だな。

547 :
開業医でないのに開業スレに書きこむ
非医師のニート脳が何か言ってるなW

548 :
>>547
開業医スレに
こういうのを書いたら礼を言われましたよ。
https://egg.2ch.sc/test/read.cgi/hosp/1542639046/93

549 :
>>547

サイコロが2回続けて1の目が出ました。

その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?

オマエ、これに即答できんアホだろ。

550 :
>>547

ニート脳の学力すらないどアホがオマエな。

オマエ、これに即答できんアホだろ。

統計スレなんだから

これに答えてみ!はよ!はよ!

サイコロが2回続けて1の目が出ました。

その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?

551 :
非医師ニートくんは
スレ1の説明も読めないようだ

http://itest.2ch.sc/test/read.cgi/hosp/1542639046/1

552 :
>>551

スルーできないアホがオマエじゃん。

これに即答できんアホだろ。

統計スレなんだから

これに答えてみ!はよ!はよ!

サイコロが2回続けて1の目が出ました。

その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?

553 :
>>551
https://egg.2ch.sc/test/read.cgi/hosp/1542639046/76-83
までの議論(>77が俺)は
非医者ニートとの会話だと思う?
相当頭が悪そうだな。

これに即答できんアホだろ。統計スレなんだから
これに答えてみ!はよ!はよ!

サイコロが2回続けて1の目が出ました。
その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?

554 :
今日もニートの歌

https://m.youtube.com/watch?v=45GP02Od_Do

555 :
>>554
https://egg.2ch.sc/test/read.cgi/hosp/1542639046/76-83
の議論(>77が俺)は
非医者ニートとの会話だと思う?
相当頭が悪そうだな。

これに即答できんアホだろ。統計スレなんだから
これに答えてみ!はよ!はよ!

サイコロが2回続けて1の目が出ました。
その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?

556 :
>>547
開業医スレに
こういうのを書いたら礼を言われましたよ。
https://egg.2ch.sc/test/read.cgi/hosp/1542639046/93

非医師ニートに教えてもらって例を言ってるのも非医師ニートなのか。二人から褒めるレスが返って来たんだが。


統計スレなんだから!これに答えてみ!はよ!はよ!

サイコロが2回続けて1の目が出ました。

その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?

557 :
事務員の日常

https://www.nicovideo.jp/watch/sm6470478

558 :
>>557
https://egg.2ch.sc/test/read.cgi/hosp/1542639046/76-83
の議論(>77が俺)は
非医者ニートとの会話だと思う?
相当頭が悪そうだな。

これに即答できんアホだろ。統計スレなんだから
これに答えてみ!はよ!はよ!

サイコロが2回続けて1の目が出ました。
その確率は1/6*1/6=0.02777で0.05未満だから
サイコロは有意差をもって歪(いびつ)である、
即ち、1の目のでる確率=1/6という帰無仮説は棄却される
というのは正しいか?

559 :
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.

560 :
リンゲル液を凍らせた。
室温に放置して固相と液相が共存している時の液相の浸透圧は
元のリンゲル液より高いか低いかを即答できないのが
ド底辺シリツ医な、オマエも即答できんのじゃね。
ある学会でリンゲル液と同じと答えたアホがいたな。

561 :
>>559
ド底辺シリツ医にもわかるように原文をつけておけよ。

>>
私は昭和の時代に大学受験したけど、昔は今よりも差別感が凄く、特殊民のための特殊学校というイメージで開業医のバカ息子以外は誰も受験しようとすらしなかった。
常識的に考えて、数千万という法外な金を払って、しかも同業者からも患者からもバカだの裏口だのと散々罵られるのをわかって好き好んでド底辺医に行く同級生は一人もいませんでした。
本人には面と向かっては言わないけれど、俺くらいの年代の人間は、おそらくは8−9割はド底辺医卒を今でも「何偉そうなこと抜かしてるんだ、この裏口バカが」と心の底で軽蔑し、嘲笑しているよ。
当の本人には面と向かっては絶対にそんなことは言わないけどね。
<<

562 :
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.

563 :
 「イグっ&#9829; イグううぅーー&#9829; 鋼太郎、池袋にイっちゃうのおおぉぉ!」

564 :
age

565 :
https://www.nicovideo.jp/watch/sm34143061

566 :
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))
}

567 :
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]

568 :
メリークリスマス

https://m.youtube.com/watch?v=DkpZeGIAgn4

569 :
平均余命(縦線)と「平均寿命−現年齢」(点線の斜線)をグラフにしてみた。

https://i.imgur.com/uYnOOUs.png

570 :
https://m.youtube.com/watch?v=O0guNxFtetk

571 :
他スレで喚いて荒らしていても
算数クイズくんが
底辺から抜け出すことは
困難を極めます

572 :
開業医スレに
こういうのを書いたら礼を言われましたよ。
https://egg.2ch.sc/test/read.cgi/hosp/1542639046/93

573 :
>>571
これ理科のクイズ。

リンゲル液を凍らせた。
室温に放置して固相と液相が共存している時の液相の浸透圧は
元のリンゲル液より高いか低いかを即答できないのが
ド底辺シリツ医な、オマエも即答できんのじゃね。

ある学会でリンゲル液と同じと答えたアホがいたな。

574 :
平均余命の信頼区間を計算しようと思ったが
各年齢での人口データがないと無理だな。

575 :
さて国語の問題です

信じて送り出したフタナリ事務員が農家の叔父さんの・・・・・

続きを原稿用紙30枚以上で作成せよ

576 :
clinical sense の症例が配信されてきた。
Devic病と思ったら経過中にレルミット兆候が出てMSに診断変更。
インターフェロンβ→ナタリズマブの前にステロイドパルスがないのが解せなかったな。

577 :
ところでMS法人って
みんな作ってる?

578 :
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)

579 :
# 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)

580 :
# 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)

581 :
white zoneの視認性と腺窩の深さの関係

white zoneが鮮明な癌 腺窩の深さ 180±47 (p<0.001)
white zoneが不鮮明な癌 腺窩の深さ 81±20 (p<0.001)

582 :
>>581
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)

583 :
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)

584 :
サンプルサイズが推定できて、気分が( ・∀・)イイ!!

585 :
アイドル映像でも見て もちつけ

https://m.youtube.com/watch?v=duDNQoJVlRI

586 :
qqct.jp
http://bvdeur67.secure.ne.jp/index.html

587 :
日本にも、
ついに朝鮮殺戮殺人カルト宗教
殺人学会の、

テロ工作拠点が明らかになった!

テロ工作拠点
福山友愛病院

なんと日本警察に朝鮮殺戮殺人学会が侵入し、
カルトによる被害者側を警察が拉致して連れていくテロ工作拠点の一角!!

警察と完全犯罪達成の為に、共同組織犯罪をやっていて、

与えられていたのは、
犯罪ライセンス!!!!!!


薬物大量投与テロ発生!!
なんと故意に八倍!!!

カミサカというテロ医師による、
偽造カルテ作成発覚!!
なんとその為に監禁罪をやっていた!!!

588 :
直線解ならプログラム組めそうだけど答が円弧を含むなら
俺の能力では無理だな。
こういう問題を解ける頭脳には平伏するだけだな。


5等分の場合はこんな形が解になるそうです
https://imgur.com/xnH6eHf.jpg

正三角形5等分問題だと解が完全に非対称的な形になって面白い
https://imgur.com/rw7yGNl.jpg

589 :
自分がどれだけ馬鹿なのか自覚できていいな。
三角形なら直線で左右対象だろうとアプリオリに決めつけてプログラムしちゃうよなぁ。

590 :
理系で一番馬鹿なのが医学部を実感するなぁ。

591 :
分岐角度が120°、対象図形と分割線のなす角が90°という
いわゆるplatoの法則で立式しないとコンピュータ解も難しそう。

592 :
>>721
4分割ですらの正答出せなかった。

https://i.imgur.com/QK7tPmy.png
https://i.imgur.com/fvCMkmg.png
https://i.imgur.com/tsB0Xn2.png
の順に小さくなるのは計算できたけど。

593 :
明日は内覧会ですW

594 :
開業するのかw大晦日にw

595 :
数学板の統計スレにこんな課題があったのでシミュレーション解を投稿しておいた。


例えば、母集団から50枚の答案用紙を選んで、平均が
60点だとする。母集団は2500枚の答案用紙から成り立っているとして、平均は70点とする。このとき50枚の答案用紙をランダムに選んだかの検定はどの

ようにすればいいでしょうか。(つまり60点の平均点が低いので、ランダムに選んだかどうかを疑っているわけです。)

596 :
甲乙二人がおのおの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)

597 :
インフルエンザ脳症成人例は死亡率が高い

https://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)

598 :
## 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')

599 :
>>598
https://i.imgur.com/BHgxjYD.png

600 :
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.

601 :
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.

602 :
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.

603 :
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.

604 :
ド底辺シリツ医にもわかるように原文をつけておけよ。

>>
私は昭和の時代に大学受験したけど、昔は今よりも差別感が凄く、特殊民のための特殊学校というイメージで開業医のバカ息子以外は誰も受験しようとすらしなかった。
常識的に考えて、数千万という法外な金を払って、しかも同業者からも患者からもバカだの裏口だのと散々罵られるのをわかって好き好んでド底辺医に行く同級生は一人もいませんでした。
本人には面と向かっては言わないけれど、俺くらいの年代の人間は、おそらくは8−9割はド底辺医卒を今でも「何偉そうなこと抜かしてるんだ、この裏口バカが」と心の底で軽蔑し、嘲笑しているよ。
当の本人には面と向かっては絶対にそんなことは言わないけどね。
<<>>603

605 :
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.

606 :
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.

607 :
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)

608 :
>>606

ド底辺シリツ医にもわかるように原文をつけておけよ。

>>
私は昭和の時代に大学受験したけど、昔は今よりも差別感が凄く、特殊民のための特殊学校というイメージで開業医のバカ息子以外は誰も受験しようとすらしなかった。
常識的に考えて、数千万という法外な金を払って、しかも同業者からも患者からもバカだの裏口だのと散々罵られるのをわかって好き好んでド底辺医に行く同級生は一人もいませんでした。
本人には面と向かっては言わないけれど、俺くらいの年代の人間は、おそらくは8−9割はド底辺医卒を今でも「何偉そうなこと抜かしてるんだ、この裏口バカが」と心の底で軽蔑し、嘲笑しているよ。
当の本人には面と向かっては絶対にそんなことは言わないけどね。

609 :
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.

610 :
なんだか疲れた
働きたくない

611 :
http://blogs.wsj.com/numbersguy/
http://www.stats.org
http://ww.numberwatch.co.uk
http://politicalarithmetik.blogspot.com
http://www.straightdope.com
http://serc.carleton.edu/nnn/index.html
http://www.statlit.org

612 :
戸田A哲君もアメリカで経済学助狂をやっているらしい。
バブル崩壊で安定を求めて理3に入ってしまったらしい。
無駄に齢とっちまったな。

613 :
>>610
正月休みで1週間ぶりに内視鏡したが違和感があるなぁ。
平日は週3やってる。

614 :
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1182327/

615 :
なんだかだるい
あたりが暗く見える
笑い声を聞くとムカつく
疲れた
働きたくない

616 :
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.

617 :
移民法でお先真っ暗だよなぁ。

618 :
窓の外で誰かが見ている

619 :
お天道様がみている、というのが日本人の道徳。
移民法でお先真っ暗。

620 :
電波が、電波の声が聞こえる

621 :
>>620
便利でいいな。
オービスも聞こえればスピード違反で捕まることもないよな。

622 :
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])

623 :
ダルい
疲れた
働いたら負け

624 :
>>623
正月休みで1週間内視鏡から離れたら却って体調が悪いなぁ。

金のために不愉快な仕事をしないというのが最大幸福だな。

おかげで自宅で安眠できる。

625 :
>>624
これ即答してみ!

できなきゃ、ド底辺学力と認定してあげよう。

フタナリとガチユリの相関性について
原稿用紙30枚以上で考察せよ

626 :
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.

627 :
>>625
原稿用紙30枚以上と書くあたり
部屋割カウントできない馬鹿とすぐ分かるぞ

628 :
こういう問題の方が楽しいね!

12345→51234のように、十進表記の末尾一桁を先頭にもってくる操作を考える。
ただし末尾は0ではないとし、全桁が同じ数字からなる数も考えないものとする。
ある数Mをこの操作でLへと置き換えた。
MがLで割り切れるMのうち、桁数が最も小さいものを全て求めよ。

629 :
>>628
ナゾナゾは出せど
他人からの問題には全く回答不能なんだね

中卒ニートのコンビニバイトくん

630 :
>>629
数学板ででた問題、面白いだろ。
実用性は?だけど。

こっちは実用的。
Rのスレに質問あったのでレスしたけど
いつも達人がエレガントなコードを出してくる。
他人のコードを読むのは勉強になる。
https://rio2016.2ch.sc/test/read.cgi/math/1501755792/630

631 :
>>629
では模範解答をお願いしますね。
原稿用紙30枚以上必要らしいけど。
はよ、はよ!

632 :
>>630
これ即答してみ!

できなきゃ、ド底辺学力と認定してあげよう。

医師板で算数クイズ出して荒らしまわってて、
いい年してそんなものが何故必要かと聞かれ、
ガソリンスタンドで客からの注文に応えるため必要だ、と答えたド底辺学力のニートくんは、
なぜコンビニバイトに転職したのでしょう?

633 :
>>632
俺にはコンビニバイトは無理だな。
内視鏡や麻酔の方がずっと楽。

634 :
>>632
算数クイズができると論文の検証ができるわけね。

内視鏡の洗浄待機時間に 胃と腸 の所見用語集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と推定される。

635 :
これ答えられるかい?
コンビニバイト以下の教養ならまあ無理だな。

>643の±の後の数字は標準誤差とすると
サンプルサイズはいくつと推定できるか?

636 :
コンビニバイトくんのレスはこれだな

http://itest.2ch.sc/test/read.cgi/hosp/1527071455/63

637 :
>>636
それそれ
医師はそんなレスしないだろ

638 :
>>636
そういう計算もできない馬鹿がこういう事故を起こすわけなんだな。
http://i.imgur.com/ArPaux9.png

統計スレなんだから>635にでも答えてみ!
できなきゃガソリンスタンドのバイト以下の頭脳な。

639 :
>>637
ガソリンスタンドのレスは理解できたらしいが
>634のレスは理解できんだろ?ド底辺頭脳クン。

640 :
>>638
>統計スレなんだから

開業医でもないのに開業医スレに書き込むコンビニバイトくんに
特大ブーメランW

641 :
>>640
標準誤差の場合のサンプルサイズ推定の
Rのコードはこのスレに既出なんだけどね。

開業医スレに投稿したら礼を言われましたぜ!
https://egg.2ch.sc/test/read.cgi/hosp/1542639046/92-95

642 :
ちゃんと主張の正しさにも同意を得たぞ。
https://egg.2ch.sc/test/read.cgi/hosp/1542639046/76-83

643 :
>>641
コンビニバイトくんのレスは
何の釈明にもなっていない

>632への回答 はよはよ

644 :
>>643
礼を言われるような投稿がだよ〜ん。
あんたのは馬鹿を晒しているだけ。
ガソリンスタンドのレスは理解できたらしいが
>634のレスは理解できんだろ?ド底辺頭脳クン。

645 :
>>644
ところでコンビニバイトくん
非医師のアラシという自覚ある?

ガソリンスタンドのレスで理解できるのは
オマエがガソリンスタンドで給油の仕事をしているということのみだな

646 :
>>645
悪いが非医師じゃないんだね。
非医師にこういう議論ができると思う?
https://egg.2ch.sc/test/read.cgi/hosp/1542639046/76-83

こう言う方が非医師のアラシっぽいぞ。
https://egg.2ch.sc/test/read.cgi/hosp/1540905566/625

647 :
>>645
標準誤差のときのサンプルサイズの計算まだぁ?
ひょっとして、標準誤差が何かも知らない馬鹿ぁ?

648 :
>>645
んで、あんたド底辺シリツ医大卒?
頭脳レベルはド底辺みたいだけど。

649 :
http://fpr-calc.ucl.ac.uk/
の比率版を非心Χ二乗分布のRスクリプトをメールしたら返事が来たけどunderlining mathの議論が進まなかったな。
Intuitivel Biostatisticsの著者は即効で対応してErrataの追加と次版の修正の返事が来た。

650 :
>>645
どアホにもわかる計算の例示として税込みガソリン価格を上げただけということすらわからんらしいな。
こういう問題に算数が必要と書いてもオマエの頭じゃ正解だせないだろ?

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

何時以降の病態悪化は診療所の車を使わずに救急車の到着を待つ方が病院に早く着くか?

651 :
>>650
非正規雇用のオッさんの言い訳キモス
反面教師にしかならんわね

もうすぐ冬休みも終わって
再来年は高校受験だわ〜

652 :
>>651
答まだぁ?
阿呆じゃね??

653 :
中学生にすらバカにされるコンビニバイトくんW

654 :
>>653
その頭脳すらなくて答られないのがオマエだぞ。

655 :
>>653
>>645
どアホにもわかる計算の例示として税込みガソリン価格を上げただけということすらわからんらしいな。
こういう問題に算数が必要と書いてもオマエの頭じゃ正解だせないだろ?

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

何時以降の病態悪化は診療所の車を使わずに救急車の到着を待つ方が病院に早く着くか?

656 :
>>653
>>645
悪いが非医師じゃないんだね。
非医師にこういう議論ができると思う?
https://egg.2ch.sc/test/read.cgi/hosp/1542639046/76-83

こう言う方が非医師のアラシっぽいぞ。
https://egg.2ch.sc/test/read.cgi/hosp/1540905566/625

657 :
バレット食道がんって右にあるよなぁ。

https://www.hindawi.com/journals/isrn/2013/840690.fig.001b.jpg

658 :
>>654〜657
これ即答してみ!

できなきゃ、ド底辺学力と認定してあげよう。

医師板で算数クイズ出して荒らしまわってて、
いい年してそんなものが何故必要かと聞かれ、
ガソリンスタンドで客からの注文に応えるため必要だ、と答えたド底辺学力のニートくんは、
なぜコンビニバイトに転職したのでしょう?


>>654
送り仮名がオカシイところをみると
日本の方ですらないのですかね

659 :
>>653
>>645
悪いが非医師じゃないんだね。
非医師にこういう議論ができると思う?
https://egg.2ch.sc/test/read.cgi/hosp/1542639046/76-83

こう言う方が非医師のアラシっぽいぞ。
https://egg.2ch.sc/test/read.cgi/hosp/1540905566/625

660 :
>>659
非正規雇用のオッさんの言い訳キモス
反面教師にしかならんわね

もうすぐ冬休みも終わって
再来年は高校受験だわ〜

661 :
>>645
どアホにもわかる計算の例示として税込みガソリン価格を上げただけということすらわからんらしいな。
こういう問題に算数が必要と書いてもオマエの頭じゃ正解だせないだろ?

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

何時以降の病態悪化は診療所の車を使わずに救急車の到着を待つ方が病院に早く着くか?

662 :
>>661
>税込みガソリン価格を上げただけ ?W

違うよねぇ

http://egg.2ch.sc/test/read.cgi/hosp/1527071455/62-63
>税込みで5000円分給油してと言われて対応できないと仕事にならんだろ?

巧妙な話のすり替えワロス

医師は給油の仕事はしないよね
コンビニバイトくん

663 :
>>645
どアホにもわかる計算の例示として税込みガソリン価格を上げただけということすらわからんらしいな。
こういう問題に算数が必要と書いてもオマエの頭じゃ正解だせないだろ?

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

何時以降の病態悪化は診療所の車を使わずに救急車の到着を待つ方が病院に早く着くか?

664 :
数学板の統計スレで助言したら礼を言われた。

https://rio2016.2ch.sc/test/read.cgi/math/1478799258/688

665 :
>>662
そのスレの続きみたぁ?
ガソリンスタンドバイトでないことは普通の頭脳があれば理解できてるぞ。

https://egg.2ch.sc/test/read.cgi/hosp/1527071455/64-65

https://egg.2ch.sc/test/read.cgi/hosp/1527071455/96

666 :
いい年してバイトのオッさん
おおキモイキモイ

667 :
>>663-665
>税込みガソリン価格を上げただけ ?W

違うよねぇ

http://egg.2ch.sc/test/read.cgi/hosp/1527071455/62-63
>税込みで5000円分給油してと言われて対応できないと仕事にならんだろ?

稚拙な話のすり替えワロス

医師は給油の仕事はしないよね
コンビニバイトくん

スレを辿ると
受験は遥か昔の医師の人生にとって一次方程式が何の役に立つのか? 
というレスにオマエが
給油の仕事で対応できない
と答えたんだよね

普通に見れば、ナリスマシ非医師のボロが出た、としか考えられんよねW

668 :
>>667
一次方程式は役に立つよ。
これも二次方程式は必要ないぞ。
答えてみ!

>>645
どアホにもわかる計算の例示として税込みガソリン価格を上げただけということすらわからんらしいな。
こういう問題に算数が必要と書いてもオマエの頭じゃ正解だせないだろ?

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

何時以降の病態悪化は診療所の車を使わずに救急車の到着を待つ方が病院に早く着くか?

669 :
>>667

そのスレの続きみたぁ?

シンプソンのパラドックスに感心したらしい開業医のレス読めないの?

https://egg.2ch.sc/test/read.cgi/hosp/1527071455/64-65

https://egg.2ch.sc/test/read.cgi/hosp/1527071455/96

670 :
>668
>税込みガソリン価格を上げただけ ?W

違うよねぇ

http://egg.2ch.sc/test/read.cgi/hosp/1527071455/62-63
>税込みで5000円分給油してと言われて対応できないと仕事にならんだろ?

稚拙な話のすり替えワロス

医師は給油の仕事はしないよね
コンビニバイトくん

スレを辿ると
受験は遥か昔の医師の今後の人生にとって算数が何の役に立つのか? 
というレスにオマエが
給油の仕事で対応できない
と答えたんだよね

普通に見れば、ナリスマシ非医師のボロが出た、としか考えられんよねW

671 :
# 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()

672 :
>>670
そのスレの続きみたぁ?

シンプソンのパラドックスに感心したらしい開業医のレス読めないの?

https://egg.2ch.sc/test/read.cgi/hosp/1527071455/64-65

https://egg.2ch.sc/test/read.cgi/hosp/1527071455/96

673 :
内視鏡の洗浄待機時間に 胃と腸 の所見用語集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
http://fpr-calc.ucl.ac.uk/
の結果と一致して、気分が( ・∀・)イイ!!

674 :
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)
.

675 :
>>674
ここにレクチャーが
https://www.youtube.com/watch?v=iFaIpe9rFR0
あるんだけど、
非心t分布にはなんにも言及がないんだよなぁ。

非心分布の解説本ってこれを凌駕するのはないな。

サンプルサイズの決め方 (統計ライブラリー)

GPowerとかのソフト使ってクリック猿になるのは楽しくない。

676 :
比率の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)

677 :
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)
}

678 :
> # EMPA-REG OUTCOME test
> # 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

ここに上げたけど、外部パッケージが必要なのでグラフしか出力されないな。
http://tpcg.io/lz0Ck7

679 :
p値って(帰無仮説棄却の)結論が誤っている確率だと思っている椰子が多いんだよなぁ。

https://rio2016.2ch.sc/test/read.cgi/math/1478799258/701

680 :
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
#

681 :
# 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
>

682 :
>>680
そのシミュレーション

# 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

683 :
疲れた
ダルい
働いたら負け

684 :
働きたくない

685 :
待機で賃金が発生する職場が( ・∀・)イイ!!

686 :
>>685
職場に出勤しなくちゃいけない時点で負け組

687 :
>>686
自宅だと飲酒するから身体に悪い

688 :
>>687
焼肉屋のオーナーなんぞ
従業員を働かせて
毎日ゴルフ三昧だぞ

689 :
>>688
別にゴルフしたくないんだが。

こういう問題が解けた方が楽しい。
https://rio2016.2ch.sc/test/read.cgi/math/1532824890/90
まとまった時間がとれないとできないな。

690 :
>>689
ゴルフは単なる症例報告だ
俺もゴルフは全くやらん

調剤薬局もそうだ
医師は自分で働かないと無収入になるのに対して
薬局オーナーは出勤せずに毎日遊び歩いていても
病院オーナーよりはるかに高い収入を得ている
しかも薬局オーナーは薬剤師である必要すらない

691 :
>>690
オーナー理事長で役員報酬の不労所得の医師もいるぞ。

692 :
治療薬ハンドブックを読んで該当箇所のポケット医薬品集を読むと
同効薬の違いが分かって(・∀・)イイ!!
防腐剤を含まない点眼抗菌薬はどれかとか実に役立つ。

693 :
>>691
そいつは働いたことが無いのかい?
でなきゃ妬ましくないな

俺の同級生の土建屋やパチンコ屋の子弟はひどいぞ
最終学歴が高卒だけど
就業経験ゼロで役員になって一生豪遊してるからな

694 :
>>693
パチンコ屋や土建屋の子弟ってシリツ医大に多いよな。

695 :
>>694
知り合いの話かい?

他大学のことは知らんが
俺の出身の国立医学部にも土建屋の娘は居た

それはそうとニュースでミッキーハウス事件を見たことがあるかい?
あのニュースを見て理解できるのは
土建屋は病院なんぞ比べ物にならんくらい稼いでいるという事実だ

まあいずれにしても言えることは
働いたら負け
ということだ

696 :
>>695
この国には勤労・納税・教育の義務があんのよ。

697 :
>>696
納税したら負け、という価値観の椰子は多いだろうなぁ。

698 :
働いたら負けだお
お家でカウチポテトしてコーラ飲んで
動画見てるのが最高だお

699 :
>>698
いや、学会出張に愛人を連れて行く方が楽しいんだが。

700 :
>>699
学会のついでになど下らん

平日の昼間に遊び歩いてこそ勝ち組だ

701 :
>>700
学会のついでの方が燃えるぞ!

702 :
https://virtualsan-looking.jp/staff/

三権分立が存在しない権力のゴキブリ自民R山口敬之安倍官製ドワンゴとゴキブリ共は庵のは原爆で細胞ごと死滅しろw

703 :
疲れた
ダルい
働きたくない

704 :
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)

705 :
働いたら負け

706 :
>>700
盆や年末に俗世を離れてコミケに行く
アタイは勝ち組

707 :
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)

708 :
'(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))

709 :
>>708
虚飾値がmの値によらないのは興味深いな。

710 :
明日は月曜
暗い日曜日

711 :
>>710
明日の午後から火曜日まで代休。

712 :
>>709
以下の(1)(2)(3)を前提にして計算

(1)予備校の発表する偏差値は合格者の偏差値の平均値
(2)合格者の成績分布は正規分布で標準偏差は母集団と同じ
(3)成績のよい方から入学を辞退する

虚飾値=合格者の偏差値 - 入学者の偏差値

と定義して、辞退率と虚飾値の関係をグラフにすると


http://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

713 :
負〜け負け負け負け〜負け〜
働いたら〜負け〜負け〜
働い〜たら〜負〜け〜な〜の〜ら〜♪

714 :
教養がないのが負け組

715 :
ダルい
疲れた
働いたら負け

716 :
国試諦めてくれてありがとう。

717 :
先週は祝日だったので今日は内視鏡予約が多くて
この時間にステーキハウス。

眠剤のんでる老人はsedationの効きが悪いぜい。

718 :
>>709
この証明は難しいな。
数値積分での実感は簡単(ド底辺シリツ医を除く)だけどね。

719 :
オセロやルービックをプログラムで解く秀才は尊敬するな。
医学部にはいない。

720 :
良かったなー本当にありがとうございます。医者にならないで。良かったなー。

721 :
ありがとうございます。患者さんや医療従事者にとっては医者を諦めていただいて良かったです。

722 :
馬鹿でもできるのが臨床医。

算数の掛け算すら怪しいのがシリツ医がこういう事故を起こすわけなんだな。

http://i.imgur.com/ArPaux9.png

723 :
問題のある人物を医療の世界に入れることぐらい怖いものはないです。本当にありがとうございます。

724 :
医師の道を諦められたことに 同意いたします。その判断は正しいです。

725 :
ホッと一息 大学 厚生労働省。良かったね。

726 :
カネが欲しいから医学部にいくんや
文句あっか

727 :
危な過ぎて 許容できない。by 大学 厚生労働省

728 :
東京医大が本来合格者に追加合格させても

本来不合格者を除籍処分しないのだから

シリツ=裏口容疑者が確定だよ。

シリツ出身者こそ、裏口入学に厳しい処分せよを訴えるべき。

裏口入学医師の免許剥奪を!の国民運動の先頭に立てばよいぞ。

僕も裏口入学とか、言ってたら信頼の回復はない。

729 :
>>709
証明は複雑な定積分が必要だな。
俺には無理なので数値積分で確認。
中心極限定理もそうだな。

730 :
>>726
接客業は賤業。

731 :
>>730
仕事は何をしてるのかね?

いまどき正規職員でないものは完全に負け組だぞ

ゆっくり霊夢はFランク大学の就職課に就職したようです【第16話】
https://www.youtube.com/watch?v=SmTtzGIIjN8

732 :
>>729
これを一般式でするのは大変だろうな。

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

733 :
累積密度関数の逆関数が必要になる:(

734 :
タバコって燃えるゴミかな?
有害物質を発生するからプラゴミと同じかな?
灰皿は不燃ゴミ
電子タバコは家電ゴミでいいのかな?

735 :
>>734
吸ってる椰子がゴミ

736 :
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)

737 :
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になる。

738 :
>>737
バグ修正

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になる。

739 :
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))

740 :
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()

741 :
>>740
仕事は何をしてるのかね?

いまどき正規職員でないものは完全に負け組だぞ

742 :
>>741
何のプログラムかわかる?

743 :
テロ工作機関
福山友愛病院

なんと朝木明代市議のような他殺だと日本人に騒がれるから
日本国警察が、
朝鮮殺戮殺人教団に乗っとられたことにより警察から与えられていたのは、


犯罪ライセンス!!!!!!


病院で医師から処方された薬は、何ら疑いを持つことなく飲む人も少なくないだろう。

医学や薬学の知識がある人や、持病で何年も投薬治療を行っている人などは、
また違った見方をしているかもしれないが、一般的に「医師からの処方薬」に対する信頼は篤い。
しかし、そんな「信頼」を揺るがすとんでもない事件が話題となっている。

■「在庫処理」で不要な治療薬を投与広島県の福山友愛病院は、昨年11〜12月の間に、
統合失調症などの患者6名に、本来必要のないパーキンソン病の治療薬を投与していたことが判明。

これは、病院を運営する医療法人会長の指示によるもので、病院側は「使用期限が迫った薬の在庫処理がきっかけのひとつ。」と説明しているとのこと。

会長は、同病院で精神科としても勤務しており、パーキンソン病の治療薬である
「レキップ」の錠剤を統合失調症患者など6人に投与するよう看護師らに指示。
投薬は複数回行われ、末丸会長は通常の


8倍の量を



指示していたという。

744 :
ところで、タバコって燃えるゴミですか?
有害物質を発生するのでプラゴミと同じ扱いでしょうか?
電子タバコは家電ゴミですよね

今度、小学校に教育実習に行くので
お家のタバコ用具を全てゴミに出すように指導してきます

745 :
https://www.niid.go.jp/niid/images/flu/resistance/20190121/dr18-19j20190121-1.pdf
H3N2で 2/21vs0/21で有意差あるか?
n<5だとΧ二乗検定はあてにならない。

746 :
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.

747 :
テロ工作機関が日本にあることが判明


福山友愛病院


日本人への薬物大量投与テロも発覚


また他は、
単純に、朝鮮殺戮殺人革命の為に、
日本人被害者側を、
カルト医師が医師免許を犯罪に使用し、
偽造カルテをでっち上げているにすぎない

でっち上げる理由は、カルト会社の犯罪にごねている、
だから、
警察から犯罪ライセンス与えられているので、

虚偽説明して騙して閉鎖病棟に閉じ込め、
携帯とりあげ、
監禁罪やり精神保健福祉法違反をやり偽造カルテ書きますね

それだけw

だって、警察がグルで共同組織犯罪をしているから、
犯罪を犯罪でないことにしてくれるんだもの
日本人被害者側を拉致していることがバレたしな


それをやらかしていたので、
福山友愛病院には電凸し、
インターネット上に書いていることを通告もしている

ケースワーカーのイソムラという女性曰わく、

カミサカ先生インターネットに書かれて辛いみたいで〜・・・



日本国内にいるテロリストが辛くなることは、
日本人の喜びだっつーのww

748 :
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)

749 :
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')

750 :
実行結果

http://i.imgur.com/hOhq2y8.png

751 :
札幌ひばりが丘病院
麻薬取締法違反で書類送検
https://video.fc2.com/content/20180607uZCBN0zX

752 :
ゆっくり霊夢はFランク大学の就職課に就職したようです
https://www.youtube.com/playlist?list=PLCjQBaWqLbQ3PSHosCZE-stWkEtyUZ051

753 :
働いたら負け

754 :
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.

755 :
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)

756 :
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)

757 :
'
がん 非がん
感染  a  b
未感染 c  d

attributable risk : x
x={a/(a+b)-c/(c+d)} / {a/(a+b)}
'

758 :
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

759 :
一般論として医療統計って全然科学じゃないって、研究者の中ではバカにされてますよ。

760 :
統計で使われる数学って難し過ぎてついていけないよね。
AICとかわからないままにソフトで出させているだけ。

761 :
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.

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


原文はこれな。

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

763 :
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.

764 :
俺は医者ではない。

765 :
医学統計は苦手だ
できなきゃ論文読めんけど

766 :
>>765
>456の問題点を指摘できないなら不正統計に騙される素養があるね。

767 :
まあ落ち着いて
萌え動画でもどうぞ

https://m.youtube.com/watch?v=FmTtUVKjmEs

768 :
「もし君の妻子や友人にいつまでも生きていてもらいたいと思うならば、君は愚かである。というのは、君は、君の力の及びうる範囲内にないものまでも君の力の及びうる範囲内にあることを欲し、よそのものまでも君のものであることを欲しているからである。」

769 :
>>767

これでも見て落ちつけ

https://www.youtube.com/watch?v=mB3ZVIc4EF4

770 :
韓国で大麻が医療解禁した
国際条約では臨床試験や学術研究(輸出輸入など)が認められているんで一度訪ねてみては?

http://livedoor.blogimg.jp/denkyupikaso-rwceiylt/imgs/9/7/97a40f97.png
http://livedoor.blogimg.jp/denkyupikaso-rwceiylt/imgs/c/6/c6fc0285.png

韓国で使われてる大塚製薬の大麻製剤は日本の医師会員向けに和訳も開始されている。
https://news.nicovideo.jp/watch/nw4912539

771 :
まあ落ち着いて
萌え動画でもどうぞ

https://www.youtube.com/watch?v=y2b95D23sEA&t=134s

772 :
統計楽しいね

773 :
https://www3.nhk.or.jp/news/html/20190327/k10011863181000.html

インフルエンザの新しい治療薬「ゾフルーザ」を投与されたA香港型のインフルエンザ患者30人を調べたところ、
70%余りに当たる22人から、この薬が効きにくい耐性ウイルスが検出されたことが国立感染症研究所の調査で分かりました。
調査件数は多くないものの、専門家は現在のような使用を続けると、耐性ウイルスが広がるおそれがあるとして使用基準を見直すべきだと指摘しています。

https://www3.nhk.or.jp/news/html/20190327/k10011863181000.html

問題:耐性発生率の95%信頼区間は? 👀
Rock54: Caution(BBR-MD5:1341adc37120578f18dba9451e6c8c3b)


774 :
95%CI 0.541 0.877なので過半数に耐性出現と言っていいな。

775 :
耐性出現率が過半数である確率はいくらか?

776 :
>>775
あんた医科歯科大卒だろ?
学部1〜2回生の時に線形代数と微分積分はやった?

777 :
線形代数と微分積分を知らんと統計学の勉強は無理だね。
まあ、上を見れば切りがないけどね。

778 :
>>777
Rが使えれば統計扱えるよ。
今どき分布表で補間値計算なんてしないし。
非心t分布もRが出してくれる。


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

779 :
こんな質問があったからRを使って答えておいた。
他の人も同じ数値出していたな。

655 名無しさん@1周年 sage 2019/06/28(金) 12:05:50.17 ID:vuCIc6fU0
偏差値72.5ってIQにするとどれくらいなの?

https://asahi.2ch.sc/test/read.cgi/newsplus/1561682615/655

780 :
統計学のための数学

あんまり公式を使うことないなぁ。
定積分も数値積分でやっちゃうから

http://www.data-arts.jp/math_for_statistics/calculus/integration.html

781 :
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))

782 :
#
# 尿素呼気試験(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)

783 :
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
>

784 :
# ゴルゴ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)
}

785 :
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)

786 :
> 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
>

787 :
# 安倍総理招待枠(60-****)が招待状から
# 254x 2409 357xだという。
# https://youtu.be/6-pYMPg5yR0?t=3981
# 通し番号がふられているとして
# 357xを3570と低めに見積もる。
#>いや、それどころか、今年はそれ以上の数字も確認されている。
#選挙で安倍首相が遊説をおこなうとかなりの頻度で目撃されている熱烈な支持者であるM氏という人物がいるのだが、
#氏が菅官房長官や杉田水脈議員とのツーショット写真などとともにSNSにアップしていた
# 今年の「桜を見る会」の受付票には「60-4908」とナンバリングされているのだ。
#https://fate.2ch.sc/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]

788 :
> 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
>

789 :
# サイコロ

# 正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,])

790 :
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]
}

791 :
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("期待値","最頻値"))

792 :
# 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)

793 :
# 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)

794 :
## 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',])

795 :
# 10円硬貨を投げて5回連続で表が出ると
# 稀な現象(0.5の5乗は 0.03125)なので表の出る確率は0.5ではない、というのが頻度主義統計の結論。
# この硬貨はどの程度歪(いびつ)なのかを推論するのがベイズ推論の面白さである。
# この硬貨で表がでる確率の95%信頼区間を計算してみよう。
#
# 表のでる確率分布をβ分布β(a,b)でa=bとすれば、0.5を頂点とする対象な事前確率分布となる。
# 事後分布はβ(a+5,a+0)となるのだが、問題はパラメータaをいくらに設定するかである。
# aを変数として95%信頼区間下限値をグラフにすると最小値があることがわかる。
# http://i.imgur.com/MA4ztAU.jpg
# 最尤法で算出させるとa=11.25のとき0.406となる。
# あとは95%区間を計算して、この硬貨が表が出る確率の95%信頼区間は0.406 0.763となる。
# http://i.imgur.com/8swQPMH.jpg
HDInterval::hdi(qbeta,shape1=1+5,shape2=1)

796 :
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)

797 :
コインをなげたら5回続けて表が出た。
表が出る確率は、平均値が0.5のベータ分布(一様分布もベータ分布の一つ)に従うように鋳造されているとする。
このコインの表の出る確率を95%信頼区間で推定するとき
区域下限値の最小値はいくらか?
つまり、95%以上の信頼性で表の出る確率はいくつ以上と言えるか?

798 :
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))

799 :
>>798
95%CIをグラフ化
https://i.imgur.com/U6eVEYN.jpg

800 :
一般化 

#
"コインをなげたら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')

801 :
よくわからないけど面白そう

802 :
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) # 日本シリーズ

803 :
# 日本シリーズ

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)

804 :
# 通算勝率に従って次の試合に勝つ確率が決まるという設定
# 先勝した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()

805 :
互角と言っても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

806 :
> 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
>

807 :
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)

808 :
日本シリーズで賭けをする。

日本シリーズは先に4勝したチームが優勝。
勝率はそれまでの引き分けを除いた通算勝率に従うとする。
開始前の通算成績はA:2勝、B:4勝であった。
今、シリーズでAが先勝(第一試合に勝利)した。
この時点でA,Bのどちらに賭ける方が有利か?

809 :
# 小数点付きの数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()

}

810 :
戻り値がある方がいいな。

# 小数点付きの数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)
}

811 :
> 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

812 :
# 小数点付きの数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)
}

813 :
> 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

814 :
# 小数点付きの数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:検証用
}

815 :
# 小数点付きの数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:検証用
}

816 :
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))

817 :
デバッグした
# 通算勝率に従って次の試合に勝つ確率が決まるという設定
# 先勝した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()

818 :
日本シリーズは先に4勝したチームが優勝。
勝率はそれまでの通算勝率に従うとする。引き分けはないものとする。
勝負がつくごとに次回の勝率が変化する。
(第二試合にAが勝つ確率は通算勝率の3/7
Aが勝ったら第三試合に勝つ確率は4/8
Aが負けたら第三試合に勝つ確率は3/8
になるという設定)
シリーズ開始前の通算成績はA:2勝、B:4勝であった。
今シリーズでAが先勝(第一試合に勝利)した。
この時点でどちらが優勝するか賭けをする。
A,Bのどちらに賭ける方が有利か?"

819 :
poisson.test(c(11, 6+8+7), c(800, 1083+1050+878))
prop.test(c(11, 6+8+7), c(800, 1083+1050+878))

820 :
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)

821 :
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)
}

822 :
# 長さ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))

823 :
# 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

824 :
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)),]

825 :
> TE[(apply(TE,1,f)),]
JD service
[1,] 0 2
[2,] 1 2

826 :
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)),]

827 :
> 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
>
http://o.2ch.sc/1lwmk.png

828 :
"某女子大には決して嘘をつかない女子大生と必ず嘘をつく女子大生がいることがわかっている。
この女子大の学生(嘘つきかどうかは不明)から
「あなたのいうことが正しければ手コキかRをしてあげる、間違っていれば何もしてあげない」と言われた。
女子大生にRをしてもらうには何と言えばいいか?
"
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:R 3:手コキ+R
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)),]

829 :
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を実行して転置
}

830 :
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を実行して転置
}

831 :
"
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)

832 :
ここまで複雑だと推論での結論はかなり困難だと思う。
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),]

833 :
ここまで複雑だと推論での結論はかなり困難だと思う。
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),]

834 :
では次の問題です
次の動画をみさくら語で解説しましょう
https://www.youtube.com/watch?v=ckO9d_-qiPw

国試浪人の事務員でなければできるはずだねW

835 :
>>834
みさくら語ってド底辺頭脳の言語か?
RとかPythonなら使えるけど。

836 :
ほほう、どうやら
底辺の国試浪人には解けないようだね

837 :
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)

838 :
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)

https://i.imgur.com/92wYLCv.jpg

839 :
さあ、みさくら語に翻訳しよう

「何?街の薬剤師?大学教授の娘が、街の一薬剤師と結婚したいと言うのか?」
「いけませんの? 」
「絶対に反対だよ。何代も続いている有名な製薬会社オーナーは別として、一般の薬剤師になるものは、会社に残りたくても残れず、仕方なく街の薬剤師になる場合が多いのだ」
「医学部教授と街の薬剤師。比較するだけでもおかしいよ」

840 :
社交性が無く、職場で干されているアスペルガー医者が建てたスレはここですか?

841 :
>>836
みさくら語ってド底辺頭脳の言語は知らんから、リンクも踏んでないよ。

842 :
新型コロナウイルスの統計処理が自分の計算と合わないのが不思議なんだよね。

2019-nCov(2019年新型コロナウイルス)の論文
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とは合致しないなぁ。

843 :
I hate the so-called Fisher exact test: a pointer to one of my favorite articles
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')
}

844 :
>>836
ド底辺スレでの宿題はまだできてないのか?

ド底辺シリツ医大卒の裏口バカは、空室なしの10人5部屋割付の数をまだ出せないのか?

部屋の名前を '底辺','私立','ガチ','裏口','バカ'と命名すると
このように

ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ
ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ バカ
ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ 私立
ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ 底辺
ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ 裏口
ガチ ガチ ガチ ガチ ガチ ガチ ガチ ガチ バカ ガチ
から
裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 底辺 裏口
裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 ガチ
裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 バカ
裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 私立
裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 底辺
裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口 裏口
まで並べて
裏口 底辺 裏口 バカ ガチ 底辺 底辺 私立 私立 バカ
バカ 裏口 私立 私立 私立 バカ ガチ 裏口 ガチ 底辺
バカ 私立 バカ バカ ガチ 裏口 底辺 バカ 裏口 裏口
裏口 裏口 ガチ 裏口 私立 底辺 裏口 裏口 バカ ガチ
底辺 バカ ガチ バカ ガチ 私立 裏口 バカ バカ 裏口

部屋が5種類あるのを数えるだけだぞ。
ド底辺シリツ医大卒の裏口バカって数もろくに数えられないのか?

845 :
ほら、んほおぉぉぉっ、って言ってみな
んほおぉぉぉっ、ってW

846 :
最新の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未満になる確率を求めよ。

847 :
0.05未満になる確率は

これを持って統計的に有意だというどの程度の信頼度を持っていえるか、ってことなんだな。

848 :
## 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)
}

849 :
# ポアソンモデル
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)

850 :
では次の問題です
この病棟における入院期間の平均値と治癒率を求めよ
https://togetter.com/li/1432976

851 :
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)

852 :
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)

853 :
リンクは踏まないから、こういう風に問題を書けよ。

"某女子大には決して嘘をつかない学生と必ず嘘をつく学生がいることがわかっている。
この女子大の学生(嘘つきかどうかは不明)から
「あなたのいうことが正しければ手コキかRをしてあげる、間違っていれば何もしてあげない」と言われた。
この女子大生にRをしてもらうには何と言えばいいか?

854 :
ここは下品ないんたねっとですね

まさにこのスレはド底辺と呼ぶにふさわしいですねW

855 :
これで、
# 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を小さくして信用させるという手法を見破れるかな。

856 :
>>854
ちゃんと答えないとRしてもらえないよ。

857 :
> (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

858 :
>>855
フィッシャー検定は非負整数しか許さないから、こんな感じで
https://i.imgur.com/b4musi9.jpg
グラフにすると途切れができてしまうのが美しくない。

χ二乗検定版を作ってみよう。

859 :
国試浪人の素人童貞のスレはここですか?

860 :
>>858

# χ二乗テスト版
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))

この方が美しいな。
https://i.imgur.com/RBXeR57.jpg

861 :
>>859
これできないとRしてもらえないよ。

"某女子大には決して嘘をつかない学生と必ず嘘をつく学生がいることがわかっている。
この女子大の学生(嘘つきかどうかは不明)から
「あなたのいうことが正しければ手コキかRをしてあげる、間違っていれば何もしてあげない」と言われた。
この女子大生にRをしてもらうには何と言えばいいか?

862 :
人類の三大発明は

言語・貨幣・Rである。

by 吉田戦車

863 :
お兄ちゃん、イサキは、イサキは獲れたのっ?

864 :
比率の比較でなくて平均値の比較のときは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)

865 :
>>863
釣り人(嘘つきかどうかは不明)から
「あなたのいうことが正しければイサキかイサキの餌のどちらかをあげる、間違っていれば何もあげない」と言われた。
この釣り人からイサキをもらうには何と言えばいいか?

866 :
少し一般化、復元抽出するか否かや個数が不均等でも計算できるように改変。
# 母集団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)
}

867 :
デフォルト設定では母集団から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)
}

868 :
標準大学の新入生の知能指数の平均を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)

869 :
>>868
この手法で新薬の血中濃度は老人でも統計的に有意差はないので、安心して老人にも処方できます
という商用パンプを目にする。

底辺シリツ医=裏口容疑者はこういうのに騙されるんだよなぁ。

870 :
>>868
平均値100 標準偏差15で定義される知能指数で
標準大学の新入生の知能指数の平均が100
裏口シリツ医大の新入生の知能指数の平均が85であったとする。
1学年は100人として
各大学から1/10を無作為抽出して知能指数をt検定したときのp値の期待値、中央値を求めよ。
また、p値が0.05以上になって裏口シリツ医大の新入生の知能指数は統計的に有意差はないと主張できる確率はいくらか?

871 :
>>863
大漁っ!!イサキぃぃ!!おにいちゃんかっこいいいいぃぃぃい ぃくううううう!

872 :
私立出身医が一番多いスレであろう「開業医が集うスレ」のほうには書き込みせんのな?

873 :
>>872
書いているよ。
開業医スレでもシリツは馬鹿にされているじゃん。

https://egg.2ch.sc/test/read.cgi/hosp/1579579161/54

>>23
生データもある程度掲載されているから自分で統計処理が再現でいるな。
こういうのを考えてみると面白い。
Fisher testの結果が俺の計算と異なって気持ちが悪いままだが。

2019-nCov感染者41例中ICU収容13例(うち現喫煙者0),28例非収容(うち現喫煙者3)である。
このことから、煙草を吸うと重症化が防げると結論できるか?

874 :
>>871
そんなにレスじゃ、Rもイサキも手に入れることはできんぞ。

875 :
では次の問題です
タバコは脳の病気です
この事実を証明せよ
https://togetter.com/li/1432976

876 :
>853

877 :
>>872
俺が書かなくてもこういう投稿を目にする。
まあ、シリツ医という表記は俺の影響かもしれん。
自治医大とかを除外する意味で私立と書いていないわけだが。
>>
優秀な女子はぜひ国立医に入ってほしい
シリツ医は開業医のアホ子弟専用の専門学校

878 :
まあたしかに私立は学費が高いのは認める
わしも経済的理由で
合格した慶応は学費が高いので蹴って
地元イナカの国立にいった

879 :
>>878
イナカも東京も国立なら学費は同じだぞ。

880 :
>>879
イナカモノにしてみれば
地元以外のところに大学が存在しているという時点で
学費以外にもアパート代や食費などの参入障壁があるんだな

881 :
>>880
シリツ医大専門受験予備校のバイトは一コマ90分で手取り2万円だったな。大学の授業料が年間14万4千円の頃の話。
地方にはそんな割のいいバイトはない。

882 :
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)

883 :
パッケージの内部関数を使って解決してくれた。
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.

884 :
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)
}

885 :
#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)

886 :
こっちは、モンテカルロによるシミュレーション
# 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)
}

887 :
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)

888 :
> 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

889 :
>>884
H(n) = Σ[k=1,2,...,n] 1/k
とする。H(n)を既約分数で表したときの分子の整数をf(n)と表す。
f(77)を求めよ。

> f(77)
17610982920730618962802441030965952272844514966520010106103127939813509744122599441432576
/ 3574019481870823559764745233429885438685864430565417716720215849457565210956573486328125

890 :
>>884
n=100と大きいとNAが混ざるな

891 :
f <− function(n,prec=10000){ # Σ 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 }

892 :
  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)) # ?[1] 1234..? 文字列の5文字目から最後まで
  dn =substr(capture.output(res$deno)[2],5,nchar(res$deno))
  cat(paste0(nm,?/?,dn,?\n?))
  invisible(res)
}}

893 :
> f(100)
3055216077446868329553816926933899676639525195878807877583434152044192757431459126874725081455196840519615954410565802448075620352
/ 588971222367687651371627846346807888288472382883312574253249804256440585603406374176100610302040933304083276457607746124267578125

894 :
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))
}

895 :
# 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()))

896 :
# 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)
){

897 :
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

898 :
# 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)

899 :
エンデミックな定常状態を(S?, I?)とおけば、S?N=1R0,I?N=μμ+γ(1?1R0)(15)である。すなわちエンデミックな状態における感受性人口比率と基本再生産数は逆数関係にあり、有病率(prevalence)I?/Nは1?1/R0に比例していて、その比例係数は、感染状態における平均滞在時間1/(μ+γ)とホストの寿命1/μの比である。これらの式はエンデミックな感染症におけるR0の推定式ともみなせる

900 :
Rv?1という条件はワクチン接種率の条件として書き直せばv?1?1R0=H

901 :
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)
}}

902 :
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)
}}

903 :
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)

904 :
"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)

905 :
# 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)

906 :
"厚生労働省によりますと、新型コロナウイルスに感染した香港の男性が乗っていたクルーズ船で、
症状がみられる人やその濃厚接触者などにウイルス検査を実施した結果、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)

907 :
んほおぉぉ
https://m.youtube.com/watch?v=-XovrzoeG_E

908 :
日本最高学費の底辺私立医大では

1年:進級失敗10人
2年:進級失敗16人
3年:進級失敗34人
4年:進級失敗9人
5年:進級失敗10人
6年:卒業失敗26人

一学年約120〜130人前後。
同じ学年で二回留年すると退学
https://mao.2ch.sc/test/read.cgi/doctor/1516439331/1
であるという。

1年次学費総額 12,145,000円 2年次以降学費(年間) 7,030,000円

1学年を125人として上記データから算出した確率(例、1年次は10/125の確率で留年)を用いて

卒業できる確率と卒業生の在学年数の期待値を求めよ。
また、退学になる確率と退学者の在学年数の期待値を求めよ。

909 :
(p=1-c(10,16,34,9,10,26)/125)
q=1-p # 留年確率
(P=prod(1-q^2)) # 卒業できる確率 Π( 1 - 2年連続留年確率)
(Q=1-P) # 退学となる確率

p1=p # 各学年を1年で進級する確率
p2=p*(1-p) # 各学年を2年で進級する確率
P12=rbind(p1,p2)
gr=expand.grid(1:2,1:2,1:2,1:2,1:2,1:2) # 6学年の組み合わせdata.frame
years=apply(gr,1,sum) # 各組合せでの在学年数
dat=cbind(gr,years)
dat=as.matrix(dat) # data.frameを行列化
f <- function(x){ # 1~6年次の進級にかかった年数の配列xからその確率を返す
ps=1 # 進学確率
for(i in 1:6){ # 各組合せでの通算確率を算出
ps=ps*P12[x[i],i]
}
return(ps) # 卒業確率(入学してからその組合せで卒業できる確率)
}
Ps=apply(dat,1,f) # 組合わせ候補にfを適用 Probability of success
data=cbind(dat,Ps) # dat[,7]:入学してからの確率 dat[,8]:在学年数
# 在学年数の期待値
sum(data[,7]*data[,8])/sum(Ps)  # 期待値=Σxi*PiでΣPi=1でなくてはならないのでsum(Ps)で除算

# 退学
q=c(10,16,34,9,10,26)/125
Q=numeric(6)
Q[1]=q[1]^2 # 1年次で退学
Q[2]=q[2]^2 *(1- Q[1]) # 2年次で退学

for(i in 2:6){
Q[i]=q[i]^2 * (1-Q[i-1])
}
sum((1:6)*Q)/sum(Q)

910 :
ko=vector('list',6) # kicked out 退学までの軌跡
a=1:2  # 1:1回で進級,2:1回留年して翌年進級
ko[[1]]=as.matrix(2) # 1年時で退学
ko[[2]]=as.matrix(expand.grid(a,2)) # 2年時で退学の軌跡
ko[[3]]=as.matrix(expand.grid(a,a,2)) # 3年次で退学の軌跡
ko[[4]]=as.matrix(expand.grid(a,a,a,2))
ko[[5]]=as.matrix(expand.grid(a,a,a,a,2))
ko[[6]]=as.matrix(expand.grid(a,a,a,a,a,2))
f <- function(x){ # 軌跡与えてその確率(入学からの確率なので総和が退学確率Qに等しい)
n=length(x)
if(n==1) return(q[1]^2)
Pf=1
for(i in 1:(n-1)) Pf=Pf*P12[x[i],i]
return(Pf*q[n]^2)
}

Ef=numeric(6) # i年次退学する時の在学年数期待値(Qで除算が必要)
for(i in 1:6){
pf=apply(ko[[i]],1,f) # i年次で退学する場合の軌跡での確率
nf=apply(ko[[i]],1,sum) # その軌跡での在学年数
Ef[i]=sum(pf*nf)
}
sum(Ef)/Q

911 :
日本最高学費の底辺私立医大では

1年:進級失敗10人
2年:進級失敗16人
3年:進級失敗34人
4年:進級失敗9人
5年:進級失敗10人
6年:卒業失敗26人

一学年約120〜130人前後。
同じ学年で二回留年すると退学
https://mao.2ch.sc/test/read.cgi/doctor/1516439331/1
であるという。

1年次学費総額 12,145,000円 2年次以降学費(年間) 7,030,000円


父兄から 同じ学年で二回留年すると退学というルールは厳しすぎる、

これを撤廃して、最長12年までは在学可能とすべきだという提言がなされたとする

この提言を採用した場合、

1学年を125人として上記データから算出した確率(例、1年次は10/125の確率で留年)を用いて

卒業できる確率と卒業生の在学年数の期待値を求めよ。

また、退学になる確率と退学者の在学年数の期待値を求めよ。

912 :
こんな凄いスレッドあったんですね、読み返してみます、

913 :
ここは国試浪人の事務員のスレ

914 :
>>913
手コキ問題の答はまだか?

915 :
>>911
まず、シミュレーションプログラムを作る。
p=1-c(10,16,34,9,10,26)/125 #進級確率
q=1-p
sim <- function(){
g=1 # 学年,7:卒業
y=0 # 在学年数
while(g<7 & y<12){
g=g+sample(1:0,1,prob=c(p[g],q[g]))
y=y+1
}
c(g,y)
}
k=1e3
replicate(k,,sim())

916 :
p=1-c(10,16,34,9,10,26)/125 #進級確率
q=1-p
sim <- function(){
g=1 # 学年,7:卒業
y=0 # 在学年数
while(g<7 & y<12){ # 卒業前、在学12年未満なら
g=g+sample(1:0,1,prob=c(p[g],q[g])) # 進級判定して
y=y+1 # 在学年数を増やす
}
c(g,y) # 学年と在学年数を返す
}
k=1e6
RE=t(replicate(k,sim()))
head(RE)
summary(RE)
R12=RE[RE[,2]==12,] # 12年在学
nrow(R12[R12[,1]<7,])/k # 退学確率

917 :
> nrow(R12[R12[,1]<7,])/k # 退学確率
[1] 0.001039

918 :
p=1-c(10,16,34,9,10,26)/125 # 進級確率
q=1-p # 留年確率
p6=prod(p) # 6年で卒業確率
f <- function(x) prod(q[x])
pf=c(6,p6)
for(i in 7:12){
cmb=combinations(6,i-6,rep=T)
pf=rbind(pf,c(i,p6*sum(apply(cmb,1,f))))
}
pf
(P=sum(pf[,2]))# 12年以内に卒業できる確率
sum(pf[,1]*pf[,2])/P # 卒業までの平均在学年数

919 :
library(gtools)
p=1-c(10,16,34,9,10,26)/125 # 進級確率
q=1-p # 留年確率
p6=prod(p) # 6年で卒業確率
f <- function(x) prod(q[x]) # x:留年学年の配列→その組合せでの確率
pf=c(6,p6) # 在学年数,その確率
for(i in 7:12){#在学年数i 7~12において
cmb=combinations(6,i-6,rep=T) # 1:6から留年学年の組合せi-6個を重複を許して選ぶ
pf=rbind(pf,c(i,p6*sum(apply(cmb,1,f)))) #その組合せでの確率の総和に6年分の進級確率を乗ずる
}

(P=sum(pf[,2]))# 12年以内に卒業できる確率
(yg=sum(pf[,1]*pf[,2])/P) # 卒業までの平均在学年数 Σ x*pdf
(Q=1-P) # 退学確率
P*yg+Q*12 # # 大学を出る(卒業もしくは退学)を平均年数

920 :
理論値
> (yg=sum(pf[,1]*pf[,2])/P) # 卒業までの平均在学年数 Σ x*pdf
[1] 7.027985

シミュレーション値
> mean(R7[,2]) # 卒業生の在学年数
[1] 7.027643

合致しているから、どちらも正しそう。

921 :
思えば東京に住んでる奴はそれだけで経済的に優遇されてるな
田舎に住んでる貧乏人は学力があっても地元国立一択だったり
学力があっても就職コースだったりするからなぁ

922 :
>>921
東京で地元の国立に進学するのは容易ではないと思う。

923 :
>>919
この問題は数学板に投稿してもプログラムの練習にしかならんな。

924 :
難し、ネットで医療統計のページ見つけたが、
エクセルシートが出てくるだけだし、χ2検定だけでも
俺みたいなのに判るように解説してほしい、
MRが言う当社の薬剤は他のよりも優れていない確率は5%
って言うのはホントなんだろうか?違うよね

925 :
>>924
Χ2乗検定が知りたいのか
p値で判定することの欺瞞性を知りたいのか
非劣性検定の問題点を知りたいのか
どれ?

926 :
具体的にはグーフィス(持田)の製品紹介にある
グーフィスはプラセボ群に比して有意に大きな値をしめしました(p<0.0001共分散解析)  
 次行にはほぼ同じ文面で同じ数字でFisherの正確検定
 更にしたには          Wilconxonの順位和検定とあります
なんのことやら、 

927 :
分散分析は郡内分散と群間分散の比がF分布に従うことをつかった検定。
(この比をF ratioというのが色っぽいw)
統計の教科書読めばFisherもWilcoxonも載っているから独習してください。

頻度主義統計を理解する前に、
p値で判定することの欺瞞性や非劣性検定の問題点を論じても混乱するだけだと思います。

928 :
新型コロナウイルスが新たに67人で陽性であった。
検査可能数を100~1000と仮定したときの検査数の期待値と95%信頼区間を求めよ
"

f <- function(N,conf=0.95,print=FALSE){
# N=100 ; conf=0.95
m=1
r=67
n=r:N
pmf=choose(r-1,m-1)/choose(n,m) #Pr(max=60|n)
# plot(n,pmf,ylab='probability',bty='l')
pdf=pmf/sum (pmf)
if(print) plot(n,pdf,ylab='density',type='h',bty='l')
E=sum(n*pdf) #E(n)
cdf=cumsum(pdf)
Lidx=which.min(abs(cdf-(1-conf)/2))
Uidx=which.min(abs(cdf-(1-(1-conf)/2)))
return(c(E=E,L=n[Lidx],U=n[Uidx]))
}
N=seq(100,1000,by=50)
RE=as.matrix(sapply(N,f))
RE
plot(N,RE[1,],bty='l',pch=19,ylim=c(0,1000),xlab='上限件数',ylab='推定件数')
segments(x0=N,y0=RE[2,],x1=N,y1=RE[3,])

929 :
コロナ患者はおことわり
当たり前だよなぁ
普通の病院に来られても検査はできん
医師なら当然知ってることだ

930 :
製薬会社の社員って基本的に自社製品の宣伝しかしないよね
金儲けのため病院訪問してんだから当たり前かも知らんが
コンプ薬屋クンとかサラリーマン時代はどんな営業してたのかねぇ?

931 :
人生に失敗してる奴ほど反日野党に肩入れするよねW

932 :
binom::binom.bayes(4,4,prior.shape1=1,prior.shape2 = 1)
curve(dbeta(x,5,1),bty='l')
options(digits=22)
pbeta(0.01,5,1)
binom::binom.bayes(4,4)
curve(dbeta(x,4.5,0.5),bty='l')
pbeta(0.01,4.5,0.5)

933 :
トップ為政者がどんなに私的な放蕩や汚職等の悪行を重ねても、国の危機には民の命を第一に守るという最低限の義務を放棄しない限りは支持され続ける、アベはそれをあっさりと放棄した。

934 :
日本の領土、日本民族、そして日本語をもっとも破壊している反日勢力が安倍なんだが。

935 :
はいはい ワロスワロスW

936 :
危機に対する面構えのこの違い
https://Imgur.com/9YDINbB.jpg
https://Imgur.com/deINMd4.jpg
これだけで一目瞭然だろう

937 :
【コロナ】安倍内閣がクソすぎて無関心層が目覚め出した…「安倍総理ってもしかして無能なの…?」★19
https://asahi.2ch.sc/test/read.cgi/newsplus/1582086184/

938 :
お兄ちゃん、イサキは釣れたのっ?

939 :
おーい国試浪人 および コンプ薬屋
お前らのスレはここだ

他スレを荒らすんじゃないぞ

940 :
一辺10[m]の正方形ABCDのプールがある
点Dでは水が湧き出しており、点Dからr[m]離れた場所では(r/10)[m/s]までのスピードでしか泳げない

点Aから正方形の中心まで泳ぐのに掛かる最短時間を求めよ


極座標の曲線r=f(θ), 10=f(-π/2), 5√2=f(-π/4)上を泳ぐ時間は
T(f)=10∫[-π/2,-π/4]√(1+(f'(θ)/f(θ))^2)dθ
δT(f)=0に対するオイラーラグランジュの方程式は
-(f'/f)^2/(f√(1+(f'/f)^2))-(d/dθ)((f'/f)/(f√(1+(f'/f)^2)))=0
整理すると
(f'^2-f''f)(f^2+f'^2)^(-3/2)=0
この解はf(θ)=a e^(bθ)で境界条件を合わせると
f(θ)=10e^((-θ-π/2)(2log2)/π)
このとき
T(f)=10∫[-π/2,-π/4]√(1+(2log2/π)^2)/dθ
=(5/2)√(π^2+4(log2)^2)

941 :
では、それを、みさくら語でどうぞ

942 :
円卓の席に座る方法を考える。
4人席の場合、既に着席している4人が1,2,3,4と書かれたくじを引いて、反時計回りに1,2,3,4と並ぶように座り直すことにする。1の席が固定されているということはない。
すると、どのようにくじを引いたとしても高々2人の移動で済むことが簡単な考察で分かる。
では一般にn席あって着席済のn人が1,2,…,nと書かれたくじを引く時、移動しなければならない人は高々何人だろうか?

943 :
底辺の人間ほどエセの正義を語ることで
偉くなった気分になるんだよね
https://togetter.com/li/1469889

944 :
Aチーム6人 : Bチーム6人でレースゲームを16試合する。
1位15点
2位12点
3位10点
4位9点
5位8点
6位7点
7位6点
8位5点
9位4点
10位3点
11位2点
12位1点
の配点の場合、各チームの合計点が656:656の引き分けになる確率を教えてください。

x=c(1:10,12,15)
sim <- function() sum(replicate(16, sum(x[sample(12,6)])))==656
k=1e5
mean(replicate(k,sim()))

945 :
3861707060011302197274473352442662107544339496/924^16
=0.0136781633711920174806098975...

シミュレーションでの近似値が
> mean(replicate(k,sim()))
[1] 0.01344

大体あってる。

946 :
>>941
数くらい数えるのと、足し算くらいできるだろ?

Aチーム6人 : Bチーム6人でレースゲームを16試合する。
1位15点
2位12点
3位10点
4位9点
5位8点
6位7点
7位6点
8位5点
9位4点
10位3点
11位2点
12位1点
の配点の場合、各チームの合計点が656:656の引き分けになる

282326431934901209944756971232412938108921708544通りの中から引き分けになるのが何個あるか数えてくれ。

947 :
臨床経験が無いのに
臨床統計を語るのは
どういうお気持ちですか?

948 :
ここをコンプ薬屋と事務員の政治スレにしよう

949 :
>>947
臨床でのエピソード

23 卵の名無しさん sage 2020/02/06(木) 10:18:40.39 ID:fvuyjOo1
予約の患者が朝食とったらしくキャンセルで空き時間ができた。
余談ながら、
若い看護師が若い女性に(キイロカインを)「ごっくんしてください」というのは艶かしいな。
思わずVater乳頭の観察に時間を割いてしまうw

950 :
>>948
安倍ちゃんのいいところを書けば250円貰えるぞwww
://i.imgur.com/jfBeNNK.jpg

951 :
遥か昔の学生時代の記憶はどうでもいいから

早くコンプ薬屋も呼んできて
二人で壁打ちしてろ

952 :
>>951
また、逃げるの?

臨床医学って確率的事象を扱う稼業なのになぁ。
自分で統計処理できないのは恥ずかしいなぁ。
前スレでも答えられずに逃亡していた。

【新型コロナ】中国の映画監督、新型コロナウイルスで一家4人死亡
https://asahi.2ch.sc/test/read.cgi/newsplus/1582010500/

上記をみた統計できない患者から、かかったら必ず死ぬんですか?
と聞かれたら数字を出して説明したいよね。

4人感染して4人死亡。
死亡率の期待値とその95%信頼区間は?

953 :
"
医学雑誌ランセットには、武漢市金銀潭医院に入院していた重度の肺炎患者52人のうち32人(61.5%)が死亡したという論文が発表されています。
https://news.yahoo.co.jp/byline/kimuramasato/20200226-00164690/

厚生労働省によりますと、新型コロナウイルスへの感染が確認された人で人工呼吸器をつけたり集中治療室で治療を受けたりしている重症者は、25日の時点でクルーズ船の乗客・乗員が36人、国内で感染が確認された人が14人で合わせて50人となっています。
https://www3.nhk.or.jp/news/html/20200226/k10012301441000.html

何をもって重症としているのかは判然としないが、両者の重症判定基準が同等として
50人中何人死亡すると推定されるかを95%信頼区間とともに述べよ。

"

library(binom)
(bn=binom.confint(32,52))
attach(bn)
data.frame(method,mean*50,lower*50,upper*50)

954 :
>>953
童貞! 校庭! 童貞! 校庭! 
童貞! 校庭! 童貞! 校庭! 

955 :
>>953
臨床童貞はおもしろいですか?

956 :
ド底辺シリツ医および同等頭脳が答が出せない問題。

若い女性研修医(嘘つきかどうかは不明)から
「あなたのいうことが正しければ手コキかRをしてあげる、そうでなければセンズリを命じる」と言われた。
Rをしてもらうには何と言えばいいか?
尚、正直者なら嘘をつかないし、嘘つきなら必ず嘘をつく。

957 :
>>956
いつもどおりキモいですねW

958 :
>>957
ド底辺シリツ医頭脳登場w

959 :
>>958
早くド底辺仲間のコンプ薬屋を呼んできなよ
オマエとコンプが揃ってAGWPする
地獄絵図が見たいなぁ
by 都内JK

960 :
>>959
あんたが>956に答が出せないド底辺頭脳ではないかよ。

961 :
>>960
コンプ薬屋とAWPまだぁ
by 都内JK

962 :
>>959
>956の答も出せない底辺頭脳を晒して嬉しい?

963 :
プログラム解はこのスレに既出だからそれを日常言語化すれば答になるけど、ド底辺はそういう教養を欠いているんだよなぁ。

964 :
相変わらず、反日テレビ局は偏向報道が酷いな
まるで何もかも反対しかしない
昭和の野党みたいだ

965 :
おい統計野郎
他スレでのオマエのゴミレスみると
ごまかしと暇つぶしだけの人生だなW

966 :
レベルが高いからレスがつかんのよ
あんたこういうグラフ作れる?
暇つぶしに、感度80% 特異度90%だった時の有病率と 検査陰性での感染確率のグラフを書いてみた。
https://i.imgur.com/yVwE5Bs.png

967 :
>>965
数学板にも投稿してますが、みてないの?
357 132人目の素数さん sage 2020/02/29(土) 20:50:00.58 ID:duevA7i1
>>345
RでSEIR MODEL
dS(t)/dt = mu*(N-S) - b*S(t)*I(t)/N - nu*S(t)
dE(t)/dt = b*S(t)I(t)/N - (mu+sig)*E(t)
dI(t)/dt = sig*E(t) - (mu+g)*I(t)
dR(t)/dt = g*I(t) - mu*R + nu*S(t)
mu:自然死亡率 b:感染率(S->I)
nu:ワクチン有効率(S->R) sig:発症率(E->I),g:回復率(I->R)
でプログラムを組んでクルーズ船に閉じ込めておいたときの収束予想をだそうと遊んでみた。

968 :
ほらまたコンプがあっちで湧いた
お前の嫁だろ
早く呼んで来いやー

969 :
>>968
>956の答も出せないドアホ登場。
ド底辺シリツ医並の頭脳だなぁ。

970 :
>>969
このFランって オマエのことだろ
https://www.nicovideo.jp/watch/sm36414429

私はあなたと違って高学歴ですが

971 :
息を吐くようにシリツの言葉が出るって、どう考えても底辺国立だな

972 :
>>971
都内旧二期校卒

あんたは>956の答も出せないドアホだろ
ド底辺シリツ医並の頭脳だなぁ。

973 :
ド底辺シリツ医頭脳じゃなければ>956に正答すると思っていた。
それを受けてこっちをやってみ、と書く予定だったが
想定したよりも馬鹿だった。


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も正直者である」

974 :
>>972
相変わらず毎日ウソばっかりですね
このFランの恐ろしいところは周囲にうつそうとすることですね
高学歴の私は抗体があるので無事ですが

https://www.nicovideo.jp/watch/sm36414429

975 :
>>974
あんたは>956の答も出せないドアホだろ
ド底辺シリツ医並の頭脳だなぁ。

976 :
>>974
>973に論理的に答られたら高学歴が実証されるからやってみ。
24時間待ってあげる。

977 :
都内旧二期校卒!?とか言う言葉が出るあたり、相当な負け犬根性が培われてるな
一期校より下、旧六より下、都内なら私立より下まではいかんが私立より上ではない
底辺国立でいいだろ、分かりやすくて
高校の時に頑張って勉強しとくんだったなwww
ま、そんなことより、リアルでもネットでも、他人とコミュニケーション取れるようにな

978 :
>>977
>973できた?

979 :
>>978
受験を控えている高校生です

他のスレであなたの通っていた学校は実はFランであるとお聞きしました
レスも私の知っている大人の方たちと比べて随分と支離滅裂で低レベルなものしかされてませんが
今はどのようなお仕事をされてるんですか?

980 :
>>979
https://egg.2ch.sc/test/read.cgi/hosp/1579701192/25

981 :
>>979
>973に代わり答えてみ!

982 :
>>981
それで今はどのようなお仕事をされてるんですか?
下品なアジを書いたプラカード持って街角に立ってるお仕事ですか?

983 :
>>982
https://egg.2ch.sc/test/read.cgi/hosp/1579701192/25

984 :
>>983
受験を控えている高校生です
他のスレでアナタはコンプ性Fラン症候群という不治の病であるとお聞きしました
高学歴の私と違ってFランであるアナタは今はどのようなお仕事をされてるんですかぁ?

985 :
>>984
>973に答えて高学歴の学力をみせつけてみ!

986 :2020/04/24
医療大麻 CBDオイル 匿名ユーザーレビュー特集
・なんで効くのかわからないけど大麻すごい
父の病気が、治りました。
医者が驚いてます。僕も驚いてます。父は喜んでます。母は得意げです。
↓↓
謎に迫る! https://plaza.rakuten.co.jp/denkyupikaso/diary/202003270000/

クリニックインザモーニング札幌 インフルエンザ
【薫風会山田病院 山田雄飛 患者虐殺】
新潟県の医療情報
●●患者を見下すクズ医師(愛知)●●
【既婚も】患者さんに恋した医師
【インフル】マジでギリギリな開業医【バイト】7
【悪質】原三信病院香椎原病院(福岡県)診療報酬不正請求事件要旨
眼科はどうする7
ベンゾジアゼピンからの離脱
お金を頂きました!えへへw
--------------------
【IMAJUKU】今宿麻美【ASAMI】
炎神戦隊ゴーオンジャー GP-57
【21卒】就活スレ Part9
【特別区】東京二十三区清掃一部事務組合【一組】
犬 は 害 獣
艦船模型総合スレッド87
障害者ポスト設置が必要
人形草紙あやつり左近
【国民日報】『韓国人立入禁止』〜コロナのせい?・・・今の日本の飲食店の現状[03/12]
【MHW】発売からずっとソロでやってる人いる?【モンハン】
【ガンホー】ケリ姫スイーツ【310ケリ目】
☆☆NBA 2017プレシーズンスレ part1☆★
【学校サボり】DIY道楽 テツ・乃万家126【女装オカマッパ】
もし信玄と謙信が争わず同盟を結んでいたなら?
【バーチャル】hololiveアンチスレ#4569【youtuber】
ヤフーオークションは吊り上げ放題のコンテンツ 2
【NHK】実践ビジネス英語【10】(非アンチスレ)
アベノミクス倒産・廃業【中小企業】3
仮にゲーミングpc持ったとしてもmod導入しようとしてウィルスに感染したらどうするの
ダウンジャケット【ファッションブランド専門】 14
TOP カテ一覧 スレ一覧 100〜終まで 2ch元 削除依頼