I want to simulate data from a non-standard density function. I already found the following link (How do I best simulate an arbitrary univariate random variate using its probability function?). However, this gives weird results. Somehow, this cumulative density function ( cdf() ) does not work well. From some values, it gives very strange results. For example, take a look at the following code:
density=function(x)(25*200.7341^25/x^26*exp(-(200.7341/x)^25))
cdf<-function(x) integrate(density,1,x)[[1]]
cdf(9701)
[1] 1
cdf(9702)
[1] 6.33897e-05
So my question, how can I create a "good" CDF function? Or more directly, how can I simulate data from a PDF?