In article <[EMAIL PROTECTED]>,
 Su K Yong <[EMAIL PROTECTED]> wrote:

> I would to generate random number for truncated Laplace PDF. I saw from
> a report that a truncated distribution function can be expressed as
> 
>               F_truncated(x)=F(x)-F(low)/ (F(upper)-F(low)) ; low <=x
> <=upper
> 
> For Laplace distribution function, F(x) can have
> 
>                                F(x) = 1/2 * exp(-(a-x)/b)  for  x<a
> 
>                         and F(x)=1-(1/2)*exp(-(x-a)/b)  for x>=a
> 
> where a and 2b^2 are the mean and variance respectively.
> 
> So I generate random variates having distribution function F_truncated
> is as follows,
> (1) Generate U ~ U(0, 1).
> (2) Set Y = F(low) + [F(upper) - F(lower)]U.
> (3) Return x = inverse F(Y).
> 
> It turns out that I have the following  x
> 
> x=a + b * ln ( 2*(U*(F(upper)-F(low)) + F(low))); for x <a
> 
> x=a - b *  ln ( 2*(1-U*(F(upper)-F(low)) - F(low))); for x >= a
> 
> 
> However, when generated the outputs do not seems correct at all. I don't
> know where had gone wrong. Thanks in advance for any help.

I don't see something obviously wrong but I think your algorithm can be 
substantially simplified. Instead of generating an uniform deviate over 
(0,1) how about using a more restricted range. Pick the lower bound to be

1/2 Exp[-A/b] where A is the lower truncation limit you desire for the 
Laplace distribution and pick the upper bound to be

1 - 1/2Exp[B/b] where B is the upper truncation limit.

the return x = F[U] where U is the uniform deviate selected between the 
two limits above

-- 
-
PGPKey fingerprint: 6DA1 E71F EDFC 7601 0201  9243 E02A C9FD EF09 EAE5
.
.
=================================================================
Instructions for joining and leaving this list, remarks about the
problem of INAPPROPRIATE MESSAGES, and archives are available at:
.                  http://jse.stat.ncsu.edu/                    .
=================================================================

Reply via email to