khazaei at ceremade.dauphine.fr
2009-Dec-25 16:07 UTC
[R] [ how can sample from f(x)~x^(a-1)
Hello all how can sample from f(x)~x^(a-1)*ind(0,min(b,-log(u)) in R? where a and b is positive constand and 0<u<1 thanks khazaei
On Fri, Dec 25, 2009 at 8:07 AM, <khazaei@ceremade.dauphine.fr> wrote:> Hello all > how can sample from f(x)~x^(a-1)*ind(0,min(b,-log(u)) in R? > where a and b is positive constand and 0<u<1 >If the idea is that X is a random variable, then you need to decide what kind of random variable it is. For example, if you wanted to assume that it was a random uniform variable roughly on the interval of -infinity to infinity, you can do something like: runif(10000, -1e100, 1e+100)^(a-1)*ind(0,min(b,-log(u))) (I'm not sure whether my limits are a good stand-in for -infinity to +infinity.) There are a number of functions that all start with r that sample from various distributions -- rnorm(), runif(), rexp(), ... Once you decide what X is, it is pretty straightforward. I was going to look at your function, but I don't know what ind() is, so I was stuck. Michael [[alternative HTML version deleted]]
khazaei said:> how can sample from f(x)~x^(a-1)*ind(0,min(b,-log(u)) in R? > where a and b is positive constand and 0<u<1It looks like you've mixed together part of the deensity of a random variable and part of a method of generating one. Is u a fixed quantity or a random uniform? What is "ind"? -- View this message in context: http://n4.nabble.com/how-can-sample-from-f-x-x-a-1-tp978822p979342.html Sent from the R help mailing list archive at Nabble.com.