This might be a really elementary question, but I'm not sure what it means. I have a density function f(x). How do I sample a value from f? For known distributions there are functions in R which do it for you (e.g. runif, rnorm, etc.) but how do I generate a random number using my own density?



What does it mean to sample a value x* from f(x)?
In the simple case that $X$ is a real valued random variable, the first thing I would reach for is the [inverse-cdf method](http://en.wikipedia.org/wiki/Inverse_transform_sampling), especially since you have mentioned "runif" which gives draws from a uniform distribution. 


There is a pretty extensive literature on ways to sample from a variety of distributions, with names like Gibbs sampling, Metropolis-Hastings, slice samplers, perfect samplers, etc. A Google search of any of these should bring up a wealth of info. Did you want something more specific?


