Skip to main content
deleted 67 characters in body
Source Link
kjetil b halvorsen
  • 82.8k
  • 32
  • 201
  • 663
library(MASS) # for mvrnorm to generate multivariate normal distributions

# Define the mean vector and covariance matrix
mu <- c(3, 2, 1) # The mean vector μ
Sigma <- matrix(c(1, 0.5, 0.7,    # First row of the covariance matrix
                  0.5, 2, 0.7,    # Second row
                  0.7, 0.7, 1),   # Third row
                nrow = 3, ncol = 3, byrow = TRUE) # Reshape into 3x3 matrix

# Generate samples from the multivariate normal distribution
set.seed(123) # For reproducibility
samples <- mvrnorm(n = 10000, mu = mu, Sigma = Sigma)

# Filter samples where X2 > X3
filtered_samples <- samples[samples[,2] > samples[,3],]

# Compute the approximate expectation of X1 given X2 > X3
E_X1_given_X2_gt_X3 <- mean(filtered_samples[,1])

print(E_X1_given_X2_gt_X3
2.93153
library(MASS) # for mvrnorm to generate multivariate normal distributions

# Define the mean vector and covariance matrix
mu <- c(3, 2, 1) # The mean vector μ
Sigma <- matrix(c(1, 0.5, 0.7,    # First row of the covariance matrix
                  0.5, 2, 0.7,    # Second row
                  0.7, 0.7, 1),   # Third row
                nrow = 3, ncol = 3, byrow = TRUE) # Reshape into 3x3 matrix

# Generate samples from the multivariate normal distribution
set.seed(123) # For reproducibility
samples <- mvrnorm(n = 10000, mu = mu, Sigma = Sigma)

# Filter samples where X2 > X3
filtered_samples <- samples[samples[, 2] > samples[, 3],]

# Compute the approximate expectation of X1 given X2 > X3
E_X1_given_X2_gt_X3 <- mean(filtered_samples[,1])

print(E_X1_given_X2_gt_X3) 
2.93153
library(MASS) # for mvrnorm to generate multivariate normal distributions

# Define the mean vector and covariance matrix
mu <- c(3, 2, 1) # The mean vector μ
Sigma <- matrix(c(1, 0.5, 0.7,    # First row of the covariance matrix
                  0.5, 2, 0.7,    # Second row
                  0.7, 0.7, 1),   # Third row
                nrow = 3, ncol = 3, byrow = TRUE) # Reshape into 3x3 matrix

# Generate samples from the multivariate normal distribution
set.seed(123) # For reproducibility
samples <- mvrnorm(n = 10000, mu = mu, Sigma = Sigma)

# Filter samples where X2 > X3
filtered_samples <- samples[samples[,2] > samples[,3],]

# Compute the approximate expectation of X1 given X2 > X3
E_X1_given_X2_gt_X3 <- mean(filtered_samples[,1])

print(E_X1_given_X2_gt_X3
2.93153
library(MASS) # for mvrnorm to generate multivariate normal distributions

# Define the mean vector and covariance matrix
mu <- c(3, 2, 1) # The mean vector μ
Sigma <- matrix(c(1, 0.5, 0.7,    # First row of the covariance matrix
                  0.5, 2, 0.7,    # Second row
                  0.7, 0.7, 1),   # Third row
                nrow = 3, ncol = 3, byrow = TRUE) # Reshape into 3x3 matrix

# Generate samples from the multivariate normal distribution
set.seed(123) # For reproducibility
samples <- mvrnorm(n = 10000, mu = mu, Sigma = Sigma)

# Filter samples where X2 > X3
filtered_samples <- samples[samples[, 2] > samples[, 3],]

# Compute the approximate expectation of X1 given X2 > X3
E_X1_given_X2_gt_X3 <- mean(filtered_samples[,1])

print(E_X1_given_X2_gt_X3) 
2.93153
Source Link
ADAM
  • 751
  • 4
  • 12

Let the mean vector and covariance matrix of $(X_1, X_2, X_3)$ be denoted as $\mu$ and $\Sigma$, respectively, where:

$$\mu = \left[ \begin{array}{c} \mu_1 \\ \mu_2 \\ \mu_3 \end{array} \right]$$

and

$$\Sigma = \left[ \begin{array}{ccc} \sigma_{11} & \sigma_{12} & \sigma_{13} \\ \sigma_{21} & \sigma_{22} & \sigma_{23} \\ \sigma_{31} & \sigma_{32} & \sigma_{33} \end{array} \right].$$

The conditional distribution of $X_1$ given $X_2$ and $X_3$ is also normally distributed, with its mean and variance given by the properties of the multivariate normal distribution. However, the condition $X_2 > X_3$ complicates the calculation, turning it into a problem involving conditional distributions based on an inequality.

For multivariate normals, the conditional expectation $E(X_1 | X_2, X_3)$ can be directly computed if $X_2$ and $X_3$ were given as constants. However, given the condition $X_2 > X_3$, we have to integrate over the joint distribution of $X_2$ and $X_3$ where $X_2 > X_3$, weighted by the conditional density of $X_1$ given $X_2$ and $X_3$.

The closed form solution for $E(X_1 | X_2 > X_3)$ is not straightforward because it depends on the joint distribution of $X_2$ and $X_3$, and involves integrating over a region defined by $X_2 > X_3$. In general, the solution might involve numerical methods or approximations because the integral defining $E(X_1 | X_2 > X_3)$ does not usually simplify nicely for arbitrary covariance matrices.

But in the most general case, where $\Sigma$ allows for arbitrary correlations among $X_1$, $X_2$, and $X_3$, finding a closed-form solution for $E(X_1 | X_2 > X_3)$ requires integrating over the conditional density of $X_1$ given $X_2$ and $X_3$, subject to $X_2 > X_3$, which is typically done using numerical methods rather than analytical expressions.

To approximate $E(X_1 | X_2 > X_3)$ for a multivariate normal distribution with mean vector $\mu = \{3, 2, 1\}$ and covariance matrix $$\Sigma = \left[ \begin{array}{ccc} 1 & 0.5 & 0.7 \\ 0.5 & 2 & 0.7 \\ 0.7 & 0.7 & 1 \end{array} \right]$$

we can use Monte Carlo simulation. Monte Carlo simulation involves generating samples from the multivariate normal distribution and filtering for the condition $X_2 > X_3$. This method is straightforward and relies on the law of large numbers to approximate the expected value.

library(MASS) # for mvrnorm to generate multivariate normal distributions

# Define the mean vector and covariance matrix
mu <- c(3, 2, 1) # The mean vector μ
Sigma <- matrix(c(1, 0.5, 0.7,    # First row of the covariance matrix
                  0.5, 2, 0.7,    # Second row
                  0.7, 0.7, 1),   # Third row
                nrow = 3, ncol = 3, byrow = TRUE) # Reshape into 3x3 matrix

# Generate samples from the multivariate normal distribution
set.seed(123) # For reproducibility
samples <- mvrnorm(n = 10000, mu = mu, Sigma = Sigma)

# Filter samples where X2 > X3
filtered_samples <- samples[samples[,2] > samples[,3],]

# Compute the approximate expectation of X1 given X2 > X3
E_X1_given_X2_gt_X3 <- mean(filtered_samples[,1])

print(E_X1_given_X2_gt_X3
2.93153