# Simulation of multivariate logistic distribution conditional to a plane

For an algorithm, I have to simulate $$X_1, \ldots, X_n \sim_{\text{iid}} \text{Logistic}(0,1)$$ conditionally to the event $$(X_1, \ldots, X_n) \in P$$, where $$P$$ is an affine plane in $$\mathbb{R}^n$$.

I really need to sample from this distribution; the goal is not to evaluate an integral.

What are the possible methods?

• @MattF.The affine plane is $P=\{u\alpha+v\beta+b\mid u,v\in \mathbb{R}^2\}$ where $\alpha$ and $\beta$ are two orthogonal vectors in $\mathbb{R}^n$ and $b \in \mathbb{R}^n$. So the event has probability $0$. I need to simulate the conditional distribution. – Stéphane Laurent Dec 12 '20 at 17:50

According to your comment, your plane is $$P=\{u\alpha+v\beta+b\colon(u,v)\in\mathbb R^2\}$$, where $$\alpha$$ and $$\beta$$ are two orthogonal vectors in $$\mathbb R^n$$ and $$b\in\mathbb R^n$$. Assuming that the vectors $$\alpha$$ and $$\beta$$ are nonzero, let $$(a_1,\dots,a_n)$$ be any basis of $$\mathbb R^n$$ such that $$a_1=\alpha$$ and $$a_2=\beta$$. Let the random variables $$Y_1,\dots,Y_n$$ be the coordinates of the random vector $$X-b$$, where $$X:=[X_1,\dots,X_n]^T$$, so that $$X-b=AY$$, where $$A$$ is the $$n\times n$$ matrix with columns $$a_1,\dots,a_n$$ and $$Y:=[Y_1,\dots,Y_n]^T$$.
Then the joint pdf of $$X_1,\dots,X_n$$ is given by the formula $$f_X(x)=f(x_1)\cdots f(x_n)\tag{1}$$ for $$x=(x_1,\dots,x_n)\in\mathbb R^n$$, where $$f$$ is the pdf of $$\text{Logistic}(0,1)$$, and the joint pdf of $$Y_1,\dots,Y_n$$ is given by the formula $$f_Y(y)=f_X(b+Ay)|\det A| \tag{2}$$ for $$y=(y_1,\dots,y_n)\in\mathbb R^n$$.
So, the joint pdf of the 2D conditional distribution you want to sample from is given by the formula $$f_{Y_1,Y_2|Y_3,\dots,Y_n}(y_1,y_2|y_3=\dots=y_n=0) =\frac{f_Y(y_1,y_2,0,\dots,0)}{f_{Y_3,\dots,Y_n}(0,\dots,0)} \propto f_Y(y_1,y_2,0,\dots,0)$$ for $$(y_1,y_2)\in\mathbb R^2$$, where $$f_{Y_3,\dots,Y_n}$$ is the joint pdf of $$Y_3,\dots,Y_n$$ and $$\propto$$ means "proportional to".
So, if you don't want to evaluate the integral $$f_{Y_3,\dots,Y_n}(0,\dots,0)=\int_{\mathbb R^2}dy_1\,dy_2\, f_Y(y_1,y_2,0,\dots,0),$$ then to sample from the 2D conditional distribution in question you can use one of the Markov chain Monte Carlo (MCMC) methods, which "create samples from a continuous random variable, with probability density proportional to a known function." In your case, the known function is $$(y_1,y_2)\mapsto f_Y(y_1,y_2,0,\dots,0)$$, with $$f_Y$$ computed according to (2) and (1).