Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2 In this exercise, we will proceed in steps to perform rejection sampling of a beta random variable using a triangular random variable as

image text in transcribed
Problem 2 In this exercise, we will proceed in steps to perform rejection sampling of a beta random variable using a triangular random variable as candidate. 2.1 Plot an overlay of a beta PDF and a triangular PDF with the following parameters: . For the beta PDF, a=2, b=2, loc=0, scale=1. . For the triangular PDF, c=0.50, loc=0, scale=1. In [13] : # Import module for plotting. import matplotlib . pyplot as plt # Import respective beta and triang modules from scipy from scipy . stats import beta, triang f, ax = plt . subplots(1, 1) # label constant a = 2 b = 2 C = .50 xBeta = np. linspace (beta . ppf (0.01, a, b), beta. ppf( . 99, a,b), 10000) xTriangle = np. linspace (triang . ppf (0.01,c), triang. ppf( .99,c), 10000) betaPDF = beta. pdf (xBeta, a, b) trianglePDF = triang. pdf (xTriangle,c) ax . plot (xBeta, betaPDF, label = 'beta pdf' ) ax. plot (xTriangle, trianglePDF, label = 'triangle pdf' ) pit . legend ( ) Out [13]: 2.00 beta pdf triangle pdf 175 150 125 100 0.75 0.50 0.25 0.2 0. 4 0.6 0.8 2.2 We will perform 10,000 trials of the rejection sampling procedure. Simulate and store 10,000 random variables distributed as Uniform[0, 1] using random state 436. Simulate and store 10,000 triangular random variables from the specified triangular distribution using random state 636. In [ ]: 2.3 Let f be the beta PDF and g the triangular PDF. Using 1.50 as an estimate of sup f/g, generate samples from the beta distribution by rejection sampling. Store your samples. Print the number of samples you obtain. In [ ] : 2.4 Plot a density histogram of your samples overlaid with the beta and triangular PDFs. Use 100 bins. In [ ]

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

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions