On Tue, 28 Jan 2003 16:01:06 +0000, you wrote in message
<[EMAIL PROTECTED]>:

>
>Dear R ers, if some can tel me how I can generate a sample from a given 
>density. I have a complex  2D density function en I want to genearte
>a sample from it? Any package?

That's generally a hard problem, and the answer depends a lot on the
particular characteristics of your distribution.  The easiest general
purpose method if you can calculate the density is probably MCMC, in
particular random walk Metropolis; see the book Markov Chain Monte
Carlo in Practice for details.  This will give you a Markov chain that
(hopefully) converges to your target distribution.  If you only want a
small sample, it's quite inefficient, but for a large sample (e.g. for
estimating moments) it can be quite good.

Support in R for MCMC is pretty much non-existent, but it's easy to
write the chains yourself.

Duncan Murdoch

______________________________________________
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to