◎正当な理由による書き込みの削除について:      生島英之とみられる方へ:

臨床統計もおもしろいですよ、その2 fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚


動画、画像抽出 || この掲示板へ 類似スレ 掲示板一覧 人気スレ 動画人気順

このスレへの固定リンク: http://5chb.net/r/hosp/1540905566/
ヒント:5chスレのurlに http://xxxx.5chb.net/xxxx のようにbを入れるだけでここでスレ保存、閲覧できます。

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

2卵の名無しさん2018/10/30(火) 22:49:12.69ID:kXLKssbE
dec2n n = concat . (map show) . reverse . sub
where sub 0 = []
sub num = mod num n : sub (div num n)
main = do
let n=7
let num=10^68 - 7
putStrLn $ dec2n n num


231610455425461524013603062230536506126223530530201410405365413161511216632624602

3卵の名無しさん2018/10/30(火) 23:17:28.53ID:kXLKssbE
dec2nw <- function(num, N, digit = 4){
r=num%%N
q=num%/%N
while(q > 0 | digit > 1){
r=append(q%%N,r)
q=q%/%N
digit=digit-1
}
return(r)
}
n=dec2nw(10**16-7,36)
n
cat(c(0:9,letters[1:26])[n+1])

4卵の名無しさん2018/10/31(水) 01:52:25.64ID:naQxCFH6
人格障害者の精神科医 古根高
http://egg.2ch.net/test/read.cgi/hosp/1497760609/

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

病的な虚言癖と妄想癖の精神科医 古根高の病名を診断するスレ
http://2chb.net/r/hosp/1529634250/

5卵の名無しさん2018/10/31(水) 10:21:03.69ID:sRjms2eC
def binomial(n,r):
from math import factorial as f
return f(n)//f(r)//f(n-r) if r>=0 and n-r>=0 else 0

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

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


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

nwin = function(m,n,k){
for(k in 0:(m-1)){
for(l in 0:(n-1)){
if(k*(n-1<l*(m-1))

6卵の名無しさん2018/10/31(水) 11:53:59.80ID:bPxngJ5R
nloc = function(m,n,k,l){
q=(n*k+l)%/%m
r=(n*k+l)%%m
(n-q)*(m-k)+q-1-l + ifelse(r>k,k-r,0)
}


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

nwin(3,4,2)
nwin(5,6,15)

7卵の名無しさん2018/10/31(水) 11:54:52.81ID:bPxngJ5R
pythonからRを経てHaskellに移植の予定。

8卵の名無しさん2018/10/31(水) 14:43:51.58ID:qgJ05S6D
>>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卵の名無しさん2018/10/31(水) 15:15:25.46ID:qgJ05S6D
import System.Environment

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

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

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

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

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

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

不定長整数が扱えるHaskellならではだな。
Rの
> mpfr(nwin(10,20,100),100)
1 'mpfr' number of precision 100 bits
[1] 15057796557878080240302485923118087468235549676781988478976は誤答とわかる

10卵の名無しさん2018/10/31(水) 19:24:32.48ID:qgJ05S6D
>>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卵の名無しさん2018/10/31(水) 21:01:13.96ID:qgJ05S6D
import System.Environment

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

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

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

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

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

12卵の名無しさん2018/10/31(水) 21:19:00.08ID:qgJ05S6D
nloc = function(m,n,k,l){
q=(n*k+l)%/%m
r=(n*k+l)%%m
(n-q)*(m-k)+q-1-l + ifelse(r>k,k-r,0)
}


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

longer <- function(m,k){
n=m+1
if(nwin(m,n,k) > nwin(n,m,k)) return(TRUE)
if(nwin(m,n,k) < nwin(n,m,k)) return(FALSE)
if(nwin(m,n,k) == nwin(n,m,k)) return(NULL)
}

13卵の名無しさん2018/10/31(水) 21:19:18.35ID:qgJ05S6D
pq1 <- function(m){
n=m+1
k=1
di=nwin(m,n,k) - nwin(n,m,k)
while(di<=0){
di=nwin(m,n,k) - nwin(n,m,k)
k=k+1
}
return(k-1)
}

pq <- function(m,Print=FALSE){ # > 0 long axis search wins
n=m+1
x=1:(m*n)
f = function(k) (nwin(m,n,k) - nwin(n,m,k))/choose(m*n,k)
y=sapply(x,f)
if(Print==TRUE){
plot(x,y,pch=19,bty='l',xlab='宝の数', ylab='確率差(長軸-短軸)')
abline(h=0,lty=3)
# print(y,quote=F)
}
z=which(y>0)
c(min(z),max(z))
}
pq(5,P=T)
(nw=cbind(0,sapply(2:20,pq)))
plot(1:20,(2:21)*(1:20),type='n',bty='l',xlab='m(短軸)',ylab='宝の数')
lines(1:20,(2:21)*(1:20),type='h',col='gray',lwd=2)
segments(1:20,nw[1,],1:20,nw[2,],lwd=4)

14卵の名無しさん2018/10/31(水) 21:50:35.78ID:AqNtLgjS
韓国「強制徴用は22万人で被害者が死亡しても遺族が訴訟可能」 元徴用工4人に損害賠償支払い判決
http://2chb.net/r/seijinewsplus/1540976520/

15卵の名無しさん2018/10/31(水) 21:51:01.16ID:qgJ05S6D
先に1個めの宝を見つけるには短軸探索と長軸探索とどちらが有利かは宝の数によって変わるのでグラフにしてみた。
縦5横6のとき宝の数を1から30まで増やして長軸探索が先にみつける確率と短軸探索がさきにみつける確率の差を描いてみた。
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚
縦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

グラフにしてみた。
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚

16卵の名無しさん2018/10/31(水) 21:57:13.38ID:qgJ05S6D
各人にとってのi 番目をどちらが先にみつけるかを計算してみた。

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

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

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

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

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

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

http://tpcg.io/Ph7TUQ

17卵の名無しさん2018/11/01(木) 10:16:30.80ID:ZkYkKASz
こういう解き方していると馬鹿になるなぁ、と
思いつつ便利なので使ってる。
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卵の名無しさん2018/11/01(木) 20:03:52.01ID:wy1a0s+b
aのb乗×cのd乗=abcd(abcd は4桁の整数)
abcdに当てはまる数字は?

[(a,b,c,d)|a<-[0..9],b<-[0..9],c<-[0..9],d<-[0..9],a^b*c^d==1000*a+100*b+10*c+d]

19卵の名無しさん2018/11/02(金) 00:51:03.46ID:CfCNBter
広島県の福山友愛病院で、
患者の病状と関係ない薬を大量に投与した。
しかも、意図的にです!



国は違うがドイツの場合

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

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

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


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


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

ダウンロード&関連動画>>

@YouTube


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

21卵の名無しさん2018/11/02(金) 18:00:28.03ID:jIM3oIca
医療法人潤和会を麻薬取締法違反の罪で略式起訴
https://seiyakuonlinenews.com/news/42856/

22卵の名無しさん2018/11/02(金) 18:53:08.10ID:3zC36uTy
広島県の福山友愛病院で、
患者の病状と関係ない薬を大量に投与した。
しかも、意図的にです!


国は違うがドイツの場合

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

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

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


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


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

ダウンロード&関連動画>>

@YouTube


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

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

こりゃ解禁しなきゃな!

24卵の名無しさん2018/11/03(土) 14:59:39.97ID:UnKdAdmR
国試浪人の事務員は裏口バカだから
レスするだけ無駄である

25卵の名無しさん2018/11/03(土) 15:10:46.97ID:Ipwzsvmc
>>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卵の名無しさん2018/11/03(土) 15:28:40.93ID:Ipwzsvmc
図形の問題って5ch(2Ch)じゃあ、投稿しにくいんだよなぁ。

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

http://2chb.net/r/math/1532824890/90

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

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

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

27卵の名無しさん2018/11/03(土) 17:40:46.36ID:Ipwzsvmc
>>24
レスできるような基礎学力すらないのがシリツ医大卒だといっているだよ。

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

の計算式書いてみ!

28卵の名無しさん2018/11/03(土) 18:16:44.41ID:hHITaoGI
臨床統計の問題です

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

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

29卵の名無しさん2018/11/03(土) 18:22:56.04ID:mjfFp3DY
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

30卵の名無しさん2018/11/03(土) 18:37:42.56ID:Ipwzsvmc
>>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卵の名無しさん2018/11/03(土) 18:38:49.80ID:Ipwzsvmc
>>29

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

推敲歓迎!!

32卵の名無しさん2018/11/03(土) 18:39:30.27ID:Ipwzsvmc
>>29

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

推敲歓迎!!

33卵の名無しさん2018/11/04(日) 16:05:31.31ID:T2FQgr1k
臨床統計の問題です

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

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

34卵の名無しさん2018/11/04(日) 17:50:26.40ID:YHVXN37A
>>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卵の名無しさん2018/11/05(月) 00:16:38.96ID:NIiUrAnG
ここの国では硬貨は7種類流通しています
この7種類の硬貨を使って1円〜70円の70通りの支払いができます
ただし一度に使用できる硬貨は3枚以下(同じ硬貨複数使いは可)です
7種類の硬貨はそれぞれ何円だったのでしょうか?

36卵の名無しさん2018/11/05(月) 00:17:21.55ID:NIiUrAnG
>>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卵の名無しさん2018/11/05(月) 00:18:36.57ID:NIiUrAnG
>>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卵の名無しさん2018/11/05(月) 00:19:36.93ID:NIiUrAnG
import Data.List
m = 69
sub x = do
let ijk = filter (<=70).nub $ sort [i+j+k| i<-x,j<-x,k<-x]
all (\y -> elem y ijk ) [0..70]
main = do
print $ [(b,c,d,e,f,g,h)| b<-[0..m],c<-[b..m],d<-[c..m],e<-[d..m],f<-[e..m],g<-[f..m],h<-[g..m],sub [0,b,c,d,e,f,g]]

39卵の名無しさん2018/11/05(月) 01:06:35.42ID:NIiUrAnG
>>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卵の名無しさん2018/11/05(月) 01:20:29.50ID:NIiUrAnG
数学板に超初心者のコードを書いたら、達人が高速化してくれた。
プログラム解を毛嫌いする向きもあるけど、初心者のコードを改善してくれたり、cに移植してくれたりする人の存在はとてもありがたい。

import Data.List

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

main = do
    print [x|x<-(xss !! 6),isGood x]

41卵の名無しさん2018/11/05(月) 01:22:05.62ID:NIiUrAnG
>>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卵の名無しさん2018/11/05(月) 01:34:19.46ID:NIiUrAnG
>>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卵の名無しさん2018/11/05(月) 07:20:27.85ID:NIiUrAnG
seqN <- function(N=100,K=5){
a=numeric(N)
for(i in 1:K) a[i]=2^(i-1)
for(i in K:(N-1)){
a[i+1]=0
for(j in 0:(K-1)){
a[i+1]=a[i+1]+a[i-j] # recursion formula
}
}

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

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

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

ret[N]
}
seqN(100,5)
seqN(1000,10)

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

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

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

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

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

ret[N]
}

45卵の名無しさん2018/11/05(月) 08:16:25.28ID:NIiUrAnG
>>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卵の名無しさん2018/11/05(月) 12:05:05.46ID:+OxX3fom
事務員さん

47卵の名無しさん2018/11/05(月) 12:14:01.00ID:RNxpU/sa
いくらド底辺シリツ医大卒の裏口バカでも
これくらいは計算できるだろ?

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

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

48卵の名無しさん2018/11/05(月) 14:38:27.92ID:Lykd2+5F
>>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卵の名無しさん2018/11/05(月) 18:35:02.59ID:Lykd2+5F
トランプのA〜10の10枚とジョーカー1枚の
合計11枚が机の上に裏向きに置いてある。
ランダムに1枚ずつ引いていった場合の、得られた数字の総和の期待値を求めよ。
ただし、ジョーカーを引いた時点で終了するものとし、
Aは数字扱いではなく、最終的に得られた数字の総和が2倍になるものとする。

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

# brute-force
library(gtools)
perm=permutations(11,11)
mean(apply(perm,1,f))

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

# Monte-Carlo
k=100
re=replicate(k,sum(replicate(n^r,f(sample(n,r,rep=T)))))
summary(re)

51卵の名無しさん2018/11/06(火) 15:40:53.99ID:jkx5i2bQ
コインを1000回投げた。連続して表がでる確率が最も高いのは何回連続するときか?

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

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

#
vsdJ=Vectorize(seq_diceJ)
NN=1000
kk=1:(NN/50)
p=0.5
y=vsdJ(NN,kk,0.5)
which.max(y)
plot(kk,y,bty='l',pch=19,xlab='sequence',ylab='probability')

52卵の名無しさん2018/11/06(火) 17:00:36.05ID:QApCAMmZ
f = function(x){
y=paste(x,collapse='')
str="1"
if(!grepl(str,y)) return(0)
else{
while(grepl(str,y)){
str=paste0(str,"1")
}
return(nchar(str)-1)
}
}

x=sample(0:1,20,rep=T) ; x ;f(x)

53卵の名無しさん2018/11/06(火) 19:54:04.82ID:jkx5i2bQ
>>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卵の名無しさん2018/11/06(火) 20:01:05.33ID:jkx5i2bQ
seq_dice <- function(N=100,k=5,p=1/6){
P=numeric(N)
for(n in 1:(k-1)){
P[n]=0
}
P[k]=p^k
P[k+1]=p^k+(1-p)*p^k
for(n in (k+1):(N-1)){
P[n+1] = P[n] + (1-P[n-k])* p^(k+1)
}
return(P[N])
}
seq_dice()

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

#
vsdJ=Vectorize(seq_diceJ)
NN=1e6
kk=1:30
p=0.5
y=vsdJ(NN,kk,0.5)
which.max(y) # 1e2:5 1e3:9 1e4:12 1e5:15 1e6:18
plot(kk,y,bty='l',pch=19,xlab='sequence',ylab='probability')
cbind(kk,y)
options(digits=22)
max(y)

55卵の名無しさん2018/11/06(火) 20:43:45.42ID:jkx5i2bQ
>>53
泥タブだと普通にみえるが、Win10のPCだと コードのインデントがなくなって左揃えされてしまうなぁ。

56卵の名無しさん2018/11/07(水) 00:33:21.67ID:J7bMbWmD
from fractions import Fraction

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

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

dice123456(1000)

57卵の名無しさん2018/11/07(水) 03:24:42.61ID:5r6Cuw34
愛の妖精ぷりんてぃん

58卵の名無しさん2018/11/07(水) 20:28:13.57ID:J7bMbWmD
# simulation
mhs = function(x){ # maximum head sequence
y=paste(x,collapse='')
str="1"
if(!grepl(str,y)) return(0)
else{
while(grepl(str,y)){
str=paste0(str,"1")
}
return(nchar(str)-1)
}
}

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

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

mean(replicate(1e5,sim()))

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

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

60卵の名無しさん2018/11/07(水) 21:22:13.74ID:s+v4AjoX
グリーンねえさん

61卵の名無しさん2018/11/08(木) 07:40:30.60ID:PGJy3ILP
>>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卵の名無しさん2018/11/08(木) 15:06:24.25ID:PGJy3ILP
m=100
ps=[(a,b,c)|a<-[1..m],b<-[a..floor(m^2/2-1/2)],c<-[b..2*b],a^2+b^2==c^2]
ps !! 99

[(a,b,c)|a<-[1..m],b<-[a..floor(a^2/2-1/2)],c<-[b..floor(sqrt(a^2+b^2))],a^2+b^2==c^2]
[(a,b,c)|a<-[1..m],b<-[a..floor(m^2/2-1/2)],let c = sqrt(a^2+b^2), fromIntegral(floor(c))==c]

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

応用問題:
a^2+b^2=c^2を満たす3つの整数(a<b<c)
の組み合わせのうち(3,4,5)から数えて100番目は何になるか 👀
Rock54: Caution(BBR-MD5:1341adc37120578f18dba9451e6c8c3b)

64卵の名無しさん2018/11/08(木) 16:45:02.14ID:PGJy3ILP
pitagoras <- function(A){
pita=NULL
for(a in 3:A){
B=floor(a^2/2-1/2)
for(b in a:B){
c=a^2+b^2
if(floor(sqrt(c)) == sqrt(c) ){
pita=rbind(pita,c(a,b,sqrt(c)))
}
}
}
colnames(pita)=letters[1:3]
return(pita)
}
pita=pitagoras(999)
saveRDS(pita,'pita999.rds')
pita[1,]
pita[7,]
pita[77,]
pita[777,]
pita[1000,]
tail(pita)

65卵の名無しさん2018/11/08(木) 20:38:27.74ID:cpzz/2HM
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.

66卵の名無しさん2018/11/08(木) 21:27:55.58ID:PVj0UwaU
Hutanari Ti〇po

67卵の名無しさん2018/11/08(木) 22:34:40.76ID:klK7Dgwj
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
最後にド底辺医大の三法則を掲げましょう。

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

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

3: The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.
ド底辺特殊シリツ医大卒は裏口入学の負い目から裏口馬鹿を暴く人間を偽医者扱いしたがる。

68卵の名無しさん2018/11/08(木) 22:35:56.08ID:klK7Dgwj
第一法則の英文の意図的な文法誤謬を指摘してみ!

69卵の名無しさん2018/11/08(木) 22:37:45.15ID:JqNfxHqE
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

70卵の名無しさん2018/11/08(木) 23:56:13.79ID:5CXia8DJ
Raise the hem of the white coat with a white coat appearing naked.
Put half of Voltaren in the anus
Peel the white eyes while hitting your ass with a bang bang with both hands
Shouts that "Utopia is surprisingly surprised! It is surprisingly utopian!
Raise the buttocks and fire the Voltaren rocket to the patient.

71卵の名無しさん2018/11/09(金) 07:26:09.53ID:guOlTCed
(mean(replicate(1e4,any(diff(cumsum(rbinom(100,1,0.5)),5)==5))))
[1] 0.8089
>
> (mean(replicate(1e4,with(rle(rbinom(100,1,0.5)), max(lengths[which(values=
<rle(rbinom(100,1,0.5)), max(lengths[which(values== 1)])>=5))))
[1] 0.8117
>

72卵の名無しさん2018/11/09(金) 07:26:39.67ID:guOlTCed
(mean(replicate(1e4,any(diff(cumsum(rbinom(100,1,0.5)),5)==5))))
[1] 0.8089
>
> (mean(replicate(1e4,with(rle(rbinom(100,1,0.5)), max(lengths[which(values=
<rle(rbinom(100,1,0.5)), max(lengths[which(values==1)])>=5))))
[1] 0.8117

73卵の名無しさん2018/11/09(金) 07:27:42.12ID:guOlTCed
実行速度

system.time(mean(replicate(1e4,any(diff(cumsum(rbinom(100,1,0.5)),5)==5))))
user system elapsed
1.840 0.000 1.875
>
> system.time(mean(replicate(1e4,with(rle(rbinom(100,1,0.5)), max(lengths[wh
<e(1e4,with(rle(rbinom(100,1,0.5)), max(lengths[whi ch(values==1)])>=5))))
user system elapsed
4.440 0.000 4.631

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

75卵の名無しさん2018/11/09(金) 13:39:50.75ID:wRJjRrMD
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.

76卵の名無しさん2018/11/09(金) 14:43:04.66ID:mj0MZvbh
"Oo, ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!
"Aaaaaaaaaaaa, big fish caught you" "Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "Sho-o-no-okoi, oh yeah, oh yeah, yeah, yeah, yeah, ha haa caught up for ha ha?"
I was licking a nipple and talking lolly I answered yao
"... Sea breams ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"
Listening to the dialogue, Ojisan pulls him body with his boyfriend
"Ha ha haaaaaaaaaaaaaaaaa, Isaki, Isaki, can you get it?"
"Aaaaaaaaaaaa ... I could have picked out a good Isaki, the biggest fishes of the year, this year."
"Big fishing !! Isaki !! Ooohoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo! "

77卵の名無しさん2018/11/09(金) 14:47:27.17ID:fYz4ML3G
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卵の名無しさん2018/11/09(金) 14:54:20.70ID:fYz4ML3G
RからPythonへの移植がようやく終わった。

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

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

http://tpcg.io/5xvZhU

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

P0(n)=a(n)/2^nとおいて
a(n+1)/2^(n+1)=1/2^(n+1){a(n)+a(n-1)+a(n-2)+a(n-3)+a(n-4)}
a(n+1)=a(n)+a(n-1)+a(n-2)+a(n-3)+a(n-4)
"""

80卵の名無しさん2018/11/09(金) 18:29:58.21ID:n6Zmr3Yp
We hold these truths to be self-evident, that all "uraguchi" are created retards,
That they are endowed by their creator with certain unalienable traits, that among these are sloth, mythomania, and the pursuit of imbecility.

That to rectify these traits, Bottom Medical Schools (BMS) are instituted for retards, deriving their just powers from what has been referred as the arbitrary donation of the parents of the rectified,
That whenever any form of the retards becomes destructive of rectification,
it is the right of the BMS to suspend or expel them, and to impose additional tuition laying its foundation on such principles and organizing its powers in such form, as to them shall seem most likely to effect the profit of BMS .

81卵の名無しさん2018/11/09(金) 19:01:24.31ID:fYz4ML3G
# 全体N個中当たりS個、1個ずつ籤を引いて当たったらやめる.
# r個めが初めて当たりであったときSの信頼区間を推定するシミュレーション。

atari <- function(N,r,k=1e3){ # k: simlation times
f <- function(S,n=N){which.max(sample(c(rep(1,S),rep(0,n-S))))}
vf=Vectorize(f)
sim=replicate(k,vf(1:(N-r)))
s=which(sim==r)%%(N-r)
s[which(s==0)]=N-r
hist(s,freq=T,col='skyblue')
print(quantile(s,c(.025,.05,.50,.95,.975)))
print(HDInterval::hdi(s))
}
atari(100,3)

82卵の名無しさん2018/11/09(金) 19:07:22.92ID:fYz4ML3G
pdf2hdi <- function(pdf,xMIN=0,xMAX=1,cred=0.95){
nxx=1001
xx=seq(xMIN,xMAX,length=nxx)
xx=xx[-nxx]
xx=xx[-1]
xmin=xx[1]
xmax=xx[nxx-2]
AUC=integrate(pdf,xmin,xmax)$value
PDF=function(x)pdf(x)/AUC
cdf <- function(x) integrate(PDF,xmin,x)$value
ICDF <- function(x) uniroot(function(y) cdf(y)-x,c(xmin,xmax))$root
hdi=HDInterval::hdi(ICDF,credMass=cred)
print(c(hdi[1],hdi[2]),digits=5)
invisible(ICDF)
}

# N個のクジでr個めで初めてあたった時のN個内の当たり数の推測
Atari <- function(N,r){
pmf <- function(x) ifelse(x>N-r+1,0,(1-x/N)^(r-1)*x/N) # dnbinom(r-1,1,x/N) ; dgeom(r-1,x/N)
# curve((1-x/N)^(r-1)*x/N,0,N)
AUC=integrate(pmf,0,N)$value
pdf <- function(x) pmf(x)/AUC
mode=optimise(pdf,c(0,N),maximum=TRUE)$maximum
mean=integrate(function(x)x*pdf(x),0,N)$value
cdf <- function(x) integrate(pdf,0,x)$value
median=uniroot(function(x)cdf(x)-0.5,c(0,N))$root
print(c(mode=mode,median=median,mean=mean))
pdf2hdi(pdf,0,N,cred=0.95)
}
Atari(100,3)
Atari(100,30)

83卵の名無しさん2018/11/09(金) 20:27:50.16ID:n7vPLA8Y
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.

84卵の名無しさん2018/11/09(金) 21:35:35.51ID:guOlTCed
次の課題はこれだな。

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

85卵の名無しさん2018/11/09(金) 21:59:40.95ID:WU3o6hYa
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

86卵の名無しさん2018/11/09(金) 22:34:31.28ID:fYz4ML3G
>>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卵の名無しさん2018/11/09(金) 22:53:11.07ID:fYz4ML3G
>>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卵の名無しさん2018/11/10(土) 00:19:47.42ID:Kp2aSERi
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.

89卵の名無しさん2018/11/10(土) 07:28:52.35ID:qmnilAbW
恵方巻き

90卵の名無しさん2018/11/10(土) 07:31:45.66ID:oGLeA9Hd
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

91卵の名無しさん2018/11/10(土) 07:35:47.21ID:Gl2x1zZV
>>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卵の名無しさん2018/11/10(土) 08:01:47.11ID:qmnilAbW
aiueo700

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


vs=Vectorize(function(K)seq2pCI(N=100,K,alpha=0.05,Print=F))
y=vs(2:23)
head(y)
plot(2:23,y['mean',],bty='l',pch=19)
points(2:23,y['mode',],bty='l')

94卵の名無しさん2018/11/10(土) 14:12:44.30ID:u8wDSGVd
幼稚な事務員

95卵の名無しさん2018/11/10(土) 14:24:33.17ID:u8wDSGVd
Look to the sky, way up on high
There in the night stars are now right.
Eons have passed: now then at last
Prison walls break, Old Ones awake!
They will return: mankind will learn
New kinds of fear when they are here.
They will reclaim all in their name;
Hopes turn to black when they come back.
Ignorant fools, mankind now rules
Where they ruled then: it's theirs again

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

Scary scary scary scary solstice
Very very very scary solstice

Up from the sea, from underground
Down from the sky, they're all around
They will return: mankind will learn
New kinds of fear when they are here

96卵の名無しさん2018/11/10(土) 15:50:53.19ID:Aj6PTVhz
>>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卵の名無しさん2018/11/10(土) 15:51:14.92ID:Aj6PTVhz
seqNp <- function(N=100,K=5,p=0.5){
if(N==K) return(p^K)
q=1-p
a=numeric(N) # a(n)=P0(n)/p^n , P0(n)=a(n)*p^n
for(i in 1:K) a[i]=q/p^i # P0(i)=q
for(i in K:(N-1)){ # recursive formula
a[i+1]=0
for(j in 0:(K-1)){
a[i+1]=(a[i+1]+a[i-j])
}
a[i+1]=q/p*a[i+1]
}
P0=numeric(N)
for(i in 1:N) P0[i]=a[i]*p^i # P0(n)=a(n)*p^n
MP=matrix(rep(NA,N*K),ncol=K)
colnames(MP)=paste0('P',0:(K-1))
MP[,'P0']=P0
MP[1,'P1']=p
for(i in (K-2):K) MP[1,i]=0
for(k in 2:K){
for(i in 1:(N-1)) MP[i+1,k]=p*MP[i,k-1]
} # Pk(n+1)=p*P(k-1)(n)
ret=1-apply(MP,1,sum)
ret[N]
}

98卵の名無しさん2018/11/10(土) 15:52:05.14ID:Aj6PTVhz
2つのサブルーチンを定義してから、

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

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

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

当然ながら、HDIの方が信頼区間幅が小さいのがみてとれる。

99卵の名無しさん2018/11/10(土) 15:59:25.71ID:Aj6PTVhz
とりあえず>84のプログラムは完成。

100卵の名無しさん2018/11/10(土) 18:18:24.26ID:eRQ4an/O
95%クオンタイルでの算出

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


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

あまり、差はないなぁ。

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

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

102卵の名無しさん2018/11/10(土) 21:22:19.55ID:BbEZ9aeT
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

103卵の名無しさん2018/11/10(土) 21:35:01.58ID:eRQ4an/O
ド底辺シリツ裏口調査団が100人を順次調査した。
裏口判明人数をそのまま公表はヤバすぎる結果であったため、
連続して裏口がみつかった最大数は4人であったとだけ公表した。
公表結果が正しいとして裏口入学人数の期待値、最頻値、及び95%信頼区間を述べよ。

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

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

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

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

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

4と100から、平均値と標準偏差がもっと簡単に導出できれば正規分布近似計算できるのだが
まあ、プログラムが組めたから正規分布近似計算する必要はないな。

104卵の名無しさん2018/11/10(土) 21:36:25.04ID:eRQ4an/O
>>102
原文はこれな。

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

105卵の名無しさん2018/11/10(土) 21:48:48.87ID:0/hxM8VF
作 牧村みき

106卵の名無しさん2018/11/10(土) 22:53:57.75ID:eRQ4an/O
開脚率の期待値を計算してみた。

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

がばがば女子大生の開脚率期待値:N人中z人開脚
N=9
z=3
Ex.gaba <- function(N,z){
integrate(function(x) x*choose(N,z)*x^z*(1-x)^(N-z),0,1)$value/integrate(function(x)choose(N,z)*x^z*(1-x)^(N-z),0,1)$value
}
Ex.gaba(9,3)
(z+1)/(N+2)

107卵の名無しさん2018/11/10(土) 22:58:20.05ID:eRQ4an/O
n=60:100
pmf=choose(60-1,5-1)/choose(n,5) #Pr(max=60|n)
pdf=pmf/sum (pmf)
sum( n*pdf) #E(n)

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


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

累積質量関数をグラフにすると
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚

108卵の名無しさん2018/11/11(日) 04:47:59.95ID:3fp/Z1Bf
NNN臨時放送

109卵の名無しさん2018/11/11(日) 08:25:49.13ID:8Ef5Z4Y6
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

110卵の名無しさん2018/11/11(日) 08:58:08.11ID:g+y24FcC
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.

111卵の名無しさん2018/11/11(日) 11:04:24.83ID:RT24eksu
東京医大、本来合格者入学許可へ 今年の受験生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卵の名無しさん2018/11/11(日) 11:06:42.03ID:RT24eksu
>>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卵の名無しさん2018/11/11(日) 11:07:30.56ID:RT24eksu
seqNp <- function(N=100,K=5,p=0.5){
if(p==0) return(0)
if(N==K) return(p^K)
q=1-p
a=numeric(N) # a(n)=P0(n)/p^n , P0(n)=a(n)*p^n
for(i in 1:K) a[i]=q/p^i # P0(i)=q

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

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

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

ret[N]
}
seqNpJ <- function(N,K,p) seqNp(N,K,p) - seqNp(N,K+1,p)

114卵の名無しさん2018/11/11(日) 11:08:29.37ID:RT24eksu
HDIofGrid = function( probMassVec , credMass=0.95 ) { # by Kruschke
sortedProbMass = sort( probMassVec , decreasing=TRUE )
HDIheightIdx = min( which( cumsum( sortedProbMass ) >= credMass ) )
HDIheight = sortedProbMass[ HDIheightIdx ]
HDImass = sum( probMassVec[ probMassVec >= HDIheight ] )
return( list( indices = which( probMassVec >= HDIheight ) ,
mass = HDImass , height = HDIheight ) )
}

115卵の名無しさん2018/11/11(日) 11:35:36.92ID:RT24eksu
pp=js
vsJ=Vectorize(function(p) seqNpJ(N=100,K=4,p))
y=vsJ(pp)
summary(y);quantile(y,prob=c(.025,.975))
plot(pp,y,col='navy',bty='l')
pp[which.max(y)]
max(y,na.rm=T)
HDInterval::hdi(y)
BEST::plotPost(y,xlab="裏口確率",col='pink')
BEST::plotPost(y,showMode = TRUE,xlab="裏口確率",col='pink')

116卵の名無しさん2018/11/11(日) 11:42:28.36ID:RT24eksu
>>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卵の名無しさん2018/11/11(日) 13:44:05.86ID:RT24eksu
あるタクシー会社のタクシーには1から通し番号がふられている。
タクシー会社の規模から保有タクシー台数は100台以下とわかっている。
この会社のタクシーを5台みかけた。最大の番号が60であった。
この会社の保有するタクシー台数の期待値を分数で答えよ

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

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

小数だと71.48850431950537

118卵の名無しさん2018/11/11(日) 13:44:55.16ID:RT24eksu
import math
import numpy as np
from fractions import Fraction

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

print (Fraction(result))
print (result)

119卵の名無しさん2018/11/11(日) 13:45:47.68ID:RT24eksu
Rだと
found_car = 5
max_number = 60
max_car = 100
n=max_number:max_car
pmf=choose(max_number-1,found_car-1)/choose(n,found_car) # Pr(max=60|n)
pdf=pmf/sum (pmf)
sum(n*pdf) #E(n)
で済むが 分数では算出できず

120卵の名無しさん2018/11/11(日) 13:58:43.34ID:RT24eksu
95%信頼区間も1行追加ですむ。
> n=60:100
> pmf=choose(60-1,5-1)/choose(n,5)
> sum(n*pmf)/sum (pmf)
[1] 71.4885
> n[which(cumsum(pmf/sum(pmf))>0.95)]
[1] 93 94 95 96 97 98 99 100

121卵の名無しさん2018/11/11(日) 13:59:57.00ID:RT24eksu
> n=60:100
> pmf=choose(60-1,5-1)/choose(n,5)
> sum(n*pmf)/sum (pmf)
[1] 71.4885
> min(n[which(cumsum(pmf/sum(pmf))>0.95)])
[1] 93

122卵の名無しさん2018/11/11(日) 14:00:49.27ID:4SxoNh8o
いあいあ ふんぐるい むぐるうなふ くとぅるう るるいえ うがふなぐる ふたぐん

123卵の名無しさん2018/11/11(日) 14:11:25.14ID:RT24eksu
# Pythonに移植
import math
import numpy as np
from fractions import Fraction

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

print (Fraction(result))
print (result)

cdf = np.cumsum(pdf)
print (max_number + np.min(np.where(cdf>0.95)))

124卵の名無しさん2018/11/11(日) 14:12:42.99ID:RT24eksu
5030556272103101/70368744177664
71.48850431950537
93

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

125卵の名無しさん2018/11/11(日) 14:15:53.17ID:4SxoNh8o
エコエコアザラク エコエコザメラク
地獄のキュエーン

126卵の名無しさん2018/11/11(日) 14:21:08.06ID:4SxoNh8o
算数の問題です
円周率をサンスクリット語で暗唱せよ

127卵の名無しさん2018/11/11(日) 15:38:32.90ID:RT24eksu
コインを1000万回投げた。連続して表がでる確率が最も高いのは何回連続するときか?

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

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

128卵の名無しさん2018/11/11(日) 16:09:19.43ID:RT24eksu
>>127
3010300桁の数はここにアップロードしてやったから早めにダウンロードして照合の桁数を間違えないようにしろよ。
9049で始まり、最後は9376で終わる数字。

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

129卵の名無しさん2018/11/11(日) 16:11:54.59ID:BgP7Mpr0
いやー、昨日のセカンドはやられました。はめられました。
第一ロッター・・・・・小カタメ少なめ 第二ロッター・・・・・小カタメ
第三ロッター・・・・・小カタメ麺半分 第四ロッター(俺)・・・大

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

130青戸6丁目住民は超変態バカップルを許さまじ食糞協会長:宇野壽倫2018/11/11(日) 16:35:14.78ID:eesLUl6p
★★【盗聴盗撮犯罪者・井口千明(東京都葛飾区青戸6−23−17)の激白】★★

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

盗聴盗撮つきまとい嫌がらせ犯罪者/食糞ソムリエ・高添沼田の親父の愛人変態メス豚家畜清水婆婆(青戸6−23−19)の
五十路後半強制脱糞
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚


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

131卵の名無しさん2018/11/11(日) 17:42:34.02ID:RT24eksu
# maximal sequential head probability at 10^8 coin flip
> y
[1] 2.2204460492503131e-16 2.2204460492503131e-16
[3] 8.8817841970012523e-16 1.5543122344752192e-15
[5] 3.5527136788005009e-15 6.8833827526759706e-15
[7] 1.4210854715202004e-14 2.8199664825478976e-14
[9] 5.6843418860808015e-14 1.1346479311669100e-13
[11] 2.2737367544323206e-13 4.5452530628153909e-13
[13] 9.0949470177292824e-13 1.8187673589409314e-12
[15] 3.6379788070917130e-12 7.2757355695785009e-12
[17] 1.4551915228366852e-11 2.9103608412128779e-11
[19] 5.8207660913467407e-11 1.1641509978232989e-10
[21] 6.6493359939245877e-06 2.5720460687386204e-03
[23] 4.8202266324911647e-02 1.7456547460031679e-01
[25] 2.4936031630254019e-01 2.1428293501123058e-01
[27] 1.4106434838399229e-01 8.1018980443629832e-02
[29] 4.3428433624081136e-02 2.2484450838189007e-02

132卵の名無しさん2018/11/11(日) 18:43:47.27ID:RT24eksu
#include <stdio.h>
#include<math.h>
#include<stdlib.h>
#define p 0.5


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

int main(int argc,char *argv[]){
int N = atoi(argv[1]);
double k = atof(argv[2]);
double PN =flip(N,k);
double PNJ = flip(N,k) - flip(N,k+1);
printf("Over %d heads at %d flips : %f\n", (int)k ,N ,PN);
printf("Just %d heads at %d flips : %f\n", (int)k ,N ,PNJ);
return 0;
}

133卵の名無しさん2018/11/11(日) 18:53:11.12ID:RT24eksu
gcc coin5.c -o coin5.exe -lm

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

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

C:\pleiades\workspace>coin5 1000 10
coin5 1000 10
Over 10 heads at 1000 flips : 0.385751
Just 10 heads at 1000 flips : 0.170128 👀
Rock54: Caution(BBR-MD5:1341adc37120578f18dba9451e6c8c3b)

134卵の名無しさん2018/11/11(日) 22:42:42.63ID:UCMkX/If
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

135卵の名無しさん2018/11/12(月) 00:48:13.50ID:G7wSOjAG
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

136卵の名無しさん2018/11/12(月) 02:39:48.77ID:+DPZ0e9S
臨床問題です
事務員のアスペ指数を計測せよ

137卵の名無しさん2018/11/12(月) 07:17:09.02ID:KUf7IfSV
>>136
前提が間違っているから
Zero Division Errorだね。

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

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

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

138卵の名無しさん2018/11/12(月) 07:46:46.08ID:fhdQROV/
誰からも相手にされない ド底辺事務員

139卵の名無しさん2018/11/12(月) 08:13:57.33ID:KUf7IfSV
>>138
数学板ではきちんとしたレスが返ってくるのよ。
こんな感じでね。
https://rio2016.2ch.net/test/read.cgi/math/1501755792/551

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

140卵の名無しさん2018/11/12(月) 13:48:23.85ID:Xm/n5tCK
この問題、俺にはプログラミング解が精いっぱい。
解析解出せる頭脳は尊敬するな。


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

141卵の名無しさん2018/11/12(月) 15:10:55.63ID:gzeh1x/+
library(rjags)
y=c(10,16,34,9,10,26)
N=rep(125,6)
Ntotal=length(y)
a=1
b=1
dataList=list(y=y,N=N,Ntotal=Ntotal,a=a,b=b)
# JAGS model
modelString ="
model{
for(i in 1:Ntotal){
y[i] ~ dbin(theta,N[i])
}
theta ~ dbeta(a,b)
}
"

142卵の名無しさん2018/11/12(月) 15:11:23.82ID:gzeh1x/+
writeLines(modelString,'TEMPmodel.txt')
jagsModel=jags.model('TEMPmodel.txt',data=dataList)
codaSamples=coda.samples(jagsModel,var=c('theta'),n.iter=20000,na.rm=TRUE)
summary(codaSamples)
js=as.vector(as.matrix(codaSamples))
BEST::plotPost(js,xlab="留年確率")
BEST::plotPost(js,showMode = TRUE,xlab="留年確率")

143卵の名無しさん2018/11/12(月) 15:12:31.12ID:gzeh1x/+
binom::binom.confint(sum(y),sum(N))

144卵の名無しさん2018/11/12(月) 16:56:10.68ID:gzeh1x/+
>>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卵の名無しさん2018/11/12(月) 17:01:57.91ID:gzeh1x/+
f <- function(Mmax,M=5,Nmax=100){
n=Mmax:Nmax
pmf=choose(Mmax-1,M-1)/choose(n,M)
pdf=pmf/sum (pmf)
mean=sum(n*pdf)
upr=n[which(cumsum(pdf)>0.95)[1]]
lwr=Mmax
c(lwr,mean,upr)
}
x=5:100
y=sapply(x,function(n) f(n)[2])
z=sapply(x,function(n) f(n)[3])
plot(x,y,type='l',lws=2,bty='l')
segments(x,x,x,z)
#points(x,z)
cbind(x,y,z)

146卵の名無しさん2018/11/12(月) 19:51:10.36ID:UwZfq4Lo
"マラソン大会の選手に1から順番に番号の書かれたゼッケンをつける。
用意されたゼッケンN枚以下の参加であった。
無作為に抽出したM人のゼッケン番号の最大値はMmaxであった。
参加人数推定値の期待値とその95%信頼区間を求めよ"

解析解は簡単。

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

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

147卵の名無しさん2018/11/12(月) 20:57:04.94ID:UwZfq4Lo
>>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卵の名無しさん2018/11/12(月) 21:48:58.46ID:UwZfq4Lo
最大値でなく平均値が与えられたときの参加人数の推定、

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

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

# simulation by round(mean)
M=5 ; Mmean=60 ; N=100
sub <- function(M,Mmean,N){
n=sample(Mmean:N,1) # n : 参加人数n
m.mean=round(mean(sample(n,M))) # m.mean : n人からM人選んだ平均値を
if(m.mean==Mmean) return(n) # roundで整数化
}
sim <- function(){
n=sub(M,Mmean,N)
while(is.null(n)){
n=sub(M,Mmean,N) # 平均値が一致するまで繰り返す
}
return(n) # 一致時の参加人数を返す
}
runner=replicate(1e4,sim())
summary(runner) ; hist(runner,freq=F,col="lightblue")
quantile(runner,prob=c(0,0.95))
cat(names(table(runner)[which.max(table(runner))])) # 最頻値

149卵の名無しさん2018/11/12(月) 21:53:15.51ID:UwZfq4Lo
5人の平均が60なので推定参加人数は当然、増えた。
正しいかどうかよくわからんなぁ。
meanをmedianにすれば中央値での推定ができる。

> runner=replicate(1e4,sim())
> summary(runner) ; hist(runner,freq=F,col="lightblue")
Min. 1st Qu. Median Mean 3rd Qu. Max.
64.00 86.00 92.00 90.72 96.00 100.00
> quantile(runner,prob=c(0,0.95))
0% 95%
64 100
> cat(names(table(runner)[which.max(table(runner))])) # 最頻値
100

150卵の名無しさん2018/11/12(月) 22:54:15.54ID:3/93pSbh
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.

151卵の名無しさん2018/11/13(火) 08:24:34.99ID:kjupm458
このスレは事務員が日がな一日妄想を垂れ流し
見物人たちがそれを見てフルボッコにするスレである

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

152卵の名無しさん2018/11/13(火) 09:07:06.76ID:UTrDDuDZ
>>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卵の名無しさん2018/11/13(火) 09:19:46.34ID:UTrDDuDZ
平均値を「四捨五入」するか、しないかを指定できるようにして
平均値が60であったときのサンプルの最大値の分布を示すシミュレーション

rm(list=ls())
M=5 ; m=60 ; n=100 ; round=TRUE
sub <- function(M,m,n){
s=sample(n,M)
rm=ifelse(round,round(mean(s)),mean(s))
if(rm==m) return(max(s))
}
sim= function(){
r=sub(M,m,n)
while(is.null(r)){
r=sub(M,m,n)
}
return(r)
}
round=F
re=replicate(1e3,sim())
summary(re) ; hist(re,freq=F,col="lightblue")
quantile(re,prob=c(0,0.95))
cat(names(table(re)[which.max(table(re))]),'\n')

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

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

156卵の名無しさん2018/11/13(火) 14:58:33.48ID:EZEaUTrv
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.

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

158卵の名無しさん2018/11/13(火) 19:46:29.89ID:WZBh4CIg
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

159卵の名無しさん2018/11/13(火) 20:23:20.79ID:DHMhO4WL
While touching Uryuu, touch the Uraguchi Jimuin with Sawasawa
"O, Oh, were you a big catch?"
"Oh, it was a big catch."
"Ayaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
While tenderly licking the baked pig with a tongue, the country trier replied
"... Sea breams, ..., a lot of flounder was caught"
Listening to the dialogue, Ojisan hit the body with him busts
"Ha ha ha ha! Ah, Isaki? Isaki, could you take it?"
Draw base clerk
"Oh, I got a big isaki, it is the biggest fishery of the year."
"Big fishing !! Isaki !! Great buddies are okay!"

160卵の名無しさん2018/11/13(火) 22:51:51.61ID:UlWlhoup
ここは くるくるぱー アスペ 事務員が
ナゾナゾを出したり アプリ翻訳したインチキ英語で
自作自演したりするスレです

161卵の名無しさん2018/11/13(火) 23:30:56.92ID:fLfkvliu
>155の計算結果は最頻値と期待値が大幅に乖離するので
計算に自信が持てずシミュレーションとの合致でようやく納得。
数学板に貼ったら2時間で期待値のHaskellでの算出値のレスが来た。それで信頼区間も確信を持って計算できた。
確率密度はこんな感じなので期待値と最頻値がずれるわけだな。
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚

162卵の名無しさん2018/11/13(火) 23:40:50.36ID:fLfkvliu
>>160
>155の算出式書けばド底辺シリツ医大卒でも基礎学力があると示せるのに裏口馬鹿を実証してどうすんの?
Rのスクリプトすら読めない裏口バカなんだろ?

163卵の名無しさん2018/11/14(水) 00:11:47.97ID:kAqwthFw
Uryuu fell 23 times in the national exam
It is an amateur virgin who is also failing in marriage
To the Uraguchi of the spinning parpurin
He is getting turned on
F class clerks condenced raw kid juice
The smell of the Doteihen does not decrease
NnnnnHooOoooOoooooooo

164卵の名無しさん2018/11/14(水) 00:35:23.31ID:lTkyjX2F
>>161
各枚数の確率を一様分布に設定してのシミュレーション。
プログラミングより結果が出るのを待つ時間の方が長いし
PCのリソースが奪われる。
泥タブで5ch閲覧や投稿で時間潰し。

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

re=replicate(1e5,sim())
summary(re) ; hist(re,freq=F,col="lightblue",main='',xlab='N')
quantile(re,prob=c(0.025,0.95,0.975))
cat(names(table(re)[which.max(table(re))]))
HDInterval::hdi(re)

165卵の名無しさん2018/11/14(水) 02:35:34.04ID:n/IxbzB4
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

166卵の名無しさん2018/11/14(水) 08:49:20.67ID:PJxL6X2W
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.

167卵の名無しさん2018/11/14(水) 20:59:26.07ID:lTkyjX2F
医師国家試験にこういうの問題を出してシリツ医大の裏口馬鹿を排除すればいいのにね。

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

168卵の名無しさん2018/11/14(水) 21:03:30.39ID:Q+EwHwPp
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

169卵の名無しさん2018/11/14(水) 21:26:14.73ID:zDUHf0ws
ド底辺事務員の今日のおかず

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

170卵の名無しさん2018/11/15(木) 08:47:29.19ID:MoyC03l0
Uryuu fell 23 times in the national exam
It is an amateur virgin who is also failing in marriage
To the Uraguchi of the spinning parpurin
He is getting turned on
F class clerks condenced raw kid juice
The smell of the Doteihen does not decrease
NnnnnHooOoooOoooooooo

171卵の名無しさん2018/11/15(木) 12:20:42.85ID:d0+yWFff
draft


pmf2hdi <- function(pmf,conf.level=0.95){ # unimodal
pdf=pmf/sum(pdf)
spdf=sort(pdf,decreasing=TRUE)
cdf=cumsum(spdf)
threshold=spdf[which(cdf>=conf.level)[1]]
idx=which(pdf>=threshold)
list(hdi=range(idx),confidence_level=sum(pdf[idx]))
}

172卵の名無しさん2018/11/15(木) 14:10:09.98ID:0BjfilY2
実際こんな職員が病院にいたら大変だね

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

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

173卵の名無しさん2018/11/15(木) 18:50:09.51ID:u639IIxL
 ABC
 ACB
 BAC
 BCA
+CAB
--------
3123 
A,B,Cは?

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

C
#include <stdio.h>
int a,b,c;
int main() {
for(a=1;a<10;a++){
for(b=1;b<10;b++){
for(c=1;c<10;c++){
if((A+A+B+B+C)*100+(B+C+A+C+A)*10+(C+B+C+A+B)==3123){
printf("%d %d %d\n",a,b,c);
}
}
}
}
return 0;
}

174卵の名無しさん2018/11/15(木) 18:50:25.10ID:u639IIxL
Python
n = range(1,10)
for A in n:
for B in n:
for C in n:
if (A+A+B+B+C)*100+(B+C+A+C+A)*10+(C+B+C+A+B)==3123:
print( [A,B,C] )
R
n=1:9
N=c(100,10,1)
for(A in n){
for(B in n){
for(C in n){
if (sum((c(A,B,C)+c(A,C,B)+c(B,A,C)+c(B,C,A)+c(C,A,B))*N) == 3123)
print(c(A,B,C))
}
}
}

175卵の名無しさん2018/11/15(木) 18:52:29.96ID:u639IIxL
>>172
残念ながら、事務員じゃないのね。
こういうの書いているの俺な。

内視鏡検査について Part.2 [無断転載禁止](c)2ch.net
http://2chb.net/r/hosp/1499746033/875

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

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


【現役医師】専門医資格取得について、どうお考えですか? 第2章
http://2chb.net/r/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卵の名無しさん2018/11/15(木) 19:08:50.01ID:u639IIxL
>>174
配列の要素ごとの演算をしてくれるRが使い勝手がいいなぁ。
シミュレーターとして使うのは遅いけど。

178卵の名無しさん2018/11/15(木) 19:10:14.30ID:u639IIxL
>>172
カスとは
>167の答も出せない
おまえのことだよ。

179卵の名無しさん2018/11/15(木) 19:26:12.08ID:0BjfilY2
医師なら事務員というワードには反応しないよねW

180卵の名無しさん2018/11/15(木) 19:33:47.58ID:LT687Ilf
>>179
ド底辺シリツというのに反応する椰子はw

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

182卵の名無しさん2018/11/15(木) 20:01:27.27ID:u639IIxL
>>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卵の名無しさん2018/11/15(木) 20:14:47.02ID:0BjfilY2
今日も事務員は発狂中

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






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

184卵の名無しさん2018/11/15(木) 20:33:45.90ID:LT687Ilf
>>183
あらら、>167に即答できないって相当頭が悪いぞ。
裏口入学??

185卵の名無しさん2018/11/15(木) 20:36:16.18ID:LT687Ilf
専門医スレで誰も正当できなかった>176の方に答えてくれてもいいぞ、国立卒ならこれくらいの四則演算はできるだろ?

186卵の名無しさん2018/11/15(木) 20:58:27.02ID:ziKbMPPq
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.

187卵の名無しさん2018/11/15(木) 22:03:57.30ID:u639IIxL
DRAFT

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

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

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

189卵の名無しさん2018/11/15(木) 22:20:49.26ID:u639IIxL
>>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卵の名無しさん2018/11/15(木) 22:51:18.47ID:u639IIxL
(1)
池の鯉を網で56匹すくいました。
すくった56匹に目印をつけ、池にもどしました。
次の日に鯉45匹をすくったところ、36匹に目印がついていました。
池の鯉はおよそ何匹ですか。

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


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

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

191卵の名無しさん2018/11/15(木) 23:19:30.11ID:u639IIxL
池の鯉を網で56匹すくいました。
すくった56匹に目印をつけ、池にもどしました。
次の日に鯉45匹をすくったところ、36匹に目印がついていました。
池の鯉はおよそ何匹ですか。

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

137149850039891/562949953421312
0.2436270741410791

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

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

import math
from fractions import Fraction
def choose(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def dhyper(x,g,b,s):
return choose(g,x)*choose(b,s-x) / choose(g+b,s)
f69 = dhyper(36,56,69-56,45)
print (Fraction(f69))
print(f69)
f70 = dhyper(36,56,70-56,45)
print (Fraction(f70))
print (f70)

192卵の名無しさん2018/11/15(木) 23:24:03.77ID:u639IIxL
>>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卵の名無しさん2018/11/15(木) 23:36:45.82ID:aG6lkqvZ
>>183
鉄則を思い出しましょう

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

194卵の名無しさん2018/11/15(木) 23:40:32.65ID:u639IIxL
pythonにも超幾何分布のモジュールがあった。

from scipy.stats import hypergeom
import matplotlib.pyplot as plt
# hypergeom.pmf(x,g+b,g,s)
print(hypergeom.pmf(36, 70, 56, 45))
print(hypergeom.pmf(36, 69, 56, 45))

195卵の名無しさん2018/11/15(木) 23:43:20.76ID:u639IIxL
>>193
そんなの書く暇があれば、これくらい即答できるはずなのに。

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

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

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

197卵の名無しさん2018/11/15(木) 23:55:08.72ID:kjgKXvFf
正当 WWW

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

198卵の名無しさん2018/11/16(金) 00:19:20.47ID:CpQxI30j
>>197
そういう指摘する暇があれば即答すればいいのに
やっぱり馬鹿なのね。

199卵の名無しさん2018/11/16(金) 14:34:20.45ID:OhMUxuM/
覆面算の □/□ * □/□ = □□/□ 
f0 分母に1を許さない
f1 分母に1がきてもよい

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

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

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

main = do
f0
f1

200卵の名無しさん2018/11/16(金) 14:49:13.79ID:OhMUxuM/
タイムアウトせずにon lineでも動かせた。

http://tpcg.io/dbtTnK

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

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

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

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

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

{- To caluculate input and let it run for minutes:
map f (ans1 r1max)
map f (ans0 r0min)
-}

202卵の名無しさん2018/11/16(金) 16:11:47.91ID:OhMUxuM/
バックグラウンで放置してたら計算してくれていた。

Prelude> map f (ans1 r1max)
[[-5,-1,3,-4,5,-3,4],[-5,-1,3,-3,5,-4,4],[-5,-1,4,-4,5,-3,3],[-5,-1,4,-3,5,-4,3],[-5,1,-4,3,5,-3,4],[-5,1,-4,4,5,-3,3],[-5,1,-3,3,5,-4,4],[-5,1,-3,4,5,-4,3]
,[5,-1,-4,3,-5,4,-3],[5,-1,-4,4,-5,3,-3],[5,-1,-3,3,-5,4,-4],[5,-1,-3,4,-5,3,-4],[5,1,3,-4,-5,4,-3],[5,1,3,-3,-5,4,-4],[5,1,4,-4,-5,3,-3],[5,1,4,-3,-5,3,-4]]

203卵の名無しさん2018/11/16(金) 18:23:07.05ID:CpQxI30j
>>191
数学板にこの問題とpythonのコードを貼ったら
ちゃんとコード内の関数を読んでレスがきた。

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

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

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

204卵の名無しさん2018/11/16(金) 19:16:23.53ID:lLHsnLDJ
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

205卵の名無しさん2018/11/16(金) 20:56:38.81ID:CpQxI30j
>>203

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


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

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

臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚

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

http://tpcg.io/TBD7MO

206卵の名無しさん2018/11/16(金) 22:01:15.87ID:7kS528uk
Uryuu fell 23 times in the national exam
It is an amateur virgin who is also failing in marriage
To the Uraguchi of the spinning parpurin
He is getting turned on
F class clerks condenced raw kid juice
The smell of the Doteihen does not decrease
NnnnnHooOoooOoooooooo

207卵の名無しさん2018/11/16(金) 22:37:20.95ID:STS/8KrX
僕らの おち○ぽ

208卵の名無しさん2018/11/17(土) 09:18:23.91ID:Xiv5Sp0o
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.

209卵の名無しさん2018/11/17(土) 10:15:28.71ID:Vs5/CoAG
>>205
池の鯉の総数と調査します。
五郎君が名前に因んで56匹を捕まえて目印をつけ、池にもどしました。
次の日に三郎君が自分の名前に因んで36匹の目印のついた鯉を捕まえることにしました。
鯉45匹めで予定の36匹が捕まりました。
池の鯉はおよそ何匹ですか。

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

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

211卵の名無しさん2018/11/17(土) 10:51:31.94ID:Vs5/CoAG
>>210
DRAFT

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

marked.fish2(3)
marked.fish2(36)

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

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

214卵の名無しさん2018/11/17(土) 13:55:53.88ID:ZSsSLaRh
>>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卵の名無しさん2018/11/17(土) 13:56:56.74ID:ZSsSLaRh
> marked.fish2(3)
lower upper
0.0006438142 0.0006421482
$`mode`
[1] 840

$median
[1] 1445

$mean
[1] 1985.835

$CI.hdi
[1] 280 5525

$CI.Qqtl
[1] 463 6902

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

216卵の名無しさん2018/11/17(土) 14:05:11.77ID:oN/r/5pI
さて来週の3本は

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

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

217純粋大和2018/11/17(土) 14:17:58.42ID:bEfId4t4
どうせ助からない(死ぬ奴)の集まりかよ 笑

218卵の名無しさん2018/11/17(土) 17:37:00.95ID:ZSsSLaRh
数学板のこれ面白かった。情報量とか調べながら解答してきた。

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

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

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

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

得意な方がいましたら、(2)の答えを出すまでの計算過程を教えていただきたいです。
よろしくお願い致します。

219卵の名無しさん2018/11/17(土) 17:38:33.02ID:ZSsSLaRh
数時間潰しての結果がこれ、わずか2行w

Prelude> let entropy x = sum $ map (\i -> -i*(logBase 2 i)) ( map(/sum(x)) x )
Prelude> 30/50 * entropy [18, 12] + 20/50 * entropy [2, 18]
0.7701685941085136

220卵の名無しさん2018/11/17(土) 18:43:39.12ID:ZSsSLaRh
>>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卵の名無しさん2018/11/17(土) 19:20:41.23ID:XNk+eTpQ
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.

222卵の名無しさん2018/11/17(土) 20:12:01.95ID:ZSsSLaRh
# 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卵の名無しさん2018/11/17(土) 21:45:47.30ID:ZSsSLaRh
KLd <- function(P,Q){ # Kullback-Leibler divergence, relative entropy,Information gain
n=length(P)
if(n!=length(Q)) return(NULL)
P=P/sum(P)
Q=Q/sum(Q)
sum(P*log(P)/log(Q)) # P relative to Q
}


kld p q = do -- Kullback-Leibler divergence
-- if length p /= length q
-- then return ()
-- else do
let pp = map (/sum(p)) p
qq = map (/sum(q)) q
in sum $ zipWith (\x y -> x * (log x)/(log y)) pp qq

224卵の名無しさん2018/11/17(土) 21:50:36.68ID:ZSsSLaRh
Prelude> p = [80,10]
Prelude> q = [10,20]
Prelude> let pp = map (/sum(p)) p
Prelude> let qq = map (/sum(q)) q
Prelude> sum $ zipWith (\x y -> x * (log x)/(log y)) pp qq
0.6974120552208812


KLd <- function(P,Q){ # Kullback-Leibler divergence, relative entropy,Information gain
n=length(P)
if(n!=length(Q)) return(NULL)
P=P/sum(P)
Q=Q/sum(Q)
sum(P*log(P)/log(Q)) # P relative to Q
}
> KLd(c(80,10),c(10,20))
[1] 0.6974121

225卵の名無しさん2018/11/17(土) 23:42:40.77ID:7FfFKHDd
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

226卵の名無しさん2018/11/18(日) 06:08:27.82ID:YaOZKwLp
事務員で遊ぶのも飽きてきたし
そろそろコミケの原稿を書き始めなきゃなぁ

227卵の名無しさん2018/11/18(日) 06:55:57.87ID:deJ1Cp/X
中学入試を難問化した問題で遊んでみる。

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

228卵の名無しさん2018/11/18(日) 08:16:59.52ID:afl5ZxKK
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

229卵の名無しさん2018/11/18(日) 10:01:00.69ID:deJ1Cp/X
>>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卵の名無しさん2018/11/18(日) 11:18:38.60ID:uPZ4H5RS
>>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卵の名無しさん2018/11/18(日) 11:18:46.99ID:uPZ4H5RS
marked.fish <- function(.x,Nmax=10000, Print=FALSE){ # marked fish # to 95%CI
N2p= function(N,g=56,s=45,x=.x){ # N:total number of fishe
if(N < g + s - x) return(0)
b = N-g # g:genuine(marked) b:bogus(unmarked) s:re-sampled
dhyper(x,g,b,s) # choose(g,x)*choose(b,s-x)/choose(g+b,s)
}
pmf=Vectorize(N2p)
N=1:Nmax
y=pmf(N)
z=y/sum(y)

mode.idx=N[y==max(y)] # can be multiple
n.idx=length(mode.idx)
mode=min(mode.idx)+(n.idx-1)/10
mean=sum(N*z)
hdi = pmf2hdi(y,Print=FALSE)$indices
zc=cumsum(z)
median=which.max((zc>0.5))
if(Print){
par(mfrow=c(2,1))
plot(N,z,type='h',col='gray',ylab='density',bty='l')
abline(v=c(mode,median,mean),lty=c(1,2,3))
legend('topright',bty='n',legend=c('mode','median','mean'),lty=1:3)
plot(N,zc,type='l',col='gray',ylab='cdf',bty='l')
abline(h=0.5,lty=3)}
qtl = c(min(which(zc>0.025)) , min(which(zc>0.975)))
list(mode=mode, median=median, mean=mean,CI.hdi=hdi,CI.Qqtl=qtl)
}

232卵の名無しさん2018/11/18(日) 11:19:33.02ID:uPZ4H5RS
marked.fish(36,Print=T)
marked.fish(3,Print=T)
n=0:45
Y=sapply(n,function(n) marked.fish(n))
y=matrix(unlist(Y["CI.hdi",]),nrow=2)
plot(n,y[2,],type='n',bty='l',xlab='re-sampled marked fish',
ylab='estimated size of total')
segments(n,y[1,],n,y[2,],lwd=3,col='gray')
points(n,unlist(Y['mode',]),pch=21)
points(n,unlist(Y['median',]),pch='+')
points(n,unlist(Y['mean',]),pch='*')
legend('center',bty='n',pch=c('○','+','*'),legend=c('mode','median','mean'))

result=data.frame(n,mode=unlist(Y['mode',]),median=unlist(Y['median',]),
mean=round(unlist(Y['mean',]),1))
result[1:20,]
result[21:40,]
tail(result)
n[floor(result[,'mode'])!=result[,'mode']] # multiple

233卵の名無しさん2018/11/18(日) 11:20:38.75ID:uPZ4H5RS
>>227
(2)の答は4個あるな。

234卵の名無しさん2018/11/18(日) 13:29:06.59ID:uPZ4H5RS
>>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卵の名無しさん2018/11/18(日) 17:41:08.98ID:uPZ4H5RS
>>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卵の名無しさん2018/11/19(月) 00:27:20.08ID:6+hS1SxI
i tried it in Showa u motherfucker. in that time niggers were supposed be in what niggahz were supposed to be motherfucking in, which we call a discrimination.
they pay shit loaded money to motherfucking niggers ass-bitch cocksucker fucking gringo homosexual hobo
i mean fuck you all go down hell

237卵の名無しさん2018/11/19(月) 06:06:04.36ID:tA4kj3ba
2^3はpythonで1を返す
ビット演算子(~, &, |, ^, <<, >>)
2**3 か pow(2,3)で冪乗

238卵の名無しさん2018/11/19(月) 06:40:59.39ID:tA4kj3ba
練習に、これを移植したいなぁ。
http://www.geocities.jp/m_hiroi/puzzle/water_jug.html

239卵の名無しさん2018/11/19(月) 06:43:11.58ID:tA4kj3ba

240卵の名無しさん2018/11/19(月) 07:27:32.80ID:tA4kj3ba
>>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卵の名無しさん2018/11/19(月) 07:29:17.17ID:tA4kj3ba
>>240

問題はこれ

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

242卵の名無しさん2018/11/19(月) 07:31:08.11ID:tA4kj3ba
こっちの方が断然、難関。

油分け算

[問題] 油分け算

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

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

243卵の名無しさん2018/11/19(月) 08:12:59.88ID:tA4kj3ba
>>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卵の名無しさん2018/11/19(月) 08:25:49.04ID:tA4kj3ba
>>239
これは可能な組み合わせを列挙しているだけで必ずしも手順をしめすプログラムじゃないな。

245卵の名無しさん2018/11/19(月) 08:30:40.71ID:L6cqzabr
i tried it in Showa u motherfucker. in that time niggers were supposed be in what niggahz were supposed to be motherfucking in, which we call a discrimination.
they pay shit loaded money to motherfucking niggers ass-bitch cocksucker fucking gringo homosexual hobo
i mean fuck you all go down hell

246卵の名無しさん2018/11/19(月) 12:28:58.07ID:xPquTj4a
>>240
[(0,0),(0,3),(3,0),(3,3),(4,2),(0,2)] というのが数学板で返された

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

248卵の名無しさん2018/11/19(月) 15:18:00.83ID:/8nCvktv
>>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卵の名無しさん2018/11/19(月) 15:21:56.75ID:/8nCvktv
>>247
ド底辺シリツ医大卒の知性を表すような文章だなぁ。

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

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

あれかな?

あれだよね?

あれ

あれ








250卵の名無しさん2018/11/19(月) 15:46:07.22ID:/8nCvktv
[問題]
30 リットルの容器 A に油が満杯に入っています。これを 17 リットルの容器 B と 13 リットルの容器 C を使って二等分してください。容器 A と B には 15 リットルずつ油が入ります。油を二等分する手順を求めてください。
[30,0,0]
[13,17,0]
[13,4,13]
[26,4,0]
[26,0,4]
[9,17,4]
[9,8,13]
[22,8,0]
[22,0,8]
[5,17,8]
[5,12,13]
[18,12,0]
[18,0,12]
[1,17,12]
[1,16,13]
[14,16,0]
[14,3,13]
[27,3,0]
[27,0,3]
[10,17,3]
[10,7,13]
[23,7,0]
[23,0,7]
[6,17,7]
[6,11,13]
[19,11,0]
[19,0,11]
[2,17,11]
[2,15,13]
[15,15,0]

251卵の名無しさん2018/11/19(月) 18:20:27.15ID:lgLouqKT
ネットで口汚くあちこちのスレを荒らしている国試浪人の事務員だが
この世に彼奴を下回るカスがいるだろうか
いや居ない
リアルではだれも口にしないが、みな思っていることだ

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

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

252卵の名無しさん2018/11/19(月) 20:30:41.47ID:/8nCvktv
rm(list=ls())

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

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

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

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

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

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

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

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

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

254卵の名無しさん2018/11/19(月) 21:00:32.27ID:/8nCvktv

255卵の名無しさん2018/11/19(月) 22:04:51.47ID:vmWf+9X3
actions = c(a2b,a2c,b2c,c2a,c2a,c2b)

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

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

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

transit=transfer(init)


push <- function(x){
n=nrow(x)
for(i in 1:n){
if(!is.vim(x[i,],stacks)) stacks=rbind(x[i,],stacks)
if(is.goal(x[i,])) break
}
return(stacks)
}
stacks=push(transit)

256卵の名無しさん2018/11/19(月) 22:22:12.67ID:vmWf+9X3

257卵の名無しさん2018/11/19(月) 22:29:14.48ID:vmWf+9X3
>>251
期待に反して悪いが俺、事務員じゃないんだね。

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

879 卵の名無しさん sage 2018/11/15(木) 07:18:18.94 ID:LT687Ilf
>>878
>875は脾弯越えの操作でpullする時の話。
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚

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

258卵の名無しさん2018/11/19(月) 22:31:41.85ID:vmWf+9X3
>>251
国立卒はちゃんとわかってる。

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

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

>http://2chb.net/r/hosp/1537519628/101-102
>http://2chb.net/r/hosp/1537519628/844-853
ID:RFPm1BdQ

>http://2chb.net/r/hosp/1537519628/869
>http://2chb.net/r/hosp/1537519628/874-875
>http://2chb.net/r/hosp/1537519628/874-880
>http://2chb.net/r/hosp/1537519628/882
ID:liUvUPgn

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

3.リアルでは皆思ってるだけで口に出してないだけ
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚

259卵の名無しさん2018/11/19(月) 22:42:33.31ID:zhu5ykUr
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.

260卵の名無しさん2018/11/19(月) 23:01:00.76ID:vmWf+9X3
>>251
統計スレに投稿するならこれくらい答えてみ。
話題のド底辺シリツ医大裏口入学を題材にした問題。

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

261卵の名無しさん2018/11/19(月) 23:13:28.02ID:vmWf+9X3
actions = c(a2b,a2c,b2c,c2a,c2a,c2b)

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

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

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

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

push <- function(x){ #新規のみスタックに積む
n=nrow(x)
for(i in 1:n){
if(!is.vim(x[i,],stacks)) stacks=rbind(x[i,],stacks)
if(is.goal(x[i,])) break #ゴールしてたらループをぬける
}
return(stacks) #新スタックを返す
}
stacks=push(transit)

262卵の名無しさん2018/11/20(火) 07:42:56.98ID:jEVjKi6n
>>251
んで、あんたどこ卒?

263卵の名無しさん2018/11/20(火) 07:48:14.29ID:jEVjKi6n
>>261
探索経路を記録するのと
移転で過去の状態に戻るのをカウントから外す必要があるなぁ。

264卵の名無しさん2018/11/20(火) 08:30:59.02ID:GReM9fuK
ネットで口汚くあちこちのスレを荒らしている国試浪人の事務員だが
この世に彼奴を下回るカスがいるだろうか
いや居ない
リアルではだれも口にしないが、みな思っていることだ

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

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

265卵の名無しさん2018/11/20(火) 11:38:05.66ID:+LTJHbMS
油分け算のRスクリプトようやく完成

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

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

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

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

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

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

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

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

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

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

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

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

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

transfer <- function(x){ # return unchekcked transferred state
re=NULL
for(fun in actions){ # try all methods
v=fun(x) # drop checked state and itself
if(!is.rim(v,.checked) & !all(v==x)) re=rbind(re,fun(x))
}
uni.re=unique(re) # delete duplicated
.checked <<- rbind(uni.re,.checked) # add to .checked GLOBELY
return(uni.re)
}

268卵の名無しさん2018/11/20(火) 11:39:23.04ID:+LTJHbMS
state=NULL
while(!is.goal(.stack[1,])){
push(transfer(pop()))
state=rbind(state,.stack[1,])
}

> state
[,1] [,2] [,3]
[1,] 3 7 0
[2,] 0 7 3
[3,] 3 4 3
[4,] 6 4 0
[5,] 6 1 3
[6,] 9 1 0
[7,] 9 0 1
[8,] 2 7 1
[9,] 2 5 3
[10,] 5 5 0

269卵の名無しさん2018/11/20(火) 13:27:38.76ID:+LTJHbMS
>>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卵の名無しさん2018/11/20(火) 15:06:09.76ID:6Tvud5kf
i tried it in Showa u motherfucker. in that time niggers were supposed be in what niggahz were supposed to be motherfucking in, which we call a discrimination.
they pay shit loaded money to motherfucking niggers ass-bitch cocksucker fucking gringo homosexual hobo
i mean fuck you all go down hell

271卵の名無しさん2018/11/20(火) 17:14:24.57ID:+LTJHbMS
ようやくデバッグできた。

> state=t0
> while(!is.goal(.stack[1,])){
+ (p=pop())
+ (tr=transfer(p))
+ (.checked <<- unique(rbind(p,.checked))) # add to .checked GLOBELY
+ push(tr)
+ (.stack)
+ if(!is.null(transfer(.stack[1,]))) state=rbind(state,.stack[1,])
+ }
> rownames(state)=NULL
> colnames(state)=c(Amax,Bmax,Cmax)
> state
10 7 3
[1,] 10 0 0
[2,] 3 7 0
[3,] 3 4 3
[4,] 6 4 0
[5,] 6 1 3
[6,] 9 1 0
[7,] 9 0 1
[8,] 2 7 1
[9,] 2 5 3
[10,] 5 5 0

272卵の名無しさん2018/11/20(火) 17:15:16.68ID:+LTJHbMS
目的のノードを見つけたら終了する仕様だから、最短かどうかはわからないなぁ。

273卵の名無しさん2018/11/20(火) 17:21:50.40ID:cc4OhAKi
仕事しないとなぁ

274卵の名無しさん2018/11/20(火) 17:53:04.65ID:3jy0dpIg
>>264
>>251
んで、あんたどこ卒?
きっと凄いとこ出てますね、と言われるぞw

275卵の名無しさん2018/11/20(火) 18:23:06.98ID:cc4OhAKi
時給の良い仕事ないかなぁ?

276卵の名無しさん2018/11/20(火) 18:44:46.44ID:cc4OhAKi
ハローワークで警備の仕事があるなぁ。

277卵の名無しさん2018/11/20(火) 19:45:03.72ID:+LTJHbMS
# 問題 : 7 リットルと 3 リットルの容器を使って 5 リットルの水を測るにはどうすればいい?

> state
7 3
[1,] 0 0
[2,] 7 0
[3,] 4 3
[4,] 4 0
[5,] 1 3
[6,] 1 0
[7,] 0 1
[8,] 7 1
[9,] 5 3
[10,] 5 0

278卵の名無しさん2018/11/20(火) 20:18:02.67ID:HF+OgDBw
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.

279卵の名無しさん2018/11/20(火) 22:25:53.92ID:cc4OhAKi
人間関係のない時給の良い仕事はないかなぁ?いじめられるからなぁ

280卵の名無しさん2018/11/20(火) 22:27:11.31ID:D0iJ9Tsc
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

281卵の名無しさん2018/11/20(火) 22:32:57.27ID:cc4OhAKi
仕事ください

282卵の名無しさん2018/11/20(火) 22:39:03.37ID:cc4OhAKi
なんの取り柄もない私に仕事をください

283卵の名無しさん2018/11/20(火) 22:41:23.23ID:cc4OhAKi
なんかの資格があったらなぁ 仕事がないなぁ 今になって悔やんでしまう

284卵の名無しさん2018/11/20(火) 22:48:29.81ID:cc4OhAKi
金がない!

285卵の名無しさん2018/11/20(火) 22:51:11.25ID:cc4OhAKi
もっと金になる勉強をすべきだった 仕事がないなぁ

286卵の名無しさん2018/11/20(火) 22:57:18.11ID:cc4OhAKi
このまま 社会に出ずに 人生が終わってしまうのか?なんだったんだろう俺の人生は?

287卵の名無しさん2018/11/20(火) 23:39:20.88ID:cc4OhAKi
明日 また ハローワーク行こう!

288卵の名無しさん2018/11/21(水) 09:42:48.41ID:Jctp5Wds
>268-269のバグを指摘できていたら見直すのだが
底辺学力でできるのは>197のような漢字の誤変換だけ。

289卵の名無しさん2018/11/21(水) 12:38:48.27ID:m3dnATiO
ド底辺スレの定期上げ

290卵の名無しさん2018/11/21(水) 13:50:41.23ID:cCF4eIpe
じゃ、定期あげ

291卵の名無しさん2018/11/21(水) 15:05:19.22ID:UV5R2p03
>>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卵の名無しさん2018/11/21(水) 20:50:08.75ID:5Xwsg5oK
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

293卵の名無しさん2018/11/21(水) 21:27:39.69ID:m3dnATiO
非医師の人たちへむけて 今日の1曲

愛国戦隊大日本

294卵の名無しさん2018/11/21(水) 22:11:11.00ID:UV5R2p03
rm(list=ls())
graphics.off()

dlevy <- function (x,m,c) sqrt(c/2/pi)*exp(-c/2/(x-m))/(x-m)^3/2
set.seed(123)
dat=rgamma(1e4,1)
hist(dat,freq=F) ; summary(dat)
x=density(dat)$x ; y=density(dat)$y
lines(x,y)
f<-function(mc){
m=mc[1];c=mc[2]
sum((y-dlevy(x,m,c))^2)
}
(mc=optim(c(0,1),f, method='N')$par)
curve(dlevy(x,mc[1],mc[2]),add=T,col=2)

295卵の名無しさん2018/11/21(水) 22:12:01.19ID:UV5R2p03
>>294
これへの回答

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

296卵の名無しさん2018/11/21(水) 22:46:03.55ID:uT58TBet
量子力学は?www

297卵の名無しさん2018/11/21(水) 23:46:11.38ID:tbX2fKWG
ボーズ粒子の実態は確率

298卵の名無しさん2018/11/21(水) 23:59:20.99ID:uT58TBet
国試諦めたんだねw

299卵の名無しさん2018/11/22(木) 00:06:46.65ID:jXQTlLg4
>>172
残念ながら、事務員じゃないのね。
こういうの書いているの俺な。

内視鏡検査について Part.2 [無断転載禁止](c)2ch.net
http://2chb.net/r/hosp/1499746033/875

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

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

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.

301卵の名無しさん2018/11/22(木) 19:48:22.68ID:EhyhVVko
30L 17L 13L
[1,] 30 0 0
[2,] 13 17 0
[3,] 13 4 13
[4,] 26 4 0
[5,] 26 0 4
[6,] 9 17 4
[7,] 9 8 13
[8,] 22 8 0
[9,] 22 0 8
[10,] 5 17 8
[11,] 5 12 13
[12,] 18 12 0
[13,] 18 0 12
[14,] 1 17 12
[15,] 1 16 13
[16,] 14 16 0
[17,] 14 3 13
[18,] 27 3 0
[19,] 27 0 3
[20,] 10 17 3
[21,] 10 7 13
[22,] 23 7 0
[23,] 23 0 7
[24,] 6 17 7
[25,] 6 11 13
[26,] 19 11 0
[27,] 19 0 11
[28,] 2 17 11
[29,] 2 15 13
[30,] 15 15 0

302卵の名無しさん2018/11/22(木) 22:15:42.49ID:jXQTlLg4
>>300
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.
この通り、実践すべき!

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

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

303卵の名無しさん2018/11/22(木) 22:49:22.84ID:s6txpOAx
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.

304卵の名無しさん2018/11/23(金) 07:36:18.66ID:t+QLwcrH
main = print $ length [(x,y)|x<-[-100..100],y<-[-100..100],7*x+3*y==5,abs x + abs y <= 100]

305卵の名無しさん2018/11/23(金) 07:45:24.89ID:Qqz1atCA
統計の話をしよう!!
サルを何千万匹殺しても無問題!!ただし、共産主義の香りづけをすれば

306卵の名無しさん2018/11/23(金) 08:10:20.25ID:QoVjbOvp
for x in range(-100,101):
for y in range(-100,101):
if(7*x+3*y==5 and x+y<=100):
print("(" + str(x) + "," + str(y) + ")")

307卵の名無しさん2018/11/23(金) 08:27:21.45ID:QoVjbOvp
>>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卵の名無しさん2018/11/23(金) 08:28:05.53ID:QoVjbOvp
R

gr=expand.grid(-100:100,-100:100)
f=function(x,y) 7*x+3*y==5 & abs(x)+abs(y)<=100
sum(mapply(f,gr[,1],gr[,2]))

309卵の名無しさん2018/11/23(金) 08:29:57.03ID:QoVjbOvp
R
re=NULL
for(x in -100:100){
for(y in -100:100){
if(7*x+3*y==5 & abs(x)+abs(y)<=100){
re=rbind(re,(c(x,y)))}}}
nrow(re)

310卵の名無しさん2018/11/23(金) 10:32:55.82ID:QoVjbOvp
# Python

a=7; b=3; c=5
n=100
xy = []
for x in range(-n,n+1):
for y in range(-n,n+1):
if(a*x+b*y==c and abs(x)+abs(y)<=n):
xy.append([x,y])
print (len(xy))
print (xy)

311卵の名無しさん2018/11/23(金) 18:35:27.02ID:QoVjbOvp
# ある医院に1時間あたり平均5人の患者が来院し、その人数の分布はポアソン分布にしたがうとする。
# 1時間あたりの平均診療人数は6人(平均診療時間10分)で、一人あたりの診療時間は指数分布に従うとする。
# 診察までの平均の待ち時間は何分か?
λ=5
μ=6

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

シミュレーション結果も

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

理論値通りだな。

312卵の名無しさん2018/11/23(金) 19:10:32.75ID:QoVjbOvp

313卵の名無しさん2018/11/23(金) 22:53:03.27ID:t+QLwcrH
1時間に平均値5人の患者がくる医院で
次の患者がくるまでの時間が10分以内である確率と
30分以上である確率はいくらか?

314卵の名無しさん2018/11/24(土) 01:25:40.73ID:5hOk6q/8
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

315卵の名無しさん2018/11/24(土) 11:07:29.76ID:wOJ88Y8z
deli <- function(course=90,hr=15,call=5){
# average 5 calls during 15 hours with 90 min delivery
k=call/hr
integrate(function(x)k*exp(-k*x),0,course/60)$value
}
vd=Vectorize(deli)
dc=0:180
plot(dc,vd(dc),type='l',lwd=2,bty='l',
xlab='Deli.course(min)',ylab='Prob of call')

316卵の名無しさん2018/11/24(土) 11:42:17.66ID:wOJ88Y8z
deli <- function(course=90,hr=15,call=5){
# average 5 calls during 15 hours with 90 min delivery
k=call/hr
integrate(function(x)k*exp(-k*x),0,course/60)$value
}
vd=Vectorize(deli)
dc=0:180
plot(dc,vd(dc),type='l',lwd=2,bty='l',
xlab='Deli.course(min)',ylab='Prob of call')

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

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

p2c=function(p,k=5/15) (-60*log(1-p)/k)
curve(p2c(x),bty='l',xlab='p',ylab='course(min)')

317卵の名無しさん2018/11/24(土) 13:12:14.88ID:owOvYQ4F
このスレの自称医者のほんまもん医師確率は?

検索した知識で医者を騙りMath
http://2chb.net/r/hosp/1541780622/

318卵の名無しさん2018/11/24(土) 14:11:47.95ID:4kuDQ9FR
こういうのを見ればわかるだろうに

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

>>878
>875は脾弯越えの操作でpullする時の話。
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚

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

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

319卵の名無しさん2018/11/24(土) 14:18:05.42ID:4kuDQ9FR
>>316

これ用のスクリプト

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

320卵の名無しさん2018/11/24(土) 16:38:49.21ID:wOJ88Y8z
two sample poisson test

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

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

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

library(rateratio.test)
rateratio.test(c(X,Y),c(N,M))$p.value
2*min(binom.test(X,X+Y,P,alt='l')$p.value,
binom.test(X,X+Y,P,alt='g')$p.value)

321卵の名無しさん2018/11/24(土) 17:00:00.40ID:wOJ88Y8z
救急車搬送数が日勤の8時間で0、夜勤の16時間で5であったときに
夜勤帯の方が時間あたり救急搬送が多いと言えるか?
救急車搬送数はポアソン分布に従うとして有意水準5%で検定せよ。

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

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

y=sapply(x,function(x) rateratio.test(c(1,x),c(8,16))$p.value)
plot(x,y,bty='l')
x[which.max(y<0.05)]

322卵の名無しさん2018/11/24(土) 17:01:06.35ID:wOJ88Y8z
>>321
日勤と夜勤でお看取り件数に差があるかも検定できるな。

323卵の名無しさん2018/11/24(土) 20:15:42.14ID:mGu7MkO8
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.

324卵の名無しさん2018/11/24(土) 20:20:35.00ID:4kuDQ9FR
f = function(A=1,B=2,N=100){
p=0
for (i in 1:N){
for(j in 0:(i-1)){
p=p+dpois(i,A)*dpois(j,B)}}
p
}
f()
f(1,3)

325卵の名無しさん2018/11/24(土) 20:31:46.81ID:4kuDQ9FR
soccer= function(A=1,B=2,N=1000){
pa=pd=0
for (i in 1:N){
for(j in 0:(i-1)){
pa=pa+dpois(i,A)*dpois(j,B)
pd=pd+dpois(i,A)*dpois(i,B)
}}
c(Awin=pa,Bwin=1-pa-pd,Draw=pd)
}

soccer()

326卵の名無しさん2018/11/24(土) 20:39:49.49ID:4kuDQ9FR
>>325
サッカーの勝敗確率

327卵の名無しさん2018/11/24(土) 20:47:34.09ID:4kuDQ9FR
>>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卵の名無しさん2018/11/25(日) 02:02:43.79ID:JOuyBVrN
ポイント乞食ご用達の楽天銀行に貯金していて、
楽天に口座凍結されて無一文になった世田谷のS君 元気??

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

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

329卵の名無しさん2018/11/25(日) 08:07:10.02ID:Vr8P87vG
マルコフの確認
(pexp(2+4,1/3)-pexp(2,1/3))/(1-pexp(2,1/3))
pexp(4,1/3)

330卵の名無しさん2018/11/25(日) 09:08:24.99ID:B7CJHmdM
k=15
a=20
b=30
(pexp(a+b,1/k)-pexp(a,1/k))/(1-pexp(a,1/k))
pexp(b,1/k)

331卵の名無しさん2018/11/25(日) 12:02:52.13ID:9toFqzz4
k=15
a=20
b=30
y=function(x) 1-exp(-x/k)
(y(a+b)-y(a))/(1-y(a))
y(b)

332卵の名無しさん2018/11/25(日) 12:19:14.40ID:9toFqzz4
>>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卵の名無しさん2018/11/25(日) 12:22:57.28ID:9toFqzz4
debugged with equivalent routine

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

}}
return(c(Upset=pa,Ordinal=1-pa-pd,Draw=pd))
}

334卵の名無しさん2018/11/25(日) 12:45:46.33ID:9toFqzz4
>>333
if(A==B) return(c(c(Upset=0,Ordinal=0,Draw=1)))
は不要だな。

335卵の名無しさん2018/11/25(日) 12:49:45.63ID:9toFqzz4
サッカーの特典はポアソン分布に従うとされている。

PK戦はなしで考える。

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

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

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

> soccer(2,3)
Upset Ordinal Draw
0.2469887 0.5920274 0.1609839

336卵の名無しさん2018/11/25(日) 12:52:38.63ID:9toFqzz4
>>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卵の名無しさん2018/11/25(日) 14:41:03.20ID:9toFqzz4
λ0=3/60  # 平均到達率
μ0=4/60 # 平均サービス率 1/μ0 : 平均サービス時間
(ρ0=λ0/μ0) # 平均トラフィック密度


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

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

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

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

338卵の名無しさん2018/11/25(日) 15:33:46.37ID:9toFqzz4
>>331
答えから、指数分布のマルコフ性が導き出されていることを確認

339卵の名無しさん2018/11/25(日) 21:52:47.06ID:9toFqzz4
# 10分に2本の割合で電車が到着するダイヤ。
# それぞれの平均待ち時間を求めてみよう
# 5分おきのダイヤでの、平均待ち時間は何分か?
i=j=5
fij <- function(x){
if(x<i) return(i-x)
return(i+j-x)
}
fij=Vectorize(fij)
curve(fij(x),0,10,type='h')
integrate(fij,0,10)$value/10

# 2(=i)分後、8(=j)分後、と電車が到着するダイヤでの平均待ち時間は何分か?
i=2 ; j=8 # 8:00,8:02,8:10,8:12,8:20,...
fij <- function(x){
if(x<i) return(i-x)
return(i+j-x)
}
fij=Vectorize(fij)
curve(fij(x),0,i+j,type='h')
integrate(fij,0,i+j)$value/(i+j)

340卵の名無しさん2018/11/25(日) 22:09:31.18ID:9toFqzz4
# 8:15,8:50,9:15,9:50,10:15,10:50....
i=50-15 ; j=60-(50-15)
fij <- function(x){
if(x<i) return(i-x)
return(i+j-x)
}
fij=Vectorize(fij)
curve(fij(x),0,i+j,type='h')
integrate(fij,0,i+j)$value/(i+j)
(i*i/2+(60-i)*j/2)/(i+j)

341卵の名無しさん2018/11/25(日) 22:53:07.02ID:JHTxnUVJ
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.

342卵の名無しさん2018/11/26(月) 00:38:59.24ID:ZChMNBQH
数学板の質問スレに俺でも答えられる問題がでるとホッとするな。
簡単すぎて誰も答えないからというのもあるが。

343卵の名無しさん2018/11/26(月) 01:19:35.09ID:ZChMNBQH
時刻表から平均待ち時間を算出する。

tt=c(0,10,13,20,23,30,40,47,50,60) # time table
ct2wt <- function(x){ # clock time to waiting time
n=length(tt)
if(x<=tt[1]){w8=tt[1]-x
}else{
for(i in 1:(n-1)){
if(tt[i]<=x & x<=tt[i+1]){
w8=(tt[i+1]-x)
break
}
}}
return(w8)
}
ct2wt=Vectorize(ct2wt)
curve(ct2wt(x),0,60,type='h',bty='l')
integrate(ct2wt,0,60)$value/60
x=diff(tt)
sum(x^2/2)/sum(x)

344卵の名無しさん2018/11/26(月) 01:24:22.62ID:iwt1L6U2
ちっちっ×××× ちっち××××
××××ち××××
へいたんな×× おうとつない
×××だけぷっくりしてるの
あまいあじがするから××てほしいな?
にゃにゃにゃにゃにゃにゃにゃん☆

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

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

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

345卵の名無しさん2018/11/26(月) 07:32:00.16ID:ZChMNBQH
>>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卵の名無しさん2018/11/26(月) 07:50:43.97ID:ZChMNBQH
>>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卵の名無しさん2018/11/26(月) 07:51:08.82ID:ZChMNBQH
>>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卵の名無しさん2018/11/26(月) 18:21:38.38ID:ZDBUmL4t
>>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卵の名無しさん2018/11/26(月) 19:10:20.76ID:WZnn9Mtx
Last but not least, three laws of Do-Teihen(lowest-tier) Medical School, currently called Gachi'Ura by its graduates.
It is not the bottom medical school but its enrollee that is despicable, which deserves to be called a bona fide moron beyond redemption.
The graduates of Do-Teihen are so ashamed that none of them dare to mention their own alma mater they had gone through.
The Do-Teihen graduates are so ashamed of having bought their way into the exclusively lowest-tier medical school
that they tend to call a genuine doctor a charlatan who elucidates their imbecility.

350卵の名無しさん2018/11/26(月) 20:45:26.65ID:G0yfFsA6
>>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卵の名無しさん2018/11/27(火) 08:33:47.65ID:WzO5TT32
Pn(t)=rho^n/n!P0(t) ,1<=n<=s

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

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

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

352卵の名無しさん2018/11/27(火) 08:48:31.40ID:WzO5TT32
Pn(t)=rho^n/n!P0(t) ,1<=n<=s

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

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

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卵の名無しさん2018/11/27(火) 09:47:23.68ID:WzO5TT32
MMS = function(n, lamda=1/20,mu=1/10,s=3){
rho=lamda/mu
sig=0
for(i in 0:s) sig=sig+rho^i/factorial(i)
p0=1/( sig + rho^(s+1)/factorial(s)/(s-rho) )
ifelse(n >= s, rho^n/factorial(s)/s^(n-s)*p0, rho^n/factorial(n)*p0)
}
1-sum(sapply(0:3,MMS))

354卵の名無しさん2018/11/27(火) 09:48:36.29ID:WzO5TT32
演習問題
&#61550; 問題
&#61550; 電話回線のチケット予約システムがあり、その窓口数は3であ

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

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

355卵の名無しさん2018/11/27(火) 09:56:32.58ID:WzO5TT32
>>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卵の名無しさん2018/11/27(火) 09:57:04.81ID:WzO5TT32
MMS = function(n, lamda=1/20,mu=1/10,s=3){
rho=s*lamda/mu
sig=0
for(i in 0:s) sig=sig+rho^i/factorial(i)
p0=1/( sig + rho^(s+1)/factorial(s)/(s-rho) )
ifelse(n >= s, rho^n/factorial(s)/s^(n-s)*p0, rho^n/factorial(n)*p0)
}
1-sum(sapply(0:3,MMS))

357卵の名無しさん2018/11/27(火) 09:59:56.71ID:WzO5TT32
MMS = function(n, λ=1/20,μ=1/10,s=3){
ρ=s*λ/μ
sig=0
for(i in 0:s) sig=sig+ρ^i/factorial(i)
p0=1/( sig + ρ^(s+1)/factorial(s)/(s-ρ) )
ifelse(n >= s, ρ^n/factorial(s)/s^(n-s)*p0, ρ^n/factorial(n)*p0)
}
1-sum(sapply(0:3,MMS))

358卵の名無しさん2018/11/27(火) 10:36:18.18ID:WzO5TT32
MMS = function(n, λ=1/20,μ=1/10,s=3){
ρ=λ/μ
sig=0
for(i in 0:s) sig=sig+ρ^i/factorial(i)
p0=1/( sig + ρ^(s+1)/factorial(s)/(s-ρ) )
ifelse(n >= s, ρ^n/factorial(s)/s^(n-s)*p0, ρ^n/factorial(n)*p0)
}

359卵の名無しさん2018/11/27(火) 11:23:34.49ID:WzO5TT32
draft

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

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

1-now8(1)

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

n=(1:10)[which.max(sapply(1:10,now8)>0.9)]
now8(n)

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

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

# No Wait Probability when s=x
nwp=function(x,lambda,mu){
p=0
for(i in 0:x) p=p+MMS(i,lambda,mu,s=x)
p
}
nwp(1,lambda,mu)
nwp(2,lambda,mu)

361卵の名無しさん2018/11/27(火) 13:05:37.04ID:RTIAbEXI
問題(第1種情報処理技術者試験・平成元年度春期午前問17を改題)

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

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

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

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

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

362卵の名無しさん2018/11/27(火) 13:53:38.67ID:RTIAbEXI
# ある医院では、患者が平均10分間隔でポアソン到着にしたがって訪ねてくることがわかった。
# 医者は1人であり、1人の患者の診療にかかる時間は平均8分の指数分布であった。
# 「平均待ち時間」を5分以下にするには同じ診察効率の医師が何人に必要か?
# その最小人数で「平均待ち時間」を5分以下に保って診療するには1時間に何人まで受付可能か?
sapply(1:3,function(x) MMS(0,1/10,1/8,x)['Wq'])
MMS(0,1/10,1/8,s=2)
f= function(l) MMS(0,l,mu=1/8,s=2)['Wq']
v=Vectorize(f)
curve(v(x),bty='l',0,2/8) # rho=l/m < s , l < s*m
abline(h=5,lty=3)
60*uniroot(function(x)v(x)-5,c(0.1,0.2))$root
MMS(0,9.3/60,mu=1/8,s=2)

363卵の名無しさん2018/11/27(火) 15:40:44.01ID:RTIAbEXI
# M/M/S(s)
MMSs <- function(n,lambda,mu,s){
if(n > s) return(0)
rho=lambda/mu # rho < s
sig=0
for(i in 0:s) sig=sig+rho^i/factorial(i)
Pn=rho^n/factorial(n)/sig
return(Pn)
}
s=3
sapply(0:s,function(x) MMSs(x,1/20,1/10,s))
cnvg=function(x,lambda,mu) MMSs(x,lambda,mu,x) # 輻輳 convergence
vc=Vectorize(function(x) cnvg(x,10/60,1/30))
(1:10)[vc(1:10) < 0.05]

364卵の名無しさん2018/11/27(火) 18:51:54.59ID:sOmaXwxS
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

365卵の名無しさん2018/11/27(火) 20:30:45.92ID:RTIAbEXI
mms <- function(n,lambda,mu,s,t=0,Print=TRUE){
alpha=lambda/mu
rho=lambda/s/mu # alpha=s*rho
sig0=0
for(i in 0:(s-1)) sig0=sig0+alpha^i/factorial(i)
P0=1/( sig0 + alpha^s/factorial(s-1)/(s-alpha) )
Pn=ifelse(n >= s, alpha^n/factorial(s)/s^(n-s)*P0, alpha^n/factorial(n)*P0)
Lq=lambda*mu*alpha^s/factorial(s-1)/(s*mu-lambda)^2*P0
L=Lq+alpha
Wq=Lq/lambda
#=mu*alpha^s/factorial(s-1)/(s*mu-lambda)^2*P0
W=Wq+1/mu
Pc=mu*P0*alpha^s/factorial(s-1)/(s*mu-lambda)
#=s^s*P0/factorial(s)*rho^s/(1-rho)
PTt=Pc*exp(-(1-rho)*s*mu*t)
output=c(P0=P0,Pn=Pn,Lq=Lq,L=L,Wq=Wq,W=W,Pc=Pc,PTt=PTt)
# P0:0 in system, Pn:n in system, Lq:guests in que, Wq: waiting time in que
# L:quests in system, W:total waiting time, Pc:all windows occupied,
# P: waiting time in que greater than t
if(Print) print(output,digits=3)
invisible(output)
}
mms(n=0,lambda=1/60,mu=1/10,s=1,t=0)

366卵の名無しさん2018/11/27(火) 20:40:29.10ID:2tUinJG4
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

367卵の名無しさん2018/11/27(火) 21:06:39.05ID:RTIAbEXI
レジが1台ある。客の到着が1時間あたり平均12人であり、
レジの所要時間が平均3分のとき,次の値を求めてみよう。
?到着したとき,すぐにサービスが受けられる確率
?系の中にいる人の平均人数
?サービスを待っている人の平均人数
?到着してからサービスを受けて去るまでの平均時間

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

368卵の名無しさん2018/11/27(火) 21:08:46.15ID:RTIAbEXI
筆算は面倒。数値を変えても算出できるようにした。

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

> mms(0,12/60,1/3,1)
P0 Pn Lq L Wq W Pc PTt
0.4 0.4 0.9 1.5 4.5 7.5 0.6 0.6
> uniroot(function(x) mms(0,24/60,1/x,1,P=F)['W']-7.5,c(0.1,2))$root
[1] 1.874993

369卵の名無しさん2018/11/27(火) 23:07:59.15ID:RTIAbEXI
# M/M/s/K
MMSK <- function(lambda,mu,s,k){
alpha=lambda/mu
sig1=sig2=0
for(n in 0:s) sig1=sig1+alpha^n/factorial(n)
if(k>s) for(n in 1:(k-s)) sig2=sig2+alpha^s/s*(alpha/s)^n
Psk=s^s/factorial(s)*(alpha/s)^k/(sig1+sig2)
return(Psk)
}

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

a=seq(0,3,len=101)
plot(a,sapply(a,function(x)E2s(x,s=1)),type='l',bty='l',ylab='call loss prob.')
lines(a,sapply(a,function(x)E2s(x,s=2)),lty=2)
lines(a,sapply(a,function(x)E2s(x,s=3)),lty=3)

370卵の名無しさん2018/11/27(火) 23:08:01.08ID:yIHJQdw7
音楽の問題です

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

371卵の名無しさん2018/11/28(水) 07:55:01.98ID:5n5kFcMp
f <- function() sum(rbinom(10,3,1/3)==rbinom(10,3,1/3))
g <- function(k) mean(replicate(k,f()))
h=Vectorize(g)
x=seq(1000,100000,by=1000)
re=h(x)
plot(x,re,pch=19,bty='l',ann=F)

372卵の名無しさん2018/11/28(水) 08:08:55.83ID:5n5kFcMp
f <- function() sum(rbinom(10,3,1/3)==rbinom(10,3,1/3))
g <- function(k) mean(replicate(k,f()))
h=Vectorize(g)
x=seq(1000,100000,by=1000)
re=h(x)
plot(x,re,pch=19,bty='l',ann=F)

x=rep(100,10000)
y=h(x)
cx=cumsum(x)
cy=cumsum(y)/1:10000
plot(cx,cy,type='l')

373卵の名無しさん2018/11/28(水) 13:47:18.06ID:5n5kFcMp
rm(list=ls())
n=10 ; lambda=10/60 ; mu=1/8
# service starc clock time(ssct) since 9:00
ssct=numeric(n)
# waiting time(w8)
w8=numeric(n)
# service end clock time(sect)
sect=numeric(n)
# arrival clock time(act)
set.seed(1234) ; act=round(cumsum(rexp(n,lambda)))
# duration of service(ds)
set.seed(5678) ; ds=round(rexp(n,mu))

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

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

act[3] # 9:17
max(sect[2]-act[3],0) # 9:33 - 9:17 vs 0
w8[3]=max(sect[2]-act[3],0) # 16 min
ssct[3]=max(sect[2],act[3]) # 9:33 vs 9:17
sect[3]=ssct[3]+ds[3] # 9:33 + 11 = 9:44

374卵の名無しさん2018/11/28(水) 15:01:41.58ID:5n5kFcMp
# ある医院に1時間あたり平均5人の患者が来院し、その人数の分布はポアソン分布にしたがうとする。
# 1時間あたりの平均診療人数は6人で、一人あたりの診療時間は指数分布に従うとする。
# 診察までの平均の待ち時間は何時間か?

rm(list=ls())

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

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

# simulation assuming service starts at 9:00
head(act) # act : arrival clock time
head(ds) # ds : duration of service
# initial values
ssct[1]=act[1] # 9:15 service start clock time for 1st guest
sect[1]=act[1]+ds[1] # 9:25 sevice end clock time for 1st guest
w8[1]=0

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

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

w8m=replicate(1e3,mean(MM1sim(P=F)))
summary(w8m)

376卵の名無しさん2018/11/28(水) 19:33:11.50ID:5n5kFcMp
>>374
行列の長さが変わらない定常状態達したら理論値通りに動作しているようだ。
エラー処理はしていなし、細かいバグがあるかもしれないが、
一応完成。

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

377卵の名無しさん2018/11/28(水) 21:10:01.72ID:CEw4d3xR
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

378卵の名無しさん2018/11/29(木) 13:46:13.50ID:vdx9uljL
待ち行列理論の公式って
待ち行列の長さが変わらない定常状態での計算値だなぁ。

こういう設定に適応していいのか疑問があるな。
# Five clients comes every hour on average to the office,
# and the single clerk serves six clients every hour on average.
# n=40 ; lambda=5/60 ; mu=6/60

379卵の名無しさん2018/11/29(木) 13:47:25.88ID:vdx9uljL
シミュレーターを改良

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

# initial values
ssct[1]=act[1] # 9:15 service start clock time for 1st guest
sect[1]=act[1]+ds[1] # 9:25 sevice end clock time for 1st guest
Wq[1]=0

380卵の名無しさん2018/11/29(木) 13:47:48.53ID:vdx9uljL
for(i in 2:n){
Wq[i]=max(sect[i-1]-act[i],0)
ssct[i]=max(sect[i-1],act[i])
sect[i]=ssct[i]+ds[i]
}
W=Wq+ds
L=Lq=NA
if(Lcount){
ct2Lq <- function(ct){ # ct:clock time to Lq
sum(act<ct & ct<ssct)
}
Lq=mean(sapply(seq(0,max(ssct),len=1e4),ct2Lq)) # average clients in que
ct2L <- function(ct){ # ct:clock time to Lq
sum(act<ct & ct<sect)
}
L=mean(sapply(seq(0,max(ssct),len=1e4),ct2L)) # average clients in que
}
if(Brief){
cat("Lq = ",Lq,'\n',"summary of Waiting in que \n")
print(summary(Wq))
cat("L = ",L,'\n',"summary of total time since arrival \n")
print(summary(W))}

381卵の名無しさん2018/11/29(木) 13:48:05.65ID:vdx9uljL
if(Print){
par(mfrow=c(2,2))
hist(Wq,freq=FALSE,col="lightblue",main="Waiting time in que")
hist(W,freq=FALSE,col="lightgreen",main="Total time since arrival")
plot(sect,1:n,type='n',bty='l',ylab="client",xlab='clock time',
main=paste('average waiting time :',round(mean(Wq),2)))
segments(y0=1:n,x0=act,x1=ssct,col='gray')
points(act,1:n,pch=1)
points(ssct,1:n,pch=19)
points(sect,1:n,pch=3,cex=0.6)
legend('bottomright',bty='n',legend = c('arrival','service start','service end'),pch=c(1,19,3))
if(Lcount){ct=seq(0,max(ssct),len=1e4)
plot(ct,sapply(ct,ct2Lq),xlab="clock time",ylab="",main="clients in que",
type='s',bty='l')}
par(mfrow=c(1,1))
}
output=list(Wq=Wq,W=W,Lq=Lq,L=L,arrival=act,start=ssct,end=sect,duration=ds)
invisible(output)
}
MM1sim(n=40,Lcount=T,R=T,P=T,seed=F)

382卵の名無しさん2018/11/29(木) 14:01:23.60ID:vdx9uljL
来院数がポアソン分布(来院間隔は指数分布)、
診療時間はそれまでの患者の診療時間に影響されない(マルコフ性とか無記憶性と呼ばれる)ので指数分布
と仮定して、1時間に5人受診、診療時間は10分を平均値として受診数を40人としてシミュレーションすると
こんなにばらついた。
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚
待ち時間行列理論でクリニックの待ち時間計算すると現実と大きく乖離すると思える。

383卵の名無しさん2018/11/29(木) 14:23:01.20ID:vdx9uljL
来院数がポアソン分布(来院間隔は指数分布)、
診療時間はそれまでの患者の診療時間に影響されない(マルコフ性とか無記憶性と呼ばれる)ので指数分布
と仮定して、1時間に5人受診、診療時間は10分を平均値として受診数を40人としてシミュレーション。

その結果

診療までの待ち時間
> summary(Wqm)
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.793 11.828 19.204 26.041 34.621 164.905
診療終了までの時間
> summary(Wm)
Min. 1st Qu. Median Mean 3rd Qu. Max.
7.952 20.296 29.359 35.335 44.600 161.234
診療待ちの人数
> summary(Lqm)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.1821 0.8501 1.5866 2.0976 2.7414 11.2506

384卵の名無しさん2018/11/29(木) 14:52:35.68ID:vdx9uljL
受診者数と平均待ち時間をシミュレーションしてみた。
受診者数が増えれば待ち行列時間の理論値50分に収束していくようだ。

臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚

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

pexp(1,5/15)

386卵の名無しさん2018/11/29(木) 19:04:59.01ID:vdx9uljL
>>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卵の名無しさん2018/11/29(木) 21:16:08.05ID:W5xHj2Da
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

388卵の名無しさん2018/11/30(金) 10:07:25.16ID:c4eruZjZ
rm(list=ls())
graphics.off()
par(mfrow=c(1,2))
a=360 ; b=1
R = function(t) ifelse(0<=t&t<=2*b,-a*t*(t-2*b),0)
N = integrate(R,0,2*b)$value ; (N=4*a*b^3/3)
A = function(t) ifelse(0<=t&t<=2*b,-a*t^3/3 +a*b*t^2,N)
curve(A(x),0,3,lwd=2,bty='l',xlab='t')
mu=100
n.win=2
c=n.win*mu
curve(R(x),0,3,lwd=2,bty='l',xlab='t') ; abline(h=2:3*mu,lty=1:2)
uniroot(function(t) R(t)-c,c(0,1))$root
d = sqrt(b^2-c/a)
t1 = b - d ; t1
Q <- function(t) A(t)-A(t1)-c*(t-t1)
curve(Q(x),0,3,bty='l') ; abline(h=0,col=8)
Q. <- function(t) -a*(t-t1)^3/3 + a*d*(t-t1)^2
curve(Q.(x),0,3,bty='l') ; abline(h=0,col=8)
optimize(Q,c(0,1))$minimum
uniroot(Q,c(1,3))$root ; t1+3*d ; (t4.1=b+2*d)
Q(2*b)/c +2*b; (t4.2=a/3/c*(b+d)^2*(2*d-b) +2*b)
par(mfrow=c(1,1))
curve(A(x),0,3,lwd=2,bty='l',xlab='t')
curve(x*N/t4.1,add=T)
integrate(Q.,t1,t4.1)$value ; 9/4*a*d^4
integrate(Q.,t1,2*b)$value + 1/2*(t4.2-2*b)*Q.(2*b) ; a/36*(b+d)^3/(b-d)*(4*b*d-b^2-d^2)
integrate(Q.,t1,t4.1)$value/N
(integrate(Q.,t1,2*b)$value + 1/2*(t4.2-2*b)*Q.(2*b))/N

min(9/4*a*d^4,a/36*(b+d)^3/(b-d)*(4*b*d-b^2-d^2))/N

389卵の名無しさん2018/11/30(金) 10:11:24.11ID:c4eruZjZ
c2Wq <- function(c,a=360,b=1){ #-> Wq:平均待ち時間
# R(t): 到着率関数 -at(t-2b)
# c:サービス率
R = function(t) ifelse(0<=t&t<=2*b,-a*t*(t-2*b),0)
N=4*a*b^3/3
d = sqrt(b^2-c/a)
min(case1=9/4*a*d^4/N,case2=a/36*(b+d)^3/(b-d)*(4*b*d-b^2-d^2)/N)
}
c2Wq(300)

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

391卵の名無しさん2018/11/30(金) 14:12:35.52ID:c4eruZjZ
Q.<- function(t){
if(t1<=t & t<= min(t4,2*b)) -a*(t-t1)^3/3 + a*d*(t-t1)^2}
# -a*(t-t1)^3/3 + a*d*(t-t1)^2 # 解析値[t1,min(t4,2b)]
tt=seq(t1,min(t4,2*b),len=1000)
lines(tt,sapply(tt,Q.),bty='l',type='l',xlab='t',ylab='Wq')

par(mfrow=c(1,1))
curve(A(x),0,3,bty='l',ylab='person',xlab='t',lwd=1,
main="到着率:at(t-2b) サービス率:200") # 累積入場者
curve(Q(x),0,3,col='navy',add=T,lwd=1,lty=3,type='h') # 待ち人数
tt=seq(0,3,len=1000)
lines(tt,sapply(tt,function(t)A(t)-Q(t)),lwd=2,col=4)
legend('right',bty='n',legend=c("流入総数","流出総数","待ち人数"),
col=c(1,4,1),lty=c(1,1,3),lwd=c(1,2,1))
integrate(Q,t1,t4)$value # 総待ち時間(=縦軸方向積分面積Area under curve)
Wtotal=ifelse(2*d<b,9/4*a*d^4,a/36*(b+d)^3/(b-d)*(4*b*d-b^2-d^2)) ; Wtotal
Wq=Wt/N ; Wq

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

臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚

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

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.

394卵の名無しさん2018/11/30(金) 23:12:28.51ID:c4eruZjZ
#
source('tmp.tools.R') # 乱数発生にNeumann法
# 受付時間9:00-12:30,15:30-19:00
curve(10*(dgamma(x-9,2,1)+dgamma(x-16,8,5)),9,20,type='h') # 雛形
R <- function(x) ifelse((9<x&x<12.5)|(15.5<x&x<19),dgamma(x-9,2,1)+dgamma(x-16,8,5),0)
set.seed(123) ; data=vonNeumann2(function(x) R(x),9,19,Print=F)
N=100 # 来院患者数
n.win=1 # サービス窓口数
mu=8 # サービス率(1時間診察人数)
client=hist(data,freq=F,breaks=30,col='skyblue',main='',xlab='clock time')
breaks=client$breaks
y=client$counts/sum(client$counts)*N # 総数をN人に
# 到達率関数,離散量を連続関数に
R <- function(x) ifelse((9<x&x<12.5)|(15.5<x&x<19),y[which.max(x<=breaks)-1],0)
R=Vectorize(R)
curve(R(x),9,20,type='h',bty='l')
c=n.win*mu # 総サービス率
abline(h=c,col=8)
t1=uniroot(function(t)R(t)-c,c(9,10))$root ; t1 # 到達率=サービス率で待ち時間開始
t2=uniroot(function(t)R(t)-c,c(16,17))$root ; t2 # 午後の部

395卵の名無しさん2018/11/30(金) 23:12:57.93ID:c4eruZjZ
tt=seq(9,24,len=1000)
Rtt=R(tt)
plot(tt,Rtt,type='s',bty='l')
cumR=cumsum(Rtt)/sum(Rtt)*N # cumsumで累積来院数をgrid化
plot(tt,cumR,type='l',bty='l')
A <- function(t) cumR[which.max(t<=tt)] # 離散量を連続関数に
A=Vectorize(A)
curve(A(x),9,24,bty='l')
Q <- function(t){ # 時刻tでの待ち人数
if(t<t1) return(0)
if(t1<t&t<t2) return(max(A(t)-A(t1)-c*(t-t1),0)) # 午前の部
else return(max(A(t)-A(t2)-c*(t-t2),0)) # 午後の部
}
Q=Vectorize(Q)
curve(Q(x),9,24,bty='l',type='h',col=2,ylab='persons',xlab='clock time')
# 待ちの発生と終了の時刻をグラフから読み取る
t15=seq(14,15,len=100) ; plot(t15,sapply(t15,Q)) # 14.6
t17=seq(16.9,17.2,len=100) ; plot(t17,sapply(t17,Q)) # 17.0
Q(22.7)
t22=seq(22.75,22.80,len=100) ; plot(t22,sapply(t22,Q)) # 22.8

curve(Q(x),9,24,bty='l',type='h',col=2,ylab='persons',xlab='clock time')
MASS::area(Q,9, 14.6,limit=20)/A(14.6) # 午前の待ち時間
MASS::area(Q,17,22.8,limit=20)/(A(22.8)-A(17)) # 午後の待ち時間

396卵の名無しさん2018/11/30(金) 23:51:07.01ID:c4eruZjZ
午前の受付9時から12時30分まで午後の受付15時30分から19時までのクリニックに
図のような二峰性の分布で100人が来院するとする。
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚
> 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分として待ち時間をグラフ化。
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚

数値積分して平均の待ち時間を算出。
> 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卵の名無しさん2018/12/01(土) 00:40:16.84ID:yFxD3TpK
>>385
混雑と待ち(朝倉書店)が届いたので

これやってみた。
ポアソン分布や指数分布を前提とせず、実際のヒストグラムから待ち時間のシミュレーション。
午前の受付9時から12時30分まで午後の受付15時30分から19時までのクリニックに
図のような二峰性の分布で100人が来院するとする。
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚
> 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分として待ち時間をグラフ化。
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚

数値積分して平均の待ち時間を算出。
> 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


臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚

診療終了23時w

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

臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚
> integrate(Q,17,19.9,subdivisions=256)$value/(A(19.9)-A(17)) # 午後の待ち時間
[1] 1.496882
待ち時間が2.2時間から1.5時間に短縮。

診療終了は20時!

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

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.

400卵の名無しさん2018/12/01(土) 10:03:30.90ID:RmWyTNtb
rm(list=ls())
nwin=2 ; mu=10
C=nwin*mu # サービス効率
R <- function(t) dgamma(t,2,1)*100 # 到達関数
R=Vectorize(R)
curve(R(x),0,10,bty='l') ; abline(h=C,col=8)
t1=uniroot(function(x)R(x)-C,c(0,1))$root ; t1 # 行列開始時刻
t2=optimise(R,c(0,2),maximum = T)$maximum ; t2 # 行列増大速度最高時刻
t3=uniroot(function(x)R(x)-C,c(1,4))$root ; t3 # 行列最長時刻
A <- function(t) integrate(R,0,t)$value # 累積来客数
A=Vectorize(A)
curve(A(x),0,10,bty='l')
Q <- function(t) A(t)-A(t1)-C*(t-t1) # 行列人数
Q=Vectorize(Q)
curve(Q(x),0,10,bty='l') ; abline(h=0,col=8)
optimize(Q,c(0,10),maximum=T)$maximum ; t3 # 行列最長時刻
t4=uniroot(Q,c(4,8))$root ; t4 # 行列終了時刻
# calculate t4 w/o Q-function 到達関数から行列終了時刻を算出
curve(R(x),0,10,bty='l',xlab='clock time',ylab='arrival rate')
abline(h=C,col=8)
t13=seq(t1,t3,len=20)
segments(x0=t13,y0=C,y1=R(t13),col=3)
text(1.25,25,'V') ; text(c(t1,t3,t4),20,c('t1','t3','t4'),cex=0.95)
V=integrate(function(t)R(t)-C,t1,t3)$value ; V # 待ち時間*人数
dQ <- function(t) integrate(function(x) C-R(x),t3,t)$value - V
uniroot(dQ,c(t3,10))$root ; t4
t34=seq(t3,t4,len=20)
segments(x0=t34,y0=20,y1=R(t34),col='cyan') ; text(4,15,'V')

401卵の名無しさん2018/12/01(土) 10:07:43.30ID:RmWyTNtb
>>400
到着関数が一峰性だと待ち行列が0になる時間が割と簡単に算出できる。
ド底辺シリツ医大裏口入学には無理だけどw

臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚

402卵の名無しさん2018/12/01(土) 10:24:54.70ID:RmWyTNtb
>>399
ド底辺シリツ医を蔑むパロディであることわかってコピペしてんの?

これにでも答えてみ!

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

403卵の名無しさん2018/12/01(土) 13:36:46.51ID:ZZpMV2Nw
この季節はいつも風邪気味になるなぁ
外来から貰ってんのかな
冬コミが近いのに原稿がまだできとらんが
体調管理はしっかりしていかんとなぁ
ジャンルはFTで良いかなぁ
ガチ百合にすっかなぁ

404卵の名無しさん2018/12/01(土) 16:09:30.06ID:ZZpMV2Nw
便秘薬をいろいろ試しているが
どれが良いかなぁ

405卵の名無しさん2018/12/01(土) 18:54:24.93ID:RmWyTNtb
t0fn <- function(n){ # terminal 0 of factorial n ( n=10, 10!=3628800 => 2
m=floor(log(n)/log(5))
ans=0
for(i in 1:m) ans=ans+n%/%(5^i)
ans
}
t0fn=Vectorize(t0fn)
t0fn(10^(1:12))

10!から1兆!まで末尾の0の数
> t0fn(10^(1:12))
[1] 2 24 249 2499 24999
[6] 249998 2499999 24999999 249999998 2499999997
[11] 24999999997 249999999997

406卵の名無しさん2018/12/01(土) 18:55:28.45ID:RmWyTNtb
おい、ド底辺。

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

407卵の名無しさん2018/12/01(土) 20:53:46.49ID:o9d/f5rc
今年の納税額は五千万超えるなぁ

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

408卵の名無しさん2018/12/01(土) 21:08:44.05ID:o9d/f5rc
ふ◯◯◯ち◯◯れ◯◯◯◯

409卵の名無しさん2018/12/01(土) 22:41:26.00ID:N4WBnKxq
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

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

411卵の名無しさん2018/12/02(日) 06:45:16.31ID:e9Pc8hcV
# Troubled train T1 with m passengers left station S1 arrived S2 station s minute later
# than depature of train T0
# beta*m passenger got out and rs passengers got in, where
# r denotes in-passenger rate per minute, T0 took b(beta*m + rs) extra-minutes
# regular train T0 takes c minutes for exchange of passengers
dango <- function(s,m,beta=3/10,r=3,b=0.01,c=0){
mm=(1-beta)*m+r*s
ss=s+b*(beta*m+r*s)-c
c(ss,mm)
}
sm=c(10,100)
re=sm
for(i in 1:2){
sm=dango(sm[1],sm[2])
re=rbind(re,sm)
}
rownames(re)=NULL
plot(re)

412卵の名無しさん2018/12/02(日) 07:38:46.89ID:IdisUW1u
薬局の店舗数を増やそうかなぁ

413卵の名無しさん2018/12/02(日) 12:10:26.58ID:TL1hN1iv
dat=hist(c(rnorm(1e6),rnorm(1e5,5,0.5)))
attach(dat)
plot(breaks[-1],counts,type='s',log='y',ylim=range(counts))
segments(x0=breaks[-1],y=min(counts),y1=counts)
segments(x0=breaks[1],y=min(counts),y1=counts[1])

414卵の名無しさん2018/12/02(日) 21:14:03.05ID:qDXWsGoQ
liars <- function(Answer){ # case of all liars permitted
N=length(Answer)
dat=permutations(2,N,0:1,set=F,rep=T)
check <- function(y,answer=Answer){
all(answer[y==0]==sum(y)) # all honest answer compatible?  
} # numeric(0)==sum(y):logical(0) all(logical(0)) : TRUE
dat[apply(dat,1,check),]
}
liars(c(1,2,2,3,3))
liars(c(1,3,5,7,9,1,3,5,7,9))
(x=sample(10,10,rep=T)) ; apply(!liars(x),1,sum)
liars(c(8, 9, 8, 2, 4, 4, 2, 3, 9, 8))

415卵の名無しさん2018/12/02(日) 21:35:54.10ID:jYRj3cxk
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.

416卵の名無しさん2018/12/02(日) 22:20:54.56ID:iMFc27fK
互いに相関のある5項目くらいのスコアの合計点から疾患の発生を予測するカットオフ値を求めました

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

417卵の名無しさん2018/12/02(日) 22:35:39.65ID:qDXWsGoQ
# 一般化、全員嘘つきも可、重複する答も可l

iars <- function(Answer){ # duplicate answer and/or case of all liars permitted
N=length(Answer)
dat=gtools::permutations(2,N,0:1,set=F,rep=T)
check <- function(y,answer=Answer){
if(all(y==1)) !all(1:N %in% answer)
else all(answer[y==0]==sum(y)) & !(sum(y) %in% answer[y==1])
# all honest answer compatible & not included in liar's anwer   
}
dat[apply(dat,1,check),]
}
liars(c(2,2,2,3,3))
liars(c(2,3,3,4,5))
liars(Answer<-sample(10,10,rep=T)) ; Answer
liars(c(4,5,5,6,7,7,8,8,9,10))

418卵の名無しさん2018/12/02(日) 22:54:14.37ID:5KkHnCxW
3S Policy Causes the ResultTruman of Panama document and 3S policy

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

419卵の名無しさん2018/12/02(日) 23:16:13.68ID:+r9Osf+E
>>416
>互いに相関のある
なら変数減らせるんじゃね?
AUC?Area Under the Curve?
AICじゃなくて?

420卵の名無しさん2018/12/02(日) 23:31:52.94ID:61sstTZi
>>419
主成分3までで累積寄与度85%なので、3まで次元は減ります

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

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

AUCはarea under curveです

421卵の名無しさん2018/12/02(日) 23:42:05.45ID:+r9Osf+E
>>420
統計テキストの演習問題によくあるから一般的だろね。
三角形の周囲長のデータから線形回帰で面積を出すというような意味のないことやってるかも。

422卵の名無しさん2018/12/02(日) 23:50:18.66ID:5KkHnCxW
Prudence, indeed, will dictate that "uraguchi" long established cannot be changed for light and transient causes;
and accordingly all experience has shown, that BMS are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms from which they can pursue profit.

But when a long train of misbehavior and misconduct , showing invariably the same Imbecility evinces a design to reveal themselves as absolute Bona Fide Moron ,
it is their right, it is their duty, to expel such "uraguchi", and to provide new guards for their future security.

423卵の名無しさん2018/12/02(日) 23:57:57.44ID:iMFc27fK
>>421
次数が減るのがメリットかなと…

424卵の名無しさん2018/12/03(月) 07:19:35.51ID:DAMQxIpv
>>423
長方形の周囲長者から面積をだすのに
データが100個あればラグランジェの補完式で100次元式で完璧に当てはめることができる。
フィボナッチ数列も同じ。

425卵の名無しさん2018/12/03(月) 07:22:30.11ID:DAMQxIpv
象の体表面積の計算に有用な数値ってどこだろ?
身長体重鼻の長さ耳の大きさ?

426卵の名無しさん2018/12/03(月) 07:24:12.72ID:DAMQxIpv
スリーサイズと身長体重の相関とか某女子大の講師が書いてたなw

427卵の名無しさん2018/12/03(月) 08:49:08.21ID:cRcCrmb8
par(mfrow=c(2,1))

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

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

D(expression (a^x/(log(x)/log(a))),'x')
dg <- function(x,a=0.01) a^x * log(a)/(log(x)/log(a)) - a^x * (1/x/log(a))/(log(x)/log(a))^2
curve(dg,0,10)

428卵の名無しさん2018/12/03(月) 11:40:13.52ID:DAMQxIpv
>>420
AICとかWAICで比較する方法があったはず。

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

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

# all honest answer compatible & not included in liar's anwer
}
dat[apply(dat,1,check),]
}
liars(c(2,2,2,3,3))
liars(c(2,3,3,4,5))
liars(Answer<-sample(10,10,rep=T)) ; Answer
liars(c(4,5,5,6,7,7,8,8,9,10))
liars(c(4,5,5,6,7,7,8,8,9,10),S=F)

430卵の名無しさん2018/12/03(月) 13:13:54.59ID:DAMQxIpv
シリツ医の使命は裏口入学撲滅国民運動の先頭に立つことだよ。

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

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

431卵の名無しさん2018/12/03(月) 15:36:25.67ID:1KqGOOJS
rm(list=ls())
graphics.off()
.a=0.01
f = function(x,a=.a) a^x-log(x)/log(a)
curve(f(x),bty='l',lwd=2) ; abline(h=0,col=8)
max=optimize(f,c(0,1),maximum=T)$maximum
min=optimize(f,c(0,1),maximum=F)$minimum
x1=uniroot(f,c(0,max))$root
x2=uniroot(f,c(max,min))$root
x3=uniroot(f,c(min,1))$root
ans=c(x1,x2,x3) ; ans
points(ans,c(0,0,0),pch=19,col=2)

432卵の名無しさん2018/12/03(月) 21:38:41.65ID:uthawMyt
liars <- function(Answer,Strict=TRUE){ # duplicate answer and/or case of all liars permitted
N=length(Answer)
dat=gtools::permutations(2,N,0:1,set=F,rep=T)
check <- function(y,answer=Answer){
if(all(y==1)) {!all(1:N %in% answer)}
else{
if(Strict){all(answer[y==0]==sum(y)) & !(sum(y) %in% answer[y==1])}
else {all(answer[y==0]==sum(y))}
}
# all honest answer compatible & not included in liar's anwer
}
dat[apply(dat,1,check),]
}
liars(c(2,2,2,3,3))
liars(c(2,3,3,4,5),S=F)

liars(Answer<-sample(10,10,rep=T),S=F) ; Answer
liars(Answer)
sort(Answer)
liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=FALSE)
liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=TRUE)

433卵の名無しさん2018/12/03(月) 21:39:50.88ID:uthawMyt
> liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=FALSE)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11]
[1,] 1 1 1 1 1 1 1 1 0 0 1
[2,] 1 1 1 1 1 1 1 1 0 1 0
[3,] 1 1 1 1 1 1 1 1 1 0 0
[4,] 1 1 1 1 1 1 1 1 1 1 1
> liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=TRUE)
[1] 1 1 1 1 1 1 1 1 1 1 1

434卵の名無しさん2018/12/03(月) 22:45:35.45ID:uthawMyt
liars <- function(Answer,Strict=TRUE){ # duplicate answer and/or case of all liars permitted
N=length(Answer)
arg=list()
for(i in 1:N) arg[[i]]=0:1
dat=do.call(expand.grid,arg) # expand.grid(0:1,0:1,0:1,...,0:1)
colnames(dat)=LETTERS[1:N]
check <- function(y,answer=Answer){
if(all(y==1)) {!all(1:N %in% answer)}
else{ # Strict: all honest answer compatible & not included in liar's anwer
if(Strict){all(answer[y==0]==sum(y)) & !(sum(y) %in% answer[y==1])}
else {all(answer[y==0]==sum(y))}
}
}
dat[apply(dat,1,check),]
}

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

liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=FALSE)
liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=TRUE)

435卵の名無しさん2018/12/03(月) 23:36:09.50ID:kWZ8ngVO
しゅごーいAWP

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

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

liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=FALSE)
liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=TRUE)

437卵の名無しさん2018/12/04(火) 01:12:57.83ID:nI+jKERK
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

438卵の名無しさん2018/12/04(火) 15:14:54.20ID:nfS0Ph7I
>>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卵の名無しさん2018/12/04(火) 19:24:56.87ID:nfS0Ph7I
バスの到着間隔が平均30分の指数分布であるEバスと
平均30分の一様分布であるUバスではどちらが待ち時間の期待値が小さいか?

440卵の名無しさん2018/12/05(水) 00:36:57.95ID:DRmF49xK
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

441卵の名無しさん2018/12/05(水) 18:34:25.14ID:mPAQrzgG
-- zerOne 5 -> [[0,0,0,0,0],[0,0,0,0,1]....[1,1,1,1,1,1]
zeroOne :: Num a => Int -> [[a]]
zeroOne n = (!! n) $ iterate (\x-> [a:b|a<-[0,1],b<-x]) [[]]

442卵の名無しさん2018/12/05(水) 19:07:50.43ID:XTI9A75j
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

443卵の名無しさん2018/12/05(水) 22:12:31.75ID:kHtcpiLC
# dat : all possible combinations
n=5 ;arg=list()
for(i in 1:n) arg[[i]]=0:1
dat=do.call(expand.grid,arg) # expand.grid(0:1,0:1,...)
dat=as.matrix(dat)
colnames(dat)=LETTERS[1:n]

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

check=function(x){
re=NULL
honest=which(x==1) # index of honest
for(i in honest){
re=append(re,is.compati(i,x))
}
all(re)
}
dat[apply(dat,1,check),]

444卵の名無しさん2018/12/05(水) 22:13:09.98ID:kHtcpiLC
正直者は嘘をつかないが
嘘つきは嘘をつくこともつかないこともある。

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

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

445卵の名無しさん2018/12/06(木) 09:56:22.91ID:cp3ws/tO
>>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卵の名無しさん2018/12/06(木) 09:56:52.33ID:cp3ws/tO
check=function(x,Strict){
re=NULL
honest=which(x==1) # index of honest
for(i in honest){
re=append(re,is.compati.H(i,x))
}
if(Strict){
liar=which(x==0) # index of liar
for(i in liar){
re=append(re,is.compati.L(i,x))
}
}
all(re)
}
dat[apply(dat,1,function(x) check(x,Strict=TRUE)),]
dat[apply(dat,1,function(x) check(x,Strict=FALSE)),]

447卵の名無しさん2018/12/06(木) 16:42:18.52ID:E+1fMA/x
dat=as.matrix(expand.grid(1:0,1:0,1:0))
colnames(dat)=LETTERS[1:3]
compati.H <- function(i,x){ # i index of honest, x: possible combination
switch(i, # i= 1,2,or,3
# if A is honest, B should be honest, compatible?
ans <- x[2]==1, # when i=1
# if B is honest,C is a liar thereby A should be honest. compatible?
ans <- x[3]==0 & ifelse(x[3]==0,!(x[1]==0),x[1]==0), # when i=2, x[3]==0 & x[1]==1
ans <- NULL) # when i=3
return(ans)
}
compati.L <- function(i,x){ # i index of liar, x: possible combination
switch(i,
ans <- x[2]==0,
ans <- x[3]==1 & x[1]==1,
ans <- NULL)
return(ans)}

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

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

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

448卵の名無しさん2018/12/06(木) 20:20:59.86ID:E+1fMA/x
a=1
m=100
n=1e6
x=sample(c(a/m,m*a),n,rep=T,prob=c(m/(m+1),1/(m+1))) ; hist(x,freq=F) ; mean(x)
a/m*m/(m+1)+m*a*1/(m+1) ; a/(m+1)*(1+m)
plot(c(m/(m/1),1/(m+1)),c(a/m,m*a),bty='l')
EX2=(a/m)^2*m/(m+1)+(m*a)^2*(1/(m+1))
(EW = EX2/a/2) ; mean(x^2)/mean(x)/2
EW <- function(m,a=1) (m^3+1)/m/(m+1)/2*a
m=1:100
plot(m,EW(m),bty='l')

449卵の名無しさん2018/12/07(金) 03:14:44.29ID:YE3oTb4v
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

450卵の名無しさん2018/12/07(金) 08:24:44.19ID:ySmU7MDt
>>449
裏口馬鹿にもわかるように原文もつけなきゃ。


原文はこれな。

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

451卵の名無しさん2018/12/07(金) 08:27:54.51ID:ySmU7MDt
開業医スレのシリツ三法則(試案、名投稿より作成)

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

>http://2chb.net/r/hosp/1537519628/101-102
>http://2chb.net/r/hosp/1537519628/844-853
ID:RFPm1BdQ

>http://2chb.net/r/hosp/1537519628/869
>http://2chb.net/r/hosp/1537519628/874-875
>http://2chb.net/r/hosp/1537519628/874-880
>http://2chb.net/r/hosp/1537519628/882
ID:liUvUPgn

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

3.リアルでは皆思ってるだけで口に出してないだけ
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚

452卵の名無しさん2018/12/07(金) 20:21:20.38ID:g1XwAPhY
3S Policy Causes the ResultTruman of Panama document and 3S policy

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

453卵の名無しさん2018/12/08(土) 07:31:43.87ID:xRW0g7nq
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

454卵の名無しさん2018/12/08(土) 20:18:41.06ID:W3abFsTH
liars <- function(Answer,Strict=TRUE){ # duplicate answer and/or case of all liars permitted
N=length(Answer)
arg=list()
for(i in 1:N) arg[[i]]=0:1
dat=do.call(expand.grid,arg) # expand.grid(0:1,0:1,0:1,...,0:1)
colnames(dat)=LETTERS[1:N]
check <- function(y,answer=Answer){
if(all(y==1)) {!all(1:N %in% answer)}
else{ # Strict: all honest answer compatible & not included in liar's anwer
if(Strict){all(answer[y==0]==sum(y)) & !(sum(y) %in% answer[y==1])}
else {all(answer[y==0]==sum(y))}
}
}
dat[apply(dat,1,check),]
}

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

liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=FALSE)
liars(c(1, 2, 3, 4, 5, 5, 5, 5, 9, 9, 9),Strict=TRUE)

455卵の名無しさん2018/12/09(日) 09:45:50.49ID:EZ1Q6//t

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

TSH : 0.34〜4.0 TSH:μIU/mlを基準値として(これが平均±2×標準偏差で計算されているとして)呪文前と呪文後のデータを正規分布で各々50個つくる。
負になった場合は検出限界以下として0にする。
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚
同じ平均値と標準偏差で乱数発生させただけなので両群には有意差はない。
横軸に呪文前のTSHの値、縦軸にTSHの変化(呪文後−呪文前)をグラフしてみると
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚

つまり、呪文前の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卵の名無しさん2018/12/10(月) 14:52:10.55ID:SBKPI/ud
アタマわるわる〜

458卵の名無しさん2018/12/10(月) 22:04:30.67ID:7+YyXAYs
>>457
頭が悪いのは誤りを指摘できないお前の頭な。

459卵の名無しさん2018/12/11(火) 08:23:18.37ID:EyBBmFk4
野獣先輩、オナシャス
アタマわるわるわ〜るわる〜
アタマわるわるわ〜るわる〜
あそれっ
アタマわるわるわ〜るわる〜
アタマわるわるわ〜るわる〜
あよいしょっ
アタマわるわるわ〜るわる〜
アタマわるわるわ〜るわる〜
あくしろよ
アタマわるわるわ〜るわる〜
アタマわるわるわ〜るわる〜
endless

460卵の名無しさん2018/12/11(火) 08:39:06.09ID:PFEjAytf
>>459
文章だけでド底辺シリツ医大卒の裏口馬鹿とわかる。
これに答えられない国立卒がいた。
駅弁らしいが。

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

461卵の名無しさん2018/12/11(火) 13:32:28.73ID:c5MyHopu
It is common knowledge among doctors and patients that Do-Teihen(exclusively bottom-leveled medical school) graduates mean morons who bought their way to Gachi'Ura(currently called by themselves)

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

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

Although people won't call them names to their face,
certain 80-90% people of about my age have been yet scorning and sneering at Uraguchi graduates, speaking in the back of our mind,
" Uraguchi morons shall not behave like somebody."
We never speak out face to face in real life.

462卵の名無しさん2018/12/12(水) 22:30:23.75ID:x9HwYbel
おいこら
あっちでまた非医師仲間のコンプが湧いてるぞ
さっさと引き取れや

463卵の名無しさん2018/12/14(金) 12:51:17.00ID:eeDD4wBK
回答付きでレスできない椰子ってシリツ卒なんだろうな。

464卵の名無しさん2018/12/14(金) 23:45:34.35ID:/gtLrghw
お前は今までに吐いたゲロの回数を覚えているのか?

465卵の名無しさん2018/12/15(土) 06:52:37.95ID:PqeMZC8f
>>464
ゲロの回数の従う事前分布をどう想定する?

466卵の名無しさん2018/12/15(土) 06:57:22.51ID:PqeMZC8f
ある女医が一日に5回屁をこいたとする。
屁の回数はポアソン分布と仮定して
この女医の一日にこく屁の回数の95%信頼区間を述べよ、
という問題にできるぞ。
答えてみ!

467卵の名無しさん2018/12/15(土) 07:17:43.02ID:PqeMZC8f
事前分布を想定して現実のデータからその分布の最適分布を算出する。当然、区間推定にある。
relocation of probability dustrubution
これがベイズ統計の基本的な考え方だよ。
上記の女医の屁の回数も区間推定できる。

468卵の名無しさん2018/12/15(土) 07:47:09.33ID:PqeMZC8f
ゲロの回数だとゼロ過剰ポアソン分布の方がいいだろうな。

469卵の名無しさん2018/12/15(土) 07:57:08.94ID:PqeMZC8f

470卵の名無しさん2018/12/15(土) 08:21:49.91ID:dSAl+lHg
臨床問題です
サブとアドンとBLの関連を原稿用紙30枚以上で考察せよ

471卵の名無しさん2018/12/15(土) 08:23:29.62ID:PqeMZC8f
>>470
んで、女医の放屁数は出せた?

472卵の名無しさん2018/12/15(土) 08:25:40.34ID:PqeMZC8f
>>470
問題の意味がわからないから詳述してくれ。
女医の屁の方は問題設定が明確だぞ。

473卵の名無しさん2018/12/15(土) 08:48:13.42ID:PqeMZC8f
ゲロの回数の事前分布なら
Zero-Inflated Negative Binomial Distribution
の方がいいかな。

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

474卵の名無しさん2018/12/15(土) 08:53:38.00ID:PqeMZC8f

475卵の名無しさん2018/12/15(土) 09:36:45.73ID:ek4No3cm
今日はこれで遊ぶかな。

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

476卵の名無しさん2018/12/15(土) 13:48:34.67ID:dSAl+lHg
問題に回答できないとは
さては中卒ニートだな

477卵の名無しさん2018/12/15(土) 14:06:30.51ID:Eu3ncs/k
>>476
>>470
問題の意味がわからないから詳述してくれ。
女医の屁の方は問題設定が明確だぞ。

478卵の名無しさん2018/12/15(土) 15:08:53.35ID:5ZAJ5aCI
こんな感じでゼロ過剰ポアソン分布モデルがつくれるな。

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

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

おい、ド底辺、上記の過剰ポアソン分布モデルで
1年間に吐くゲロの回数の平均値を出してみ!

479卵の名無しさん2018/12/15(土) 15:09:33.17ID:5ZAJ5aCI
女医の放屁の方はポアソン分布でよさそうだな。

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

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

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

481卵の名無しさん2018/12/15(土) 15:31:26.76ID:5ZAJ5aCI
>>480
統計用語じゃないから、解説してくれ。

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

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

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

483卵の名無しさん2018/12/15(土) 15:50:36.53ID:5ZAJ5aCI
インフルエンザ迅速検査キットの感度が80%、偽陽性率1%とする。

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

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

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

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

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

484卵の名無しさん2018/12/15(土) 15:58:10.95ID:5ZAJ5aCI
nLR=(1-0.80)/0.99 # FN/TN
po=0.1/(1-0.1)
o=po/nLR^2 # po=o*nLR^2
o/(1+o)

485卵の名無しさん2018/12/15(土) 16:30:26.03ID:5ZAJ5aCI
インフルエンザの流行期ならなら有熱で受診した患者がインフルエンザである確率分布はこんな感じ(青のヒストグラム)

臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚

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

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

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

486卵の名無しさん2018/12/15(土) 16:41:26.81ID:5ZAJ5aCI
nLR=(1-0.80)/0.99 # FN/TN
po=0.1/(1-0.1)
o=po/nLR^2 # po=o*nLR^2
o/(1+o)

curve(dbeta(x,8,2),bty='l',ann=F,type='h',col='maroon')
N=1e5
x=rbeta(N,8,2)
hist(x,breaks=30,col='lightblue',main='検査前有病確率',
f=F,xlab='',yaxt='n', ylab='')
o=x/(1-x)
po=o*nLR^2
pp=po/(1+po)
# hist(pp,f=F,breaks=50,col='pink',main='検査後有病確率',
yaxt='n', xlab='',ylab='')
BEST::plotPost(pp,compVal = 0.10,breaks=60,xlab="2回陰性後有病確率",
col='pink',showMode=F)

487卵の名無しさん2018/12/15(土) 16:43:14.07ID:5ZAJ5aCI
par(mfrow=c(2,1))
theta=0.9
lambda=2
N=1e5
# Zero inflated poisson distribution
zip=numeric(N)
for (i in seq_along(zip)){
if(rbinom(1,1,1-theta)==0){
zip[i]=0
}else{
zip[i]=rpois(1,lambda)
}
}
hist(zip)
HDInterval::hdi(zip)
mean(zip)

# Hurdle distribution
hurdle=numeric(N)
for (i in seq_along(hurdle)){
if(rbinom(1,1,1-theta)==0){ # if zero, then zero
hurdle[i]=0
}else{ # else zero truncated poisson distribution
tmp=0
while(tmp==0){
tmp=rpois(1,lambda)
}
hurdle[i]=tmp
}
}
hist(hurdle)
HDInterval::hdi(hurdle)

488卵の名無しさん2018/12/15(土) 17:13:08.28ID:dSAl+lHg
この程度の問題文が理解できないとは
さては中卒ニートだな

489卵の名無しさん2018/12/15(土) 17:48:16.98ID:Eu3ncs/k
>>488
自分の出した問題も説明できないとはド底辺シリツか?

490卵の名無しさん2018/12/15(土) 17:50:19.60ID:Eu3ncs/k
>>488
知らんことには回答できない。
答えてほしけりゃ問題を敷衍して書けよ。
統計ネタなら答えるぞ。

491卵の名無しさん2018/12/15(土) 19:14:33.63ID:lcyf4Gyo
問題が理解すらできないとは
さては中卒ニートだな

492卵の名無しさん2018/12/15(土) 19:25:13.63ID:Eu3ncs/k
>>491
>>488
自分の出した問題も説明できないとはド底辺シリツか?

493卵の名無しさん2018/12/15(土) 20:03:13.15ID:lcyf4Gyo
試験で解答できなきゃ零点だ

494卵の名無しさん2018/12/15(土) 20:24:09.71ID:Eu3ncs/k
>>493
不適切問題じゃね。
こういうのが即答できれば基礎学力の試験になる。

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

495卵の名無しさん2018/12/15(土) 20:34:41.94ID:Eu3ncs/k
>>493
原稿用紙30枚以上の模範解答書いてみ!
はよ、はよ!

496卵の名無しさん2018/12/15(土) 21:14:31.96ID:3n76OB9+
捏造データでお遊んでろ。

497卵の名無しさん2018/12/15(土) 21:24:38.91ID:Eu3ncs/k
>>496
ベイズ統計における事前確認は捏造ではなく
無情報もしくは弱情報分布である。
日本人女性の平均身長を1〜2mの分布とする
というのが弱情報分布。

498卵の名無しさん2018/12/15(土) 21:25:49.01ID:Eu3ncs/k
事前分布の分散は逆ガンマより半コーシーを使うのがGelman流ね。

499卵の名無しさん2018/12/15(土) 21:29:02.64ID:Eu3ncs/k
事前確率分布を設定することでこういう計算も可能となる。
オマエの知識レベルじゃ無理だろうけど。

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

500卵の名無しさん2018/12/16(日) 01:08:39.24ID:/hMzfoFS
1年:進級失敗10人、うち1人放校
2年:進級失敗16人、放校なし
3年:進級失敗34人、うち放校9人
4年:進級失敗9人、うち放校2人
5年:進級失敗10人、うち放校1人
6年:卒業失敗26人、うち放校1人

http://2chb.net/r/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)

臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚

501卵の名無しさん2018/12/16(日) 06:39:53.73ID:ZC5C+Eow
算数の問題です
エリンギとマツタケの使用頻度を検証すると
あぁん いくいく いっひゃうのらぁ

502卵の名無しさん2018/12/16(日) 07:47:33.23ID:/hMzfoFS
このページ便利だな。

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

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

503卵の名無しさん2018/12/16(日) 07:49:21.32ID:/hMzfoFS
これも親切設計

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

504卵の名無しさん2018/12/16(日) 10:16:17.73ID:1U2yFJp0
>>501
おい、上の過剰ゼロポアソンモデルから放校者数の期待値を計算してみ。
来年のド底辺シリツ医大の放校者の予想になるぞ。
まあ、ド底辺シリツが放校者ゼロ過剰というのは過大評価だがね。

505卵の名無しさん2018/12/16(日) 10:39:40.56ID:/hMzfoFS
pairsxyz <- function(x,y,z){
xyz=data.frame(x,y,z)
panel.cor <- function(x, y, ...){
usr <- par('usr'); on.exit(par(usr))
par(usr=c(0,1,0,1))
r <- cor(x, y, method='spearman', use='pairwise.complete.obs')
zcol <- lattice::level.colors(r, at=seq(-1, 1, length=81), col.regions=colorRampPalette(c(scales::muted('red'),'white',scales::muted('blue')), space='rgb')(81))
ell <- ellipse::ellipse(r, level=0.95, type='l', npoints=50, scale=c(.2, .2), centre=c(.5, .5))
polygon(ell, col=zcol, border=zcol, ...)
text(x=.5, y=.5, lab=100*round(r, 2), cex=2, col='black')
pval <- cor.test(x, y, method='pearson', use='pairwise.complete.obs')$p.value
sig <- symnum(pval, corr=FALSE, na=FALSE, cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1), symbols = c('***', '**', '*', '.', ' '))
text(.6, .8, sig, cex=2, col='gray20')
}
panel.hist <- function(x, ...) {
usr <- par('usr'); on.exit(par(usr))
par(usr=c(usr[1:2], 0, 1.5))
h <- hist(x, plot=FALSE)
breaks <- h$breaks
nB <- length(breaks)
y <- h$counts; y <- y/max(y)
rect(breaks[-nB], 0, breaks[-1], y, col='lightblue', ...)
}
cols.key <- scales::muted(c('red', 'blue', 'green'))
cols.key <- adjustcolor(cols.key, alpha.f=1/4)
# pchs.key <- rep(19, 3)
# gr <- as.factor(1:3)
panel.scatter <- function(x, y){
# points(x, y, col=cols.key[gr], pch=19, cex=1)
points(x, y, col=sample(colours(),1),pch=19, cex=1)
lines(lowess(x, y))
}

506卵の名無しさん2018/12/16(日) 10:40:27.95ID:/hMzfoFS
pairs(xyz,
diag.panel=panel.hist,
lower.panel=panel.scatter,
upper.panel=panel.cor,
gap=0.5,
labels=gsub('\\.', '\n', colnames(xyz)),
label.pos=0.7,
cex.labels=1.4)
}

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

pairs も カスタマイズすればわりと使えるな。

507卵の名無しさん2018/12/16(日) 11:38:51.60ID:ZC5C+Eow
ニート ニート 働けニート

ダウンロード&関連動画>>

@YouTube


508卵の名無しさん2018/12/16(日) 11:42:14.17ID:/hMzfoFS
Nt <- 100
set.seed(123)
Ti <- sample(20:40, Nt, replace=TRUE)
Xt <- rlnorm(Nt, 100, 15)
Yt <- rbinom(Nt, size=Ti, prob=0.8)

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

その線形回帰は

glm(Yt ~ Xt, family=poisson(link="log"), offset=log(Ti))

509卵の名無しさん2018/12/16(日) 14:16:40.36ID:/hMzfoFS
source('tmp.tools.R')

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

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

#
lambda <- sapply(mu,function(x) rgamma(1,shape=shape,scale=x/shape))
y2 <- sapply(lambda,function(x) rpois(1,x))
hist(y1,f=F,breaks=50)
hist(y2,f=F,breaks=50, add=T,col=5)

510卵の名無しさん2018/12/16(日) 20:30:27.72ID:/hMzfoFS
# ネットワークノード1..j..N
# ネットワーク内の客の数1..k..K、
# ノードjでの平均客数L[k,j]、通過時間W[k,j]、到着率lambda[k,j]
# mu[j]:サービス率,r[i,j]ノードiからjへの移行確率
# theta[j] = Σtheta[i](i=1,N) * r[i,j] の解がtheta
rm(list=ls())
theta=c(0.6,0.4)
mu=c(0.6,0.4)
N=2
K=10
L=W=lambda=matrix(rep(NA,N*K),ncol=N)

k=1
for(j in 1:N){
W[k,j]=1/mu[j]*(1+0)
}
tmp=numeric(N)
for(j in 1:N){
tmp[j]=theta[j]*W[k,j]
}
den=sum(tmp)
lambda[k,1]=k/den
for(j in 2:N){
lambda[k,j]=theta[j]*lambda[k,1]
}
for(j in 1:N){
L[k,j]=lambda[k,j]*W[k,j]
}

511卵の名無しさん2018/12/16(日) 20:30:52.05ID:/hMzfoFS
#
for(k in 2:K){
for(j in 1:N){
W[k,j]=1/mu[j]*(1 + L[k-1,j])
}
tmp=numeric(N)
for(j in 1:N){
tmp[j]=theta[j]*W[k,j]
}
den=sum(tmp)
lambda[k,1]=k/den
for(j in 2:N){
lambda[k,j]=theta[j]*lambda[k,1]
}
for(j in 1:N){
L[k,j]=lambda[k,j]*W[k,j]
}
}
L
W
lambda

512卵の名無しさん2018/12/17(月) 04:38:09.36ID:GOYrgwsC
minimize 2*b+4*sin(θ)/(cos(θ)-1/2)*α where (θ-sin(θ)/2+(sin(θ)/(cos(θ)-1/2))^2(α-sin(α))/2+(1-b)*sin(θ)/2=pi/8 ,0<b<1,0<θ<pi/2

513卵の名無しさん2018/12/17(月) 04:45:32.12ID:GOYrgwsC
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卵の名無しさん2018/12/17(月) 05:14:49.85ID:GOYrgwsC
rangeB = map (/1000) [1..1000]
rangeTheta = map (\x -> x * pi/2/1000) [1..1000]
rangeAlpha = map (\x -> x * pi/1000) [1..1000]
rangeR = map (\x -> x * 1/1000) [1000..10000]
re = [2*b+4*r*α| b<-rangeB,θ<-rangeTheta, α<-rangeAlpha,r<-rangeR,(θ-sin(θ))/2+r^2*(α-sin(α))/2+(1-b)*sin(θ)/2==pi/8]
main = do
print $ minimum re

515卵の名無しさん2018/12/17(月) 05:39:04.50ID:GOYrgwsC
rangeB = map (/1000) [1..1000]
rangeTheta = map (\x -> x * pi/2/1000) [1..1000]
rangeAlpha = map (\x -> x * pi/1000) [1..1000]
re = [(2*b+4*sin(θ)/(cos(θ)-1/2)*α)| b<-rangeB,θ<-rangeTheta, α<-rangeAlpha,(θ-sin(θ))/2+(sin(θ)/(cos(θ)-1/2))^2*(α-sin(α))/2+(1-b)*sin(θ)/2==pi/8]
main = do
print $ minimum re

516卵の名無しさん2018/12/17(月) 05:47:22.52ID:GOYrgwsC
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卵の名無しさん2018/12/17(月) 05:47:36.95ID:GOYrgwsC
minimize(2*b+4rα) where (θ-sinθ)/2+r^2(α-sinα)/2+(1-b)sinθ/2=pi/8 ,0<b<1,0<θ<pi/2,0<α<2*pi

518卵の名無しさん2018/12/17(月) 13:52:12.63ID:FuhGkKV8
向学心のないコミュ障事務員のスレ

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

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

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

520卵の名無しさん2018/12/17(月) 14:01:55.57ID:N+SAyf9z
>>518
向学心を語るなら>499の計算してからな。
ド底辺頭脳クン。

521卵の名無しさん2018/12/17(月) 14:02:51.74ID:FuhGkKV8
人生についての向学心は大学受験なんていう狭い領域で机上の空論をこねくり回すことではない
だがいつまでも不合格の受験生は、その領域から抜け出せなくなるんだなW

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

【因果応報】医学部再受験【自業自得】
http://2chb.net/r/kouri/1543851603/

522卵の名無しさん2018/12/17(月) 14:07:07.62ID:N+SAyf9z
>>521
>499は受験に無関係な臨床問題だよ。
答えてみ!
はよ!はよ!
向学心を語るなら>499の計算してからな。
ド底辺頭脳クン。

523卵の名無しさん2018/12/17(月) 14:08:05.38ID:FuhGkKV8
このスレもお勧めだぞW

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

524卵の名無しさん2018/12/17(月) 14:09:08.10ID:N+SAyf9z
>>523
>>518
向学心を語るなら>499の計算してからな。
ド底辺頭脳クン。

525卵の名無しさん2018/12/17(月) 14:14:33.64ID:N+SAyf9z
ド底辺頭脳でもこれくらいできるかな?

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

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

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

526卵の名無しさん2018/12/17(月) 14:26:10.34ID:FuhGkKV8
さあそろそろ今日の宿題の問題を出題しといてやろうか
事務員には無理だろうけどな

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

527卵の名無しさん2018/12/17(月) 14:40:27.65ID:qP6ufigZ
>>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卵の名無しさん2018/12/17(月) 14:43:19.14ID:qP6ufigZ
>>526
数値計算とか統計処理の必要な問題すらも作れないのは統計数理の素養がない馬鹿だからだろ。

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


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

529卵の名無しさん2018/12/17(月) 19:41:34.06ID:FuhGkKV8
やはり低学歴ニートには答えられないんだな

参加賞で1曲あげといてやろう
ダウンロード&関連動画>>

@YouTube


530卵の名無しさん2018/12/17(月) 19:55:33.62ID:N+SAyf9z
>>529
>>518
向学心を語るなら>499の計算してからな。
ド底辺頭脳クン。

531卵の名無しさん2018/12/17(月) 20:34:35.71ID:qP6ufigZ
source('tools.R')
ab=Mv2ab(0.70,0.01)
pbeta(0.80,ab[1],ab[2])-pbeta(0.60,ab[1],ab[2])
pbeta(0.90,ab[1],ab[2])-pbeta(0.50,ab[1],ab[2])
x=rbeta(1e5,ab[1],ab[2])
o=x/(1-x)
TP=0.80
FN=1-TP
TN=0.99
(nLR=FN/TN)
po=o*nLR^2
pp=po/(1+po)
BEST::plotPost(pp,compVal=0.10)

532卵の名無しさん2018/12/17(月) 20:34:41.41ID:qP6ufigZ
source('tools.R')
ab=Mv2ab(0.70,0.01)
pbeta(0.80,ab[1],ab[2])-pbeta(0.60,ab[1],ab[2])
pbeta(0.90,ab[1],ab[2])-pbeta(0.50,ab[1],ab[2])
x=rbeta(1e5,ab[1],ab[2])
o=x/(1-x)
TP=0.80
FN=1-TP
TN=0.99
(nLR=FN/TN)
po=o*nLR^2
pp=po/(1+po)
BEST::plotPost(pp,compVal=0.10)

533卵の名無しさん2018/12/17(月) 20:36:09.78ID:qP6ufigZ
インフルエンザ迅速検査キットの感度が80%、偽陽性率1%とする。

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

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

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

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

という。

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

534卵の名無しさん2018/12/18(火) 08:26:52.13ID:3rdYoIBg
バグに気づくのに時間がかかった、数学板に上げる前に気づいてよかった。

PQR = function(b,s){ # OQ=b ∠POQ=s
r=sin(s)/(cos(s)-1/2)
a=atan(sqrt(1^2+b^2-2*1*b*cos(s))/r) # <- WRONG!!
(s-sin(s))/2+r^2*(a-sin(a))/2+(1-b)*sin(s)/2
# (pi/2-s)/2 + b*sin(s)/2 - r^2*(a/2-sin(a)/2)
}
bb=seq(0,1,len=101)
ss=seq(0,pi/2,len=101)
z=outer(bb,ss,PQR)
image(bb,ss,z,xlab='b(OQ)',ylab='s(rad)')
contour(bb,ss,z,bty='l',nlevels=20,add=T, lty=3)
contour(bb,ss,z,levels=pi/8,lwd=2, add=T)
Persp3d(bb,ss,z)
b2s <- function(b){
uniroot(function(x) PQR(b,x)-pi/8, c(0,pi/2))$root
}
b2s=Vectorize(b2s)

L = function(b){ # 2b + 4ra
s=b2s(b)
r=sin(s)/(cos(s)-1/2)
a=atan(sqrt(1^2+b^2-2*1*b*cos(s))/r)
2*b + 4*r*a
}
L=Vectorize(L)
curve(L(x),0,pi/6,bty='l')
L(0)

535卵の名無しさん2018/12/18(火) 09:56:44.79ID:iW+brusm
こんな素朴な質問したら理解できない長文レスが数学化卒からきた。

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

臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚
臨床統計もおもしろいですよ、その2 	fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚
の順に小さくなるのは計算できたけど。

536卵の名無しさん2018/12/18(火) 15:48:23.96ID:3rdYoIBg
暇つぶしにサムスカの太鼓持ち講演を聞いた。

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

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

537卵の名無しさん2018/12/18(火) 15:50:29.76ID:3rdYoIBg
>>536
まあ、聞いているやつが(ド底辺シリツ医大卒のようなアホが多数で)p<0.001とか出せばエビデンスレベルが高いと誤解するだろうとわかっての所作なら策士だとは思うが。

538卵の名無しさん2018/12/18(火) 15:55:06.24ID:3rdYoIBg
こんなのがあんのね

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

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

539卵の名無しさん2018/12/18(火) 21:56:13.92ID:RRjIHldX
3S Policy Causes the ResultTruman of Panama document and 3S policy

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

540卵の名無しさん2018/12/18(火) 23:30:22.38ID:rfcy7s34
本日も事務員放送の終了時間となりました

ダウンロード&関連動画>>

@YouTube


541卵の名無しさん2018/12/19(水) 04:45:37.72ID:CUSSzVDj
>>540
相関係数を算出に全例調査しているのにp値を出だすのが
何でアホと言われるかわかる?

542卵の名無しさん2018/12/19(水) 13:50:09.99ID:CUSSzVDj
>>541
わからないからp値だしているのか
わからない>540のような馬鹿につけこんでいるのか、
どっちだろうな。

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

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

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

543卵の名無しさん2018/12/19(水) 16:34:10.87ID:3mCL+IGn
さて問題です

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

544卵の名無しさん2018/12/19(水) 16:43:43.16ID:CUSSzVDj
>>543
>>540
相関係数を算出に全例調査しているのにp値を出だすのが
何でアホと言われるかわかる?

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

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

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

545卵の名無しさん2018/12/19(水) 18:33:47.66ID:3mCL+IGn
問題に即答できんとは
さてはニートだな

546卵の名無しさん2018/12/19(水) 19:18:36.88ID:CUSSzVDj
>>545
統計スレで統計問題を書けないとはド底辺シリツ頭脳だな。

547卵の名無しさん2018/12/19(水) 20:12:36.56ID:3mCL+IGn
開業医でないのに開業スレに書きこむ
非医師のニート脳が何か言ってるなW

548卵の名無しさん2018/12/19(水) 21:12:41.91ID:CUSSzVDj
>>547
開業医スレに
こういうのを書いたら礼を言われましたよ。
https://egg.2ch.net/test/read.cgi/hosp/1542639046/93

549卵の名無しさん2018/12/19(水) 21:13:24.16ID:CUSSzVDj
>>547

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

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

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

550卵の名無しさん2018/12/19(水) 21:24:51.44ID:CUSSzVDj
>>547

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

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

統計スレなんだから

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

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

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

551卵の名無しさん2018/12/19(水) 21:25:04.74ID:3mCL+IGn
非医師ニートくんは
スレ1の説明も読めないようだ

http://2chb.net/r/hosp/1542639046/1

552卵の名無しさん2018/12/19(水) 21:28:31.22ID:CUSSzVDj
>>551

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

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

統計スレなんだから

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

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

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

553卵の名無しさん2018/12/19(水) 21:49:54.61ID:CUSSzVDj
>>551
https://egg.2ch.net/test/read.cgi/hosp/1542639046/76-83
までの議論(>77が俺)は
非医者ニートとの会話だと思う?
相当頭が悪そうだな。

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

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

554卵の名無しさん2018/12/19(水) 23:57:49.27ID:3mCL+IGn

555卵の名無しさん2018/12/20(木) 04:19:04.11ID:b33W7V5i
>>554
https://egg.2ch.net/test/read.cgi/hosp/1542639046/76-83
の議論(>77が俺)は
非医者ニートとの会話だと思う?
相当頭が悪そうだな。

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

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

556卵の名無しさん2018/12/20(木) 08:39:31.68ID:YfbLPysN
>>547
開業医スレに
こういうのを書いたら礼を言われましたよ。
https://egg.2ch.net/test/read.cgi/hosp/1542639046/93

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


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

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

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

557卵の名無しさん2018/12/20(木) 19:49:02.89ID:LEZzzwW7
事務員の日常

2021/01/19(火) 21:51:27.13ID:kd8IADuM
私立医コンプレックスのウリュウのジジイにつける薬などない。


lud20210305234854ca
このスレへの固定リンク: http://5chb.net/r/hosp/1540905566/
ヒント:5chスレのurlに http://xxxx.5chb.net/xxxx のようにbを入れるだけでここでスレ保存、閲覧できます。

TOPへ TOPへ  

このエントリをはてなブックマークに追加現在登録者数177 ブックマークへ


全掲示板一覧 この掲示板へ 人気スレ | >50 >100 >200 >300 >500 >1000枚 新着画像

 ↓「臨床統計もおもしろいですよ、その2 fc2>1本 YouTube動画>16本 ニコニコ動画>1本 ->画像>48枚 」を見た人も見ています:
臨床統計もおもしろいですよ、その1
臨床統計もおもしろいですよ、その3
臨床統計もおもしろいですよ、その3
どんな映画を観てもおもしろいと言い切れるマンだけど質問ある?
 もっともアイテム探しがおもしろいゲームってなんですか?
若月の個人PVってどれひとつもおもしろくないな
どぴゅどぴゅおもしろい 1発目
おもしろい遊び発見したかも
【PSO2朗報】ぎゅ。おもしろい
おもしろいヤクザ漫画ってある?
少女終末旅行、おもしろい
【朗報】アクア民さん、おもしろい
最高におもしろいgifが見つかる
【朗報】ひらがな推しがおもしろい!
最高におもしろい漫画が発見される
最高におもしろい漫画が発見される
氷菓とかってアニメおもしろいんか?
【統計】立憲・枝野代表(埼玉5)「首相秘書官が勝手にやります?勝手にやるわけがないじゃないですか」
はじめて見たけどチコちゃんっておもしろいな
今年の大河なかなかおもしろいじゃないか!
風のスティグマってアニメおもしろい?
お前らの腕時計趣味のおもしろい話を教えてくれ
ケンモジってたまにおもしろいこと言うよね
どこがおもしろいのか信者すらわからないアニメ
アニメ化されるULTRAMANっておもしろいの?
無職・だめ板のおもしろいスレについて語るスレ
ガラスの仮面って無茶苦茶おもしろいじゃねえか
アクションでスコア制ってなにがおもしろいんだ?
こないだから『どろろ』見始めたんだが、おもしろいなw
中古でWii買ったからおもしろいゲーム教えてくれ
競馬予想TVのタオルって奴相当おもしろいなw
おもしろいスレ立てられないからゆーちゅーぶで見つけたえっちな
おもしろいコピペがあったら貼るスレinマ板part45
1番おもしろいバトルロイヤルゲームって何なの?
スイッチのゼルダが絶賛されまくってるがほんまにおもしろいんか
シュタインズ・ゲートってアニメおもしろいんか?
【吾峠呼世晴】鬼滅の刃148斬【これは楽しいおもしろい】
Re:ゼロから始める異世界生活とかってアニメおもしろいんか?
【朗報】顔を絵画みたいにするサイト、おもしろい なんJ民もやるぞ!!
バンカラジオとかいう陽キャタッグのクッソおもしろいYouTube r
青春ブタ野郎はバニーガール先輩の夢を見ないとかってアニメおもしろいんか?
売れたゲームが1番優れてる、1番おもしろいゲームではないということ
わらの犬っていう映画知ってる?めっちゎおもしろいから見たほうがいいや
最高におもしろい漫画ついに発見される…こういうので、こういうので、いいんだよ…
デモンエクスマキナ体験版やったけどあんまりおもしろいと思わなかった
任ファンだがゼルダブスザワってスカスカすぎてどこがおもしろいの?ってなった
【麻雀っておもしろいの?】警官3人が賭けマージャン 徳島、注意処分
上沼恵美子って女芸人では一番おもしろいと思う。関西では向かうところ敵なしやからな。
パトレイバーの映画は一作目はおもしろい二作目も押井色全開で面白い三作目もまあまあおもしろい
公認アニメ『刀使ノ巫女』がボロカス言われていて悲しい。 (ヽ・ん・) おもしろいのに…
おもしろいのになぜかTVであまり使われないお笑い芸人の筆頭ってトータルテンボスだよな?
【兵庫】盲目の美術家の作品触れて 県立美術館で「手で見る造形」展 「ゴワゴワしていておもしろい」とにっこり
エウレカセブンとかいうクソおもしろいアニメwwwwwwwwwwwwwwww
最近のアニメのつまらなさは異常 見ておもしろいだけでなくエレガントに動きまわるアニメが見たい
【書籍】 「すみません、計算間違ってました」著者の謝罪にファン賞賛!! 文庫版『空想科学読本』がおもしろいぞ
「コメントは荒れるほどおもしろい」ネットでの誹謗中傷を漫画にした作者語る“アンチの心理” 一見とても好印象に見える女性が
クエンティン・タランティーノ監督の最新作 主演レオナルド・ディカプリオとブラッド・ピット こんなん絶対おもしろい
【芸能】2019年上半期テレビ出演女性第1位! フリーアナウンサー・新井恵理那「カワイイより、おもしろいと言われるアナウンサーに」
強化人間を臨床的に作りました、その1
松本「50キロの荷物持った状態で走ったら絶対ボルトより曙のほうが足速いと思うんですよ、もうその時点で萎えるやないですか陸上って」
【ラジオ】さんま 規制厳しいテレビに嘆き 若手共演者には「もう、おもしろいテレビ観れないよ」★2 [爆笑ゴリラ★]
はーちん尾形のコントがなかなかおもしろい件
牧野真莉愛「歯医者さんが好き 歯磨き粉の林檎味や塩を楽しめるし,終わったらおもしろ消しゴムを貰えて、まりあ、とっても嬉しいです!」
ニー速ておもしろいよね
おもしろい馬術のゲーム
09:27:58 up 19 days, 5:27, 0 users, load average: 3.70, 3.29, 3.27

in 0.065603971481323 sec @0.065603971481323@1c3 on 051422