Message-ID: <1341659551748-4635706.post@n4.nabble.com>
Date: 2012-07-07T11:12:31Z
From: Berend Hasselman
Subject: Declaring a density function with for loop
In-Reply-To: <1341655863664-4635699.post@n4.nabble.com>
chamilka wrote
>
> I have an extended binomial distribution which has the following form:
>
> http://r.789695.n4.nabble.com/file/n4635699/kb.png
>
> Here alpha and beta are two parameters and x=0,1,2,3,...n (alike the
> binomial distribution)
> I am writing a function to find out the densities (probabilities) of this
> distribution for given values of alpha and beta. The below is the my
> function...
>
> dnewdis<-function(x,a,b,n) {
> term<-0
> for (j in 0:exp(10)) {
> term=term+(((-1)**i)*(choose(b-1,i))*(beta(x+a+a*i,n-x+1)))
> }
> s=a*b*choose(n,x)*term
> return(s)
> }
>
The error is the line
for (j in 0:exp(10)) {
Shouldn't that be
for (i in 0:exp(10)) {
When I use this line results appear to be more in line with what you are
expecting.
Berend
--
View this message in context: http://r.789695.n4.nabble.com/Declaring-a-density-function-with-for-loop-tp4635699p4635706.html
Sent from the R help mailing list archive at Nabble.com.