Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(partitions)
- library(BiasedUrn)
- # Sum probabilities for all combinations of two groups.
- # Only works when length(x) = 3. We wish to merge x[1] and x[2].
- sum.mFNCH<-function(x, m, s, w, prec = 1e-07){
- rr <- restrictedparts(sum(x[1:2]),(length(x)-1))
- ss <- 0
- for(i in 1:ncol(rr)){
- ss <- sum(ss, dMFNCHypergeo(c(rr[,i],x[3]),m,s,w, precision=prec) )
- ss <- sum(ss, dMFNCHypergeo(c(rev(rr[,i]),x[3]),m,s,w, precision=prec) )
- }
- return(ss)
- }
- # Multi-variate probability for 3 ball groups with:
- # 22, 47, and 139 balls and weights 0.1, 0.2, and 0.3.
- # Sample a total of 7 balls for the first two groups and 15 for the third.
- x <- c(2,5,15)
- m <- c(22,47,139)
- w <- c(0.1,0.2,0.3)
- sum.mFNCH(x, m, sum(x), w, prec=1e-8)
- [1] 0.1108098
- # Univariate equivalent using average weight.
- wr <- ((22/69)*0.1+(47/69)*0.2)
- # Scale odds relative to third group which now constitute the white balls:
- wr <- wr/0.3
- dFNCHypergeo(7, 69, 139, sum(c(7,15)), wr)
- [1] 0.1120066
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement