hello, everybody, I met a problem that I want to generate a random uniform number by using function with c interface. What I found is only "unif_rand()", but its range is [0,1]. How can I create a uniform random variable by using a function with c interface. Who can tell me what function it is and how to use? I will appreciate for it very much. Thanks in advance! xiaotong wang
What sort of "random uniform numbers" do you want to generate? Without qualifiers, "uniform" usually just refer to U(0,1). If you want the interval to be (a, b), just do X = unif_rand() * (b-a) + a Andy> From: xt_wang at cs.concordia.ca > > hello, everybody, > > I met a problem that I want to generate a random uniform > number by using > function with c interface. > > What I found is only "unif_rand()", but its range is [0,1]. > How can I create a > uniform random variable by using a function with c interface. > > Who can tell me what function it is and how to use? > > I will appreciate for it very much. > > Thanks in advance! > > xiaotong wang > >
On Tue, 15 Jun 2004 18:17:36 -0400, xt_wang at cs.concordia.ca wrote:>hello, everybody, > >I met a problem that I want to generate a random uniform number by using >function with c interface. > >What I found is only "unif_rand()", but its range is [0,1]. How can I create a >uniform random variable by using a function with c interface. > >Who can tell me what function it is and how to use?It's not clear to me what you are asking for. Do you want it to be uniform on the range (A,B)? Use A + (B-A)*unif_rand() or runif(A,B). These are documented in the Writing R Extensions manual, along with a large collection of other distributions (and instructions on how to initialize them). Duncan Murdoch