On 07/05/2011 10:17 AM, [email protected] wrote:
> On Mon, Jul 4, 2011 at 10:13 PM, Ted To <[email protected]> wrote:
>> Hi,
>>
>> Is there an easy way to make random draws from a conditional random
>> variable?  E.g., draw a random variable, x conditional on x>=\bar x.
> 
> If you mean here truncated distribution, then I asked a similar
> question on the scipy user list a month ago for the normal
> distribution.
> 
> The answer was use rejection sampling, Gibbs or MCMC.
> 
> I just sample from the original distribution and throw away those
> values that are not in the desired range. This works fine if there is
> only a small truncation, but not so well for distribution with support
> only in the tails. It's reasonably fast for distributions that
> numpy.random produces relatively fast.
> 
> (Having a bi- or multi-variate distribution and sampling y conditional
> on given x sounds more "fun".)

Yes, that is what I had been doing but in some cases my truncations
moves into the upper tail and it takes an extraordinary amount of time.
 I found that I could use scipy.stats.truncnorm but I haven't yet
figured out how to use it for a joint distribution.  E.g., I have 2
normal rv's X and Y from which I would like to draw X and Y where X+Y>= U.

Any suggestions?

Cheers,
Ted To
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to