简体   繁体   中英

overlaying exponential distribution onto histogram

How can i overlay an exponential distribution on a histogram of time intervals? The histogram looks like an exponential distribution. When I try to create the histogram in a similar way to superimposing a normal curve I get the following:

Error in xy.coords(x, y) : 'x' and 'y' lengths differ

I can create the histogram on its own which has an x axis from 0 to 70. And I can create an exponential distribution curve on its own but its x axis goes from 0 to 1.

I am using hist(t) where t is a list of times in seconds for the histogram and curve(dexp(x,rate=0.09)) for the exponential distribution.

Make sure to use prob = TRUE in hist , and add = TRUE in curve

z <- rexp(300,rate = 0.09)
hist(z, prob = TRUE)
curve(dexp(x, rate = 0.09), col = 2, lty = 2, lwd = 2, add = TRUE)

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM