Plot normal, left and right skewed distribution in R

前端 未结 3 1639
一个人的身影
一个人的身影 2021-01-30 21:47

I want to create 3 plots for illustration purposes: - normal distribution - right skewed distribution - left skewed distribution

This should be an easy task, but I fo

3条回答
  •  梦毁少年i
    2021-01-30 22:26

    Finally I got it working, but with both of your help, but I was relying on this site.

     N <- 10000
     x <- rnbinom(N, 10, .5)
     hist(x, 
     xlim=c(min(x),max(x)), probability=T, nclass=max(x)-min(x)+1, 
       col='lightblue', xlab=' ', ylab=' ', axes=F,
       main='Positive Skewed')
    lines(density(x,bw=1), col='red', lwd=3)
    

    enter image description here

    This is also a valid solution:

    curve(dbeta(x,8,4),xlim=c(0,1))
    title(main="posterior distrobution of p")
    

提交回复
热议问题