0
$\begingroup$

Consider the following 11 continuous non-negative observations:

0, 0.3, 0.31, 0.33, 0.37, 0.49, 0.51, 0.53, 0.59, 0.6

  1. Obtain the empirical cumulative distribution function for these observations.
  2. Use the inversion method to simulate 1000 readings from this ECDF.

I tried using:

A<-c(0, 0.3, 0.31, 0.33, 0.37, 0.49, 0.51, 0.53, 0.59, 0.6)
ecdf(A)
plot.ecdf(A, main="ECDF of sample")

But this was I cannot get the function, and hence cannot simulate. Any ideas please?

$\endgroup$
2
  • $\begingroup$ You might want to look at a combination of runif and the quantile function, with careful consideration which type is most suitable here $\endgroup$ – Henry Feb 12 '20 at 23:46
  • $\begingroup$ What do you mean by "cannot get the function"? $\endgroup$ – Peter Flom Feb 13 '20 at 11:25
2
$\begingroup$
A <- c(0, 0.3, 0.31, 0.33, 0.37, 0.49, 0.51, 0.53, 0.59, 0.6)
e <- ecdf(A)
plot.ecdf(A, main="ECDF of sample")

e is a function giving the ECDF of A.

It's a bit late so I'm quite tired, but I think for the inversion method, you need to obtain the inverse CDF, and to transform 1,000 uniformly distributed numbers using the inverse CDF. This is, as is said in the literature, left as an exercise for the reader.

By the way, this seems like a homework assignment. You should tag it as such (self-study).

$\endgroup$
0
$\begingroup$

ecdf(A) is a function, so you call that function by giving it an argument. e.g ecdf(A)(x).

However, you can sample that ecdf just using sample (by sampling A with replacement).

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.