Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 import uniform
from scipy,special import binom
from numpy import sqrt, pi, exp, tan, cunsum
from scipy.stats inport probplot
import pandas as pd
Import natplotlib.pyplot as plt
Inversion method: Let F be a distribution function from which we want to draw. Define the quantive 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 algorithm 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 itself 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)=((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

Strategic Database Technology Management For The Year 2000

Authors: Alan Simon

1st Edition

155860264X, 978-1558602649

Students also viewed these Databases questions

Question

What is the relationship between humans?

Answered: 1 week ago

Question

What is the orientation toward time?

Answered: 1 week ago