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) }* Since the sum inside the pdf runs from 0 to infinity, i restrict it to exp(10)[a large number).... My questions are: 1. Does the above function correct for the given pdf? In a journal paper, this distribution is evaluated for x=0,1,2...7 and n=7 and alpha=0.7 and beta=0.59 so I used my function and got densities as: /> dnewdis(0,0.7,0.59,7) [1] 0.9527325 > dnewdis(1,0.7,0.59,7) [1] 4.001476 > dnewdis(2,0.7,0.59,7) [1] 10.40384 > dnewdis(3,0.7,0.59,7) [1] 21.50127 > dnewdis(4,0.7,0.59,7) [1] 38.70228 > dnewdis(5,0.7,0.59,7) [1] 63.47174 > dnewdis(6,0.7,0.59,7) [1] 97.32334 > dnewdis(7,0.7,0.59,7) [1] 141.814/ which are very contradiction to the values provided in the paper!!! 0.136090 0.104612 0.097393 0.096992 0.101203 0.111303 0.134110 0.218296 Also I am getting probabilities greater than 1 too?? Can you please tell me where am I doing wrong and I the function should be corrected? I am a new R user!! Thank you very much for your kind help! -- View this message in context: http://r.789695.n4.nabble.com/Declaring-a-density-function-with-for-loop-tp4635699.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.