[Numpy-discussion] Conditional random variables
Janos
jkramar@gmail....
Sat Oct 29 16:11:40 CDT 2011
Ted To <rainexpected <at> theo.to> writes:
>
> On 07/05/2011 11:07 AM, josef.pktd <at> gmail.com wrote:
> > For example sample x>=U and then sample y>=u-x. That's two univariate
> > normal samples.
>
> Ah, that's what I was looking for! Many thanks!
>
You need to be careful, though - if you just sample x|x>=u and then sample
y|y>=u-x then you'll get the wrong distribution unless x|x>=u has the same
distribution as x|x+y>=u, which is false. What you should actually do if you
want draws from (x,y)|x+y>=u is first sample (x+y)|(x+y)>=u, and then x|x+y, and
then compute y=(x+y)-x.
If x~N(mu_x, sigma_x^2) and y~N(mu_y, sigma_y^2) with correlation rho, then
x+y~N(mu_x+mu_y, sigma_x^2+sigma_y^2+2*rho*sigma_x*sigma_y), and
x|x+y~N(mu_x+r*(x+y-mu_x-mu_y), sigma_x^2*(1-r^2)), where
r=cor(x,x+y)=(1+(1-rho^2)(rho+sigma_x/sigma_y)^-2)^(-1/2).
More information about the NumPy-Discussion
mailing list