Answered step by step
Verified Expert Solution
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 pseudorandom numbers using the inversion and acceptreject 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 be a distribution function from which we want to draw. Define the quantive function inf: Then, if
has distribution function
Acceptreject: Let be a density function from which we want to draw and there exists a density from which we can draw eg via the inversion method
and for which there exists a constant such that for all The following algorithm generates a random variable with density function
Generate a random variable from density
Generate a random variable independent from
If Ucg return otherwise repeat
The number of iterations needed to successfully generate is itself a random variable, which is geometrically distributed with the success acceptance
probabinty Hence, the expected number of iterations is Some calculations show that
b Generate samples from the standard normal distribution using the acceptreject method with candidate density with
distribution funciton from the standard Cauchy distribution. To this end, i determine mathematically or via simulation the value of
closest to one so that for all ii Obtain standard normal random variables using the acceptreject method, generating Cauchy
distributed random variables using inversion method. iii Compare estimated and theoretical acceptance probabilities. iv Generate a QQplot of the
generated sample.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started