Results 1 to 4 of 4

Math Help - Sampling - inverse transform & rejection method

  1. #1
    Newbie
    Joined
    Aug 2009
    Posts
    2

    Sampling - inverse transform & rejection method

    Hello,

    I was wondering if someone could help me with a question given in the tutorial at uni.

    The probability density function is

    f(x) = (1/2)(x+1) 1 < x <= 2
    = (1/2) 2 < x <= 3
    = 0 elsewhere

    Now to generate values of the random variable, we have to use the inverse transform method and the rejection method.

    If anyone, could show me how to solve this equations or equations like the one above, that would be appreciated.

    Thanks in advance
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Newbie
    Joined
    Aug 2009
    Posts
    9
    (*) \int_1^x f(t) dt = \frac{1}{4}(x+1)^2 - 1
    (**)  \int_1^2 f(t) dt + \int_2^x f(t) dt  = \frac{1}{2}x - \frac{1}{4}

    Note that (*) is 1-1 over [1,2]

    Now, the inverses are:

    (*)  F^{-1}(u) = 2\sqrt{u+1} - 1
    (**)  F^{-1}(u) =  2\left(u+\frac{1}{4}\right)

    R code

    n <- 1000
    u <- runif(n)
    x1 <- 2*sqrt(u+1) - 1
    x2 <- 2*(u+1/4)
    par(mfrow=c(1,2))
    hist(x1)
    hist(x2)
    par(mfrow=c(1,1))


    Now, for the rejection method, note that for g uniform [0,1], we have

    \frac{f(x)}{g(x)} \leq \frac{3}{2} for x \in [1,2]. This gives you c=\frac{3}{2}

    So, a uniformly generated x will be accepted if \frac{1}{3} (x+1) > u

    This should get you started, I hope...

    P.S. This is only my 2nd post, so please don't bash me too much...
    Last edited by temp; August 15th 2009 at 06:52 PM.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Aug 2009
    Posts
    2
    so I make this clear,

    If I was to do the inverse method on the following equation:

    f(x) = (2/3)(x-1) 1 < x <= 2 (equation 1)
    = (2/3) 2 < x <= 3 (equation 2)
    = 0 elsewhere

    I'm also not sure about my c values, can you double check???

    Equation 1

    By integration it would be
    (1/3)(x-1)^2 + 1

    The inverse is
    sqrt(3)sqrt(u-1) + 1

    Equation 2

    By integration it would be
    (2/3)x + (1/3)
    The inverse is
    (3/2)(x-(1/3))

    Also, don't understand the rejection method there, is that just the first equation is f(x) and the second equation is g(x).

    Thanks again in advance.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Aug 2009
    Posts
    9
    CDF:

    (*) \int_1^x f(t) dt = \frac{1}{3}(x-1)^2
    (**)  \int_1^2 f(t) dt + \int_2^x f(t) dt  = \frac{2}{3}x - 1

    Inverses:

    (*)  F^{-1}(u) = \sqrt{3u} + 1
    (**)  F^{-1}(u) =  \frac{3}{2}\left(u+1\right)

    I hope it helps

    For more on rejection sampling, see

    Statistical Computing with R by Maria L. Rizzo

    Also, here's some helpful R code to go with her book:
    http://personal.bgsu.edu/~mrizzo/SCR/SCRch3.R

    Also, see the post by Moo:
    http://www.mathhelpforum.com/math-he...on-method.html
    Last edited by temp; August 15th 2009 at 07:35 PM.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Rejection Sampling
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: October 20th 2011, 06:35 AM
  2. Sampling and the Z transform
    Posted in the Advanced Applied Math Forum
    Replies: 2
    Last Post: August 17th 2011, 09:00 PM
  3. Inverse Z transform by partial fraction method
    Posted in the Advanced Applied Math Forum
    Replies: 1
    Last Post: July 3rd 2010, 05:50 AM
  4. Inverse Z transform by inversion integral method
    Posted in the Advanced Applied Math Forum
    Replies: 3
    Last Post: July 3rd 2010, 05:47 AM
  5. Simulating - Acceptance/Rejection method
    Posted in the Advanced Statistics Forum
    Replies: 7
    Last Post: August 18th 2009, 10:25 PM

Search Tags


/mathhelpforum @mathhelpforum