0

I generated 200 random numbers with the random variable that Y~Exponential(0.8) using:

n=rexp(200,0.8)
bins=cut(n,breaks=c(0,1,2,3,max(n)))

I am trying to compute the expected number of counters for each bin knowing that Y~Exponential(0.8). How can i do this?

1 Answers1

1

You can use the same set of functions that ?rexp is from to calculate the proportions in each range, and use this to calculate expected numbers:

num  <- 200
brks=c(0,1,2,3,Inf)

set.seed(12345)
n    <- rexp(num,0.8)
bins <- cut(n,breaks=brks)

expect.prop <- diff(pexp(brks, rate=0.8))
#[1] 0.55067104 0.24743245 0.11117856 0.09071795

rbind(
  observed=table(bins),
  expected=num*expect.prop
)
#            (0,1]    (1,2]    (2,3]  (3,Inf]
#observed 115.0000 42.00000 24.00000 19.00000
#expected 110.1342 49.48649 22.23571 18.14359
thelatemail
  • 91,185
  • 12
  • 128
  • 188