Question

How to do the following in R:

Write a function to generate a random sample of size n from the
**Gamma(α,1)** distribution by the
acceptance-rejection method. Generate a random sample of size 1000
from the Gamma(3,1) distribution. (Hint: you may **use g(x) ∼
Exp(λ = 1/α)** as your proposal distribution, where λ is the
rate parameter. Figure out the appropriate constant c).

Answer #1

How to do the following in R:
Write a function to generate a random sample of size n from the
Gamma(α,1) distribution by the acceptance-rejection method.
Generate a random sample of size 1000 from the Gamma(3,1)
distribution. (Hint: you may use g(x) ∼ Exp(λ = 1/α) as your
proposal distribution, where λ is the rate parameter. Figure out
the appropriate constant c).

How to do the following in R:
Write a function to generate a random sample of size n from the
Beta(a,b) distribution by the acceptance-rejection method. Generate
a random sample of size 1000 from the Beta(3,2) distribution.

Use R to code a function to generate a random sample of size n
from the Beta(a, b) distribution by the acceptance-rejection
method.
(1) Generate a random sample of size 3000 from the Beta(4,3)
distribution.
(2) Graph the histogram of the sample with the theoretical
Beta(4,3) density superimposed.
Answer the above questions by showing the R codes and
results.

Using MATLAB, not R codes, I repeat, please, not in R, just
MATLAB codes, write the complete code for:
1. Assume Y is an exponential random variable with rate
parameter λ=2. (1) Generate 1000 samples from this exponential
distribution using inverse transform method (2) Compare the
histogram of your samples with the true density of Y.

Use R.
Generate a random sample with n=15 random observations from an
exponential distribution with mean=1.
Calculate the sample median, which is an estimator of the
population median.
Use bootstrap (nonparametric, with B=1000) methods to estimate
the variance of the estimator for the population median.
use the Monte Carlo method, e.g. generate 1000 samples of size
15 to estimate the true variance of the median estimator. Compare
and comment on your results.

This problem is to be done in R.
Maria claims that she has drawn a random sample of size 30 from
an Exp(10) distribution (λ = 10, rate = 0.1). The mean of her
sample is 12.
(a) What is the expected value of a sample mean?
(b) Run a simulation by drawing 1000 random samples, each of
size 30, from an Exp(10) distribution, and compute the means for
each sample. What proportion of the sample means are ≥ 12?...

USING MATLAB:
1. Assume Y is an exponential random variable with rate
parameter λ=2.
(1) Generate 1000 samples from this exponential distribution
using inverse transform method
(2) Compare the histogram of your samples with the true density
of Y.

Write an R code that does the following:
(a) Generate n samples x from a random variable X that has a
uniform density on [0,3]. Now generate samples of Y using the
equation: y = α/(x + β). For starters, set α = 1, β = 1
The R code:
x=runif(n=1000, min = 0, max = 3)
x
y=1/x+1
y
Please answer the following:
b) Use plot(x,y) to check if you got the right curve.
c) How does the correlation...

1. Write an R function named “abs.shift” to calculate the
function value |x|-1 of a real number x, where |x| is the absolute
value of x. Do not use the abs() function.
2. Which of the following method is for simulating discrete
random variables?
A) The Rejection method with uniform envelope.
B) The Inverse CDF method.
C) The rnorm() function.
D) The sample() function in R.

(1) Use ‘sample’ function to generate a vector of 100 random
numbers that follows a multinomial distribution with probability
(0.1, 0.15, 0.3, 0.45).
(2) Without using the ‘sample’ function, generate a vector of
100 random numbers that follows a multinomial distribution with
probability (0.1, 0.15, 0.3, 0.45).
(3) Calculate the probability for 2.5 < X < 9 in a Poisson
distribution with the mean 6. （using R）

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 17 minutes ago

asked 21 minutes ago

asked 37 minutes ago

asked 44 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago