[R] Declaring a density function with for loop

David L Carlson dcarlson at tamu.edu
Sat Jul 7 23:40:47 CEST 2012


dnewdis <- function(x, a, b, n) {
    i <- 0:exp(10)
    term <-sum((((-1)**i)*(choose(b-1,i))*(beta(x+a+a*i,n-x+1))))
    a*b*choose(n,x)*term
}

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352




> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of chamilka
> Sent: Saturday, July 07, 2012 10:21 AM
> To: r-help at r-project.org
> Subject: Re: [R] Declaring a density function with for loop
> 
> Thank you very much for you kind explanation Berend Hasselman!!
> 
> Is it possible to declare this probability density function without
> looping?
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Declaring-
> a-density-function-with-for-loop-tp4635699p4635720.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list