Created
October 20, 2025 08:24
-
-
Save abikoushi/47af420c6f072ce5dffb8e5efd56dd9b to your computer and use it in GitHub Desktop.
Try multivariate noncentral hypergeometric distribution in BiasedUrn package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(BiasedUrn) | |
| library(dplyr) | |
| K=10 | |
| set.seed(1234); OR = rexp(K) | |
| ressim = sample.int(K, size = 10000, prob = OR, replace = TRUE) |> | |
| table() |> | |
| as.data.frame() | |
| ressim = mutate(ressim, prob = Freq/sum(Freq)) | |
| theo_F = numeric(nrow(ressim)) | |
| theo_W = numeric(nrow(ressim)) | |
| #i=1 | |
| for(i in 1:nrow(ressim)){ | |
| x = numeric(K) | |
| x[ressim$Var1[i]] = 1 | |
| theo_F[i] = dMFNCHypergeo(x = x, m = rep(1, K), n=1, odds = OR) | |
| theo_W[i] = dMWNCHypergeo(x = x, m = rep(1, K), n=1, odds = OR) | |
| } | |
| plot(theo_F, theo_W) | |
| abline(0,1,lty=2) | |
| plot(ressim$prob, theo_F) | |
| abline(0,1,lty=2) | |
| plot(ressim$prob, theo_W) | |
| abline(0,1,lty=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment