rweibull

R plot Probability Density Function


I need to create a plot of the various different types of pdf (normal, beta, weibull, etc) for given parameters. I am very new to R, and every other resource I have been able to find shows how to fit these distributions to data; I can't find any on how to plot the distributions independently. How do I do that?


Solution

  • ## Normal PDF
    x <- seq(-4,4,.001)
    y <- dnorm(x)
    plot(x,y)
    
    ## Beta PDF 
    
    x <- seq(0,1,.001)
    y <- dbeta(x,2,5)
    plot(x,y)
    
    
    # Can also do with line instead of points
    x <- seq(0,1,.001)
    y <- dbeta(x,2,5)
    plot(x,y,type='n')
    lines(x,y)