I have an empirical joint distribution function
$ \hat{F}(x_1,x_2) = Pr(X_1 < x_1, X_2 < x_2) $
Can I generate bivariate random number from this distribution with a certain condition such as $ X_1 > c_1, X_2 > c_2 $ ?
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It only takes a minute to sign up.
Sign up to join this communityI have an empirical joint distribution function
$ \hat{F}(x_1,x_2) = Pr(X_1 < x_1, X_2 < x_2) $
Can I generate bivariate random number from this distribution with a certain condition such as $ X_1 > c_1, X_2 > c_2 $ ?
Assuming that the only thing that you have is an empirical distribution, the simplest way to go is to draw values from $\hat F$ and reject if $X_1 \leq c_1$ and $X_2 \leq c_2$. Less naive implementation would be to subset $(X_1, X_2)$ values so to drop the values below threshold and draw from $\hat F_\text{trunc}$, the same way as you would do with any other discrete distribution. Simple example in R of such approach can be find below.
set.seed(123)
c1 <- -1
c2 <- 0.5
X <- data.frame(X1 = rnorm(100), X2 = rnorm(100)) # creating fake data
X_trunc <- subset(X, X1 > c1 & X2 > c2) # subset
# draw 1000 samples
X_trunc[sample(nrow(X_trunc), 1000, replace = TRUE), ]
The above example assumes that you have the full data, however if the only thing that you have is the empirical distribution tables with probabilities for $(x_1,x_2)$, than the procedure is the same but you draw the $(x_1,x_2)$ pairs with $\hat F(x_1,x_2)$ probabilities as in the example below.
library(dplyr)
# lets calculate the probabilities for x1,x2 pairs
FX <- group_by(X, X1, X2) %>%
summarise(n = n()) %>%
ungroup() %>%
mutate(prob = n/sum(n))
# next, we subset and sample as above but from F(X1,X2)
FX_trunc <- subset(FX, X1 > c1 & X2 > c2)
# notice that here we sample with parameter prob set to F(x1,x2)
FX_trunc[sample(nrow(FX_trunc), 1000, replace = TRUE, prob = FX_trunc$prob), ]
Drawing from bivariate distribution does not differ in here from drawing from univariate distribution, the values to be drawn are pairs, or more precisely indexes for those pairs.
X
can be any bivariate distribution. Check my edit where I show in greater detail how to deal with $\hat F$ if you do not have the data but only the table of probabilities.
$\endgroup$