I am trying to do a simulation in Stata with a random sample of 10000 for the variable X with pdf f(x) = exp(-x), X>0
I tried inserting a large number for the upper limit, but it does not seem to work. My stata code was:
clear
set obs 10000
set seed 272915
gen x= 0 + 100000000*runiform()
gen y= (exp(-x))
histogram y
summ y, detail
I have also tried (i) gen u= inv(x) & gen y =(exp(-x)), and (ii) gen y=invexponential(exp(-x)), but these are both invalid syntaxes
What would be the correct way of generating uniform random numbers between 0 and infinity, and applying these to an exponential distribution with domain (x, infinity). Any help on the specific stata code would be appreciated.
Aucun commentaire:
Enregistrer un commentaire