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/cn.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灯, 水草

请输入看板名称,例如:Gossiping站内搜寻

TOP