Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write in python.In this exercise, we will generate ( pseudo - ) random numbers using the inversion and accept - reject method. In order

Please write in python.In this exercise, we will generate (pseudo-)random numbers using the inversion and accept-reject method. In order to generate the random numbers you are
only allowed draw from the Uniform distribution and use
from random inport uniform
from scipy. special inport binon
from numpy import sqrt, pi, exp, tan, cunsum
from scipy.stats import probplot
import pandas as pd
inport natplotilb.pyplot as plt
Inversion method: Let F be a distribution function from which we want to draw. Define the quantile function F-1(u)=inf{x:F(x)u,0u1}. Then, if
UUnif[0,1],F-1(U) has distribution function F
Accept-reject: Let f be a density function from which we want to draw and there exists a density g from which we can draw (e.g., via the inversion method)
and for which there exists a constant c such that f(x)cg(x) for all x. The following algonithm generates a random variable x with density function f.
Generate a random variable x from density g
Generate a random variable UUnif{0,1](independent from x)
If Ucg(x)f(x), return x, otherwise repeat 1.-3.
The number of iterations needed to successfully generate x is itseif a random variable, which is geometrically distributed with the success (acceptance)
probabinty p=P(Ucg(x)f(x)). Hence, the expected number of iterations is 1p. Some calculations show that p=1c.
(b) Generate 10000 samples from the standard normal distribution using the accept-reject method with candidate density g(x)=(x(1+x2))-1 with
distribution funciton G(x)=tan-1x from the standard Cauchy distribution. To this end, (i) determine (mathematically or via simulation) the value of c1
closest to one so that f(x)cg(x) for all x.(ii) Obtain 10000 standard normal random variables using the accept-reject method, generating Cauchy
distributed random variables using inversion method. (iii) Compare estimated and theoretical acceptance probabilities. (iv) Generate a QQ-plot of the
generated sample.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions

Question

7. Identify four antecedents that influence intercultural contact.

Answered: 1 week ago

Question

5. Describe the relationship between history and identity.

Answered: 1 week ago