We have done it, thanks very much!

2010-03-13



Randel



发件人: Yihui Xie <xie@yihui.name>
发送时间: 2010-03-12 22:48
主 题: Re: [R] rmaxwell in C
收件人: 王杰彪 <tryshy@163.com>
抄 送: r-help <r-help@r-project.org>





The manual R-exts, section 6.7.1 should help if you want to call rgamma() in C. 

Regards, 
Yihui 
-- 
Yihui Xie <xieyihui@gmail.com> 
Phone: 515-294-6609 Web: http://yihui.name 
Department of Statistics, Iowa State University 
3211 Snedecor Hall, Ames, IA 



2010/3/12 xie <xie@yihui.name>: 
> rmaxwell() depends on rgamma(), so what you actually need is to download R source (rgamma() might depend further on other functions, though). 
> 
>> library(VGAM) 
>> rmaxwell 
> function (n, a) 
> { 
> if (!is.Numeric(n, posit = TRUE, allow = 1)) 
> stop("bad input for argument 'n'") 
> if (any(a <= 0)) 
> stop("argument 'a' must be positive") 
> sqrt(2 * rgamma(n = n, 1.5)/a) 
> } 
> <environment: namespace:VGAM> 
> 
> Regards, 
> Yihui 
> -- 
> Yihui Xie <xieyihui@gmail.com> 
> Phone: 515-294-6609 Web: http://yihui.name 
> Department of Statistics, Iowa State University 
> 3211 Snedecor Hall, Ames, IA 
> 
> 
> 
> On Fri, Mar 12, 2010 at 12:18 AM, 王杰彪 <tryshy@163.com> wrote: 
>> Hi R useRs: 
>> 
>> How can I generate a random sample from Maxwell Distribution in C language? 
>> Since I know the function rmaxwell {VGAM}, I tried the function r2c {r2c}. 
>> But I still cannot find the source code. 
>> 
>> Thanks for your kind help. 
>> 
>> RegaRds, 
>> 
>> 2010-03-12 
>> 
>> 
>> 
>> Randel 
>>        [[alternative HTML version deleted]] 
>> 
>> ______________________________________________ 
>> R-help@r-project.org mailing list 
>> https://stat.ethz.ch/mailman/listinfo/r-help 
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 
>> and provide commented, minimal, self-contained, reproducible code. 
>> 
> 
> 
	[[alternative HTML version deleted]]

