how do i empirically estimate variance of conditional normal distribution?

62 Views Asked by At

I've tried searching for this, but maybe I'm not using the correct search strings. suppose I have joint distribution $P(X_1,X_2)$ over 2 continuous random variables $X_1,X_2$ that I can sample from. What is the correct algorithm to estimate the variance of $P(X_2|X_1)$ ?

if the conditioning variable was discrete, I could simply slice at $X_1 = x_1$ and calculate the variance of the $X_2$ that fall into this slice. the main issue is with the continuous variables. Do I use a smooth bin, where say I wanted $P(X_2|X_1 = 1)$ I would take samples around $X_1 = 1$ weighted by some kernel?

Would appreciate some canonical resource for this, feel I am reinventing the wheel.