Search code examples
rscale

R Beta function - relative y scale


I am having trouble understanding the Beta function in R. I want the y scale to display a relative value in percent (0->1). How do I achive this with the graph having the same form?

x = seq(0,1,0.001)
plot(x,dbeta(x,10,40), type="l", col="red", xlab="time", ylab="frequency")

Solution

  • It sounds like you're looking for the beta density, normalized so the maximum value is 1. This could be accomplished with:

    x = seq(0,1,0.001)
    density = dbeta(x, 10, 40)
    plot(x, density/max(density), type="l", col="red", xlab="time", ylab="frequency")
    

    enter image description here