# Re: [R] binomial distribution

From: Peter Dalgaard <P.Dalgaard_at_biostat.ku.dk>
Date: Fri, 27 Jun 2008 17:24:33 +0200

Peng Jiang wrote:
> Hi, xiechao
> i don't think that is a R specific problem. you mean u got two random
> variables X,Y and both
> of them binomial distributed and you want to find the distribution of
> a new variable Z = X/Y.
> That is a basic transformation problem. u can start with introducing a
> new r.v. namely W, by
> letting it equal to X you obtain W=X,Z=X/Y from which u have X = W
> and Y = W / Z. It is easy
> to find the Jacobian of this transformation, and the left is routinely.
Not that easy! X and Y are discrete, and the result is an improper distribution since there is a positive probability of dividing by 0. If the mean of X and Y are moderately large, the delta method can be used. If they have a small(-ish) number of different values, I'd be tempted just to use brute force, as in

r <- outer(x,y,"/")
r[0,0] <- 0 # 0/0 defaults to NaN
p <- outer(dbinom(x,10,.5), dbinom(y,10,.5)) o <- order(r)
plot(r[o],cumsum(p[o]), type="s")
plot(unique(r[o]),tapply(p[o],list(r[o]), sum), type="h")

(the latter plot is not quite right --- should take better care of rounding issues)
>
> regards.
> On 2008-6-27, at 下午8:29, Xie Chao wrote:
>
>> Hi all,
>>
>> I am a biological student and need your help in statistics.
>>
>> I have two sets of binomial distributed numbers: {a1, a2, ..., an}
>> and {b1,
>> b2, ..., bn}.
>> How can I get the distribution of the ratios of the two sets of numbers
>> {a1/b1, a2/b2, ..., an/bn}? Is there a formula to transform the
>> distributions? Or where I can start if I want to learn necessary
>> techniques?
>> Thank you a lot!
>>
>> xiechao
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help_at_r-project.org mailing list
>>
https://stat.ethz.ch/mailman/listinfo/r-help
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> -----------------------------------------------
> Peng Jiang
> 江鹏
> Ph.D. Candidate
> Antai College of Economics & Management
> 安泰经济管理学院
> Department of Mathematics
> 数学系
> Shanghai Jiaotong University (Minhang Campus)
> 200240 Shanghai
> P. R. China
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

```--
O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard_at_biostat.ku.dk)              FAX: (+45) 35327907

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help