Thread: Simulation - Composition method

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    8

    Simulation - Composition method

    Hi all, this question doesn't really have to do with C, but it is related to simulation, and without solving this first, I can't do the random variate generator.

    I'm supposed to generate random variates for p(x) ~ pi - x + x^2 + sin(x), for 0 <= x <= pi.

    I got the normalization factor as 6 / (12 + 3*pi^2 + 2*pi^3), which gives me my f(x) as

    f(x) = [6 / (12 + 3*pi^2 + 2*pi^3)] * (pi - x + x^2 + sin(x)).

    I then run into problems decomposing the f(x). I decomposed it into the following equation:

    f(x) = 6*pi / a - (3*pi^2 / a) * f_1(x) + (2*pi^3 / a) * f_2(x) + (12 / a) * f_3(x)
    where a = (12 + 3*pi^2 + 2*pi^3), f_1(x) = 2x/pi^2, f_2(x) = 3x^2 / pi^3, f_3(x) = ½ sinx.

    I reasoned that f_1 is proportional to x, f_2 to x^2, and f_3 to sin(x). I then normalized f_1, f_2 and f_3, obtaining the respective individual distributions.

    However, I'm confused by the presence of the constant term 6*pi / a and the negative sign in front of f_1. What should I do with them?

    I'm really confused with the whole composition method, and I would greatly appreciate it if someone could point me to a website that gives a clear explanation of how to decompose the distributions.

    Thank you.

    Regards,
    Rayne

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > Hi all, this question doesn't really have to do with C
    Which is why it is now on the Tech board.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. on method pointers and inheritance
    By BrownB in forum C++ Programming
    Replies: 2
    Last Post: 03-02-2009, 07:50 PM
  2. fork, execv, spawn, or something else?
    By DavidP in forum C++ Programming
    Replies: 8
    Last Post: 01-26-2009, 04:25 PM
  3. Best communication method to thousand childs?
    By Ironic in forum C Programming
    Replies: 8
    Last Post: 11-08-2008, 12:30 AM
  4. C# method
    By siten0308 in forum C# Programming
    Replies: 6
    Last Post: 07-15-2008, 07:01 AM
  5. Simulation - M(RT)^2 method
    By wu_weidong in forum C Programming
    Replies: 4
    Last Post: 03-14-2005, 01:47 PM