作者binchung (ideal)
看板Statistics
標題Re: [問題] R 兩個問題
時間Tue Jul 8 11:09:23 2008
1. If you can calulate the inverse function of the cumulative function easily,
then randomly sample U1,...,Un from Uniform distribution and compute values of
the inverse function at U1,...,Un.
Or try gibb's sampling.
2. I think there should be a function for arctan in R.
※ 引述《laba1014 (嘿喲~加油!!!)》之銘言:
: 不好意思有兩個R的問題要請教 :
: 1. 請問若已知某分配的 p.d.f 型態 ,
: 譬如 f(x) =1/a(√π)^(-1) * gamma(m)/gamma(m-1) *(1+ x^2/a^2)^(-m)
: 要怎麼寫程式才能從該分配中進行抽樣本的動作 ?
: 2. 反函數要怎麼寫 ?
: 譬如 已知x 但想知道 tan^(-1)(x) 應該怎麼做 ?
: 希望版上前輩能不吝指教 <(_ _)>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 208.125.17.166
1F:→ laba1014:感謝 <(_ _)> 我去找找 gibb's sampling要怎麼用 07/08 16:39
2F:→ clickhere:這跟Gibb無關吧?! 07/09 08:13
3F:→ clickhere:如果m是正整數,那這是cauchy的變型,在R用rcauchy就行了. 07/09 08:21
4F:→ clickhere:上面是錯的, m=2才是cauchy 07/09 08:23
5F:→ clickhere:sorry, m=1才是 07/09 08:24
6F:推 clickhere:所以你這是t分佈的變型. m應該是a的函數吧? 07/09 08:29
7F:→ clickhere:在R中,用 rt(), 再套用rejection method就行了. 07/09 08:30
8F:推 laba1014:C大眼光真是有夠利 我是想從pearson type 4 的分配取 07/09 17:25
9F:→ laba1014:r.v 這分配的確包含上述所提的分配只是參數多不少 07/09 17:26