Reputation: 3153
I have a vector of discrete data and I want to simulate from the empirical distribution associated to this data, I was simulating with the function rlogspline after doing fit<-logspline(vector_of_data) where vector_of_data is data that is suppose to be coming from a continuous distribution, that's why I used logspline, but with this vector I have the certainty that the values in it are of discrete nature so I can't use logspline to adjust a "fit" for it.
Basically what I want to do is to adjust a "fit" of the observed data and then use that fit to simulate those values. Do you think this can be done in R?
Thank you very much for your help.
Upvotes: 1
Views: 422
Reputation: 6784
I am not totally clear exactly what you are trying to do, but could you use something like quantile
and runif
, for example:
obs <- c(125,110,115,100,150) # original observations
sim <- quantile(obs, runif(10000)) # simulations
hist(sim, freq=FALSE)
Upvotes: 0
Reputation: 226077
I think sample(x,...,replace=TRUE)
(sampling with replacement) should simulate from the empirical distribution ...
Upvotes: 2