R_Language 板


LINE

作者: AmigoSafin () 看板: R_Language 標題: [問題] uniform distribution畫scatterplot 時間: Tue Oct 30 08:27:08 2018 [問題類型]: 程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來) [問題敘述]: 請簡略描述你所要做的事情,或是這個程式的目的 [Update] 我朋友說 marginal Y 不是 1/(2\theta) 苦手了 [Update] 不知道這個可行嗎? ### par(mfrow=c(2,2)) df.1 <- data.frame(x = rnorm(10000, 1, 1), y.1 = runif(10000, -0.1, 0.1)) p.1 <- ggplot(df.1, aes(x, y.1)) + geom_point() + theme_classic() ggExtra::ggMarginal(p.1, type = "histogram") df.2 <- data.frame(x = rnorm(10000, 1, 1), y.2 = runif(10000, -3, 3)) p.2 <- ggplot(df.2, aes(x, y.2)) + geom_point() + theme_classic() ggExtra::ggMarginal(p, type = "histogram") df.3 <- data.frame(x = rnorm(10000, 1, 1), y.3 = runif(10000, -5, 5)) p.3 <- ggplot(df.3, aes(x, y.3)) + geom_point() + theme_classic() ggExtra::ggMarginal(p.3, type = "histogram") df.4 <- data.frame(x = rnorm(10000, 1, 1), y.4 = runif(10000, -25, 25)) p.4 <- ggplot(df.4, aes(x, y.4)) + geom_point() + theme_classic() ggExtra::ggMarginal(p.4, type = "histogram") #### 大家好 想請教大家如果我已知marginal distribution of Y= 1/(2\theta) 題目請我: Graph an approximation to the marginal distribution of Y when \theta=0.1, \theta=3, \theta=5, \theta=25 Use n = 10000 for each \theta 我不太確定我有無理解錯誤 因為他是先給joint p.d.f. p(x,y)=1/[(2\theta)\sqrt(2\pi)] e^{(-(1/2)\times(y-x)^2} ,y \in R x \in [-\theta, \theta] 也給了X marginal density p_x(x)=1/2\theta 所以我直接算出Y的marginal 然後用以下的code(我在網路上找的) 想要畫出題目所要求的 但失敗了 其實我不是很明白題目想要做的 想請教各位高手 題目應該是要我畫出不同的\theta值下 Y的marginal 的變化 請問有大大願意幫忙嗎? 感激不盡 [程式範例]: par(mfrow=c(2,2)) py1 <- runif(10000, min = -0.1, max = 0.1) plot(py1, main="Marginal PDF of Y Scatterplot", pch=19) py2 <- runif(10000, min = -3, max = 3) plot(py2, main="Marginal PDF of Y Scatterplot", pch=19) py3 <- runif(10000, min = -5, max = 5) plot(py3, main="Marginal PDF of Y Scatterplot", pch=19) py4 <- runif(10000, min = -25, max = 25) plot(py4, main="Marginal PDF of Y Scatterplot", pch=19) -- --



※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 129.21.69.148
※ 文章網址: https://webptt.com/m.aspx?n=bbs/R_Language/M.1540859231.A.848.html ※ 編輯: AmigoSafin (129.21.69.148), 10/30/2018 08:45:53
1F:→ andrew43: 題目有貼完整嗎? 10/30 10:13
2F:→ AmigoSafin: 謝A大 剛我朋友說不是uniform 讓我來改 10/30 10:36
※ 編輯: AmigoSafin (8.41.66.201), 10/30/2018 11:03:09 ※ 編輯: AmigoSafin (8.41.66.201), 10/30/2018 11:29:33
3F:→ andrew43: 隨意代入幾個數字,pdf就破1了。 10/30 11:41
哎 還是做不出來 我覺得我沒有搞懂題目要求的 所以code也做不出來 marginal Y 是joint p.d.f.對X的範圍做積分 我覺得我的code要往這個方向做 或者找出marginal Y和 E(Y|X)以及joint p.d.f.的關係 因為題目有說 用以上兩個pdf去做 但...想不出來>"< marginal Y=P(x,y)*P(x|y) 但p(x|y)沒有給 不好意思排版有點亂 還是希望有高手願意分享如果有用R的marginal plot 做過類似題目的 看看要怎麼做 通常答案都比想象的簡單 但自己就是做不出來 ※ 編輯: AmigoSafin (8.41.66.201), 10/30/2018 11:48:32
4F:→ AmigoSafin: A大您是說我的code的pdf嗎?uniform 那個嗎? 10/30 11:50
5F:→ andrew43: p(x,y)這個pdf確認有沒有貼正確。寫得嚴謹一點 10/30 11:55
※ 編輯: AmigoSafin (129.21.71.84), 11/01/2018 02:31:58
6F:→ AmigoSafin: 已修正 謝謝~~ 11/01 02:32
7F:→ andrew43: 參考 https://ideone.com/NW4ENl 11/01 10:07
8F:→ AmigoSafin: 謝謝A大~ 11/02 21:56
9F:→ andrew43: 我漏了句 library(plot3D) 11/02 22:14
10F:→ andrew43: 推錯 11/02 22:14
11F:→ andrew43: 啊沒推錯,請自行補上 library(plot3D) 11/02 22:14
12F:→ AmigoSafin: 謝謝A大~我在找時間重新做一遍 又有其他工作追殺lol 11/03 04:17







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:Soft_Job站內搜尋

TOP