R Normal Distribution +ggplot_r

Source: Internet
Author: User
Tags ggplot
Randnorm<-rnorm (3000)
# #rnorm (3000) produces 3,000 positive too many distributions
Randdensity<-dnorm (Randnorm)
# # # #dnorm (randnorm) to find its density function value
Ggplot (Data.frame (x=randnorm,y=randdensity)) +aes (x=x,y=y) +geom_point () +labs (x= "Random Normal varables", y= " Randdensity ")
# #将这个你太分分布数以及对应的密度函数值作为x, y-axis values, and draw point graphs
P<-ggplot (Data.frame (x=randnorm,y=randdensity)) +aes (x=x,y=y) +geom_point () +labs (x= "Random Normal Varables", y= " Randdensity ")
# #变量p作为该段代码的引用
Neg1seq<-seq (From=min (randnorm), to=-1,by=0.1)
# #生成一段序列, the starting value is min (randnorm), the end is to=-1, step 0.1
Lessthanneg1<-data.frame (X=neg1seq,y=dnorm (NEG1SEQ))
# #将序列跟该段序列对应的密度函数值作为数据框元素
Lessthanneg1<-rbind (c (min (random), 0), Lessthanneg1,c (Max (lessthanneg1$x), 0)
# #将最小值, the middle, the maximum value of the row and data box
P+geom_polygon (Data=lessthanneg1,aes (x=x,y=y))
# #geom_polygon进行填充, fill the part of the curve with the X-week
Randprob<-pnorm (Randnorm)
# #pnorm () distribution function
Ggplot (Data.frame (X=randnorm,y=randprob)) +aes (x=x,y=y) +geom_point () +labs (x= "Random Normal varables", y= " Randdensity ")
# #绘制分布函数
# #分布函数求积分为密度函数图形

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.