Results 1 to 4 of 4

Math Help - Classical Monte Carlo

  1. #1
    Member
    Joined
    Oct 2008
    Posts
    206

    Classical Monte Carlo

    I am interested to find out:

    \int ((\frac{2(cos(\pi x/2)}{3(1-x^2)}-\frac{2}{\pi})^2. 3(1-x^2)/2.dx

    I want use \frac{1}{m}\displaystyle\sum_{i=1}^{m}(\frac{2(cos  (\pi x^{(i)}/2)}{3(1-x^{(i)}^2)})^2 where x^{(i)} is drawn from 3(1-x^2)/2 (a density defined from 0<x<1).

    The question is simple. How can I draw a random sample of let say 10000 from the density f(x)= 3(1-x^2)/2 ?

    What I did is to generate 10000 random uniform variable and subst into the equation.
    For example:

    x=runif(10000)
    g=3(1-x^2)/2

    but the answer is still wrong after computation
    Meanwhile finding this inverse is hard
    Last edited by noob mathematician; November 1st 2010 at 09:09 AM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by noob mathematician View Post
    I am interested to find out:

    \int ((\frac{2(cos(\pi x/2)}{3(1-x^2)}-\frac{2}{\pi})^2. 3(1-x^2)/2.dx

    I want use \frac{1}{m}\displaystyle\sum_{i=1}^{m}(\frac{2(cos  (\pi x^{(i)}/2)}{3(1-x^{(i)}^2)})^2 where x^{(i)} is drawn from 3(1-x^2)/2 (a density defined from 0<x<1).

    The question is simple. How can I draw a random sample of let say 10000 from the density f(x)= 3(1-x^2)/2 ?

    What I did is to generate 10000 random uniform variable and subst into the equation.
    For example:

    x=runif(10000)
    g=3(1-x^2)/2

    but the answer is still wrong after computation
    Meanwhile finding this inverse is hard
    Make sure you know what the support of the f(x) is first, and check that it is a pdf, then look at:

    Inverse transform sampling!

    It might be easier to use rejection sampling though for this pdf


    CB
    Last edited by CaptainBlack; November 1st 2010 at 11:30 PM.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by noob mathematician View Post
    I am interested to find out:

    \int ((\frac{2(cos(\pi x/2)}{3(1-x^2)}-\frac{2}{\pi})^2. 3(1-x^2)/2.dx

    I want use \frac{1}{m}\displaystyle\sum_{i=1}^{m}(\frac{2(cos  (\pi x^{(i)}/2)}{3(1-x^{(i)}^2)})^2 where x^{(i)} is drawn from 3(1-x^2)/2 (a density defined from 0<x<1).

    The question is simple. How can I draw a random sample of let say 10000 from the density f(x)= 3(1-x^2)/2 ?

    What I did is to generate 10000 random uniform variable and subst into the equation.
    For example:

    x=runif(10000)
    g=3(1-x^2)/2

    but the answer is still wrong after computation
    Meanwhile finding this inverse is hard
    Would it not be simpler to use:

    \frac{1}{m}\displaystyle\sum_{i=1}^{m}\left\{ \left(\frac{2(cos(\pi x^{(i)}/2)}{3(1-(x^{(i)})^2)}-\frac{2}{\pi}\right)^2 \times \left[3(1-(x^{(i)})^2\right)/2]\right\}

    with $$ x^{(i)} sampled from U(0,1) ?

    CB
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Member
    Joined
    Oct 2008
    Posts
    206
    Quote Originally Posted by CaptainBlack View Post
    Would it not be simpler to use:

    \frac{1}{m}\displaystyle\sum_{i=1}^{m}\left\{ \left(\frac{2(cos(\pi x^{(i)}/2)}{3(1-(x^{(i)})^2)}-\frac{2}{\pi}\right)^2 \times \left[3(1-(x^{(i)})^2\right)/2]\right\}

    with $$ x^{(i)} sampled from U(0,1) ?

    CB
    Amazing! I should have thought of that. Thanks again
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Monte Carlo Simulations
    Posted in the Advanced Statistics Forum
    Replies: 0
    Last Post: February 20th 2011, 06:30 PM
  2. Monte Carlo's Simulation
    Posted in the Math Software Forum
    Replies: 1
    Last Post: May 19th 2010, 01:19 AM
  3. Monte Carlo method
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: April 14th 2010, 10:57 AM
  4. Monte Carlo Estimate
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: February 23rd 2010, 11:40 PM
  5. Monte Carlo Simulation
    Posted in the Advanced Statistics Forum
    Replies: 3
    Last Post: March 10th 2009, 07:30 AM

/mathhelpforum @mathhelpforum