TITLE: Decompose dependent random variables into function of dependent and independent parts
QUESTION [9 upvotes]: Let $X$ and $Z$ be two (possibly dependent) random variables. Is it necessarily the case that there exists a Borel function f and a random variable $Y$ that is independent of $X$ such that $Z = f(X, Y)$? If this is true, this would help with a result I am trying to prove. By random variable, the more general the better, ideally the proof technique would work for all of classical random variables, random vectors in $\mathbb{R}^n$, random elements in a metric space, etc. There are no conditions on $f$ other than Borel, it can be discontinuous, etc. The only condition of $Y$ is that it is independent of $X$.
Also, if this is a known result in some book or article, could you please post the name that book or paper and where this result is contained. Almost everything I can find talks about under what conditions dependent random variables can be written as sums or linear combinations of others (for example, https://en.wikipedia.org/wiki/Indecomposable_distribution), nothing about general functions.

REPLY [6 votes]: I interpret the question as suggested in my comment above: we would like to find random variables $X,Z$ on some probability space with the given joint distribution, and then a third random variable $Y$ with the requested properties.
Given $X:\Omega\to\mathbb R$ with the right distribution, we can take $Y$ as uniformly distributed on $[0,1]$, on the probability space $\Omega\times [0,1]$ now. Matching the distributions is equivalent to making sure that the conditional distribution of $Z=f(X,Y)$, given $X$, comes out right. Write $F(x,t)=P(Z<t|X)(x)$. Then we can put $f(x,F(x,t+))=t$ (and make $f(x,\cdot)$ constant on the gaps, if any). This delivers the right joint distribution of $X$ and $f(X,Y)$ by construction, and it is measurable because $f(x,y)<\alpha$ precisely if $y<F(x,\alpha-)$.