This site is to serve as my note-book and to effectively communicate with my students and collaborators. Every now and then, a blog may be of interest to other researchers or teachers. Views in this blog are my own. All rights of research results and findings on this blog are reserved. See also http://youtube.com/c/hongqin @hongqin
Saturday, December 21, 2013
rgompertz, Gompertz random number
##########################################
#inverse of gompertz CDF
# see http://hongqinlab.blogspot.com/2013/06/median-lifespan-of-2-parameter-gompertz.html
#inverse.gomp.CDF = function(R,G,y) { (1/G)*log(1 - (G/R)*log(1-y) ) }
#see generate random number with a given distribution
# http://hongqinlab.blogspot.com/2013/12/generate-gompertz-random-numbers.html
#generate Gompertz random numbers
rgompertz = function(R,G, n){
x.uniform = runif(n)
inverse.gomp.CDF = function(R,G,y) { (1/G)*log(1 - (G/R)*log(1-y) ) }
x.gompertz = inverse.gomp.CDF(0.001,0.2, x.uniform)
return(x.gompertz)
}
rgompertz(0.001,0.2,100)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment