Question

how do you generate data for a y random variable in matlab?

If x has uniform distribution (0,1)

y has uniform distribution (a,b)

Then write a matlab code using rand() command to generate data from distribution of y

y = ? + ?x

a,b, rand()

Answer #1

If x has uniform distribution (0,1) and y has uniform distribution (a,b)

we know that

if x is a draw from uniform distribution (0,1) then

y= a+(b-a)*x is a draw from uniform distribution (a,b)

Using matlab, we can use rand() to generate a random number from uniform distribution (0,1)

hence

**ans:**

The following Matlab code generates y from uniform(1,10)

get this

Code in text format

---

%draw from uniform(0,1)

x=rand();

%set the values of a,b

a=1;

b=10;

%draw from uniform(a,b)

y=a+(b-a)*x;

%print y

fprintf('a draw from uniform(%g,%g) is %.4f\n',a,b,y);

----

USING MATLAB
(A) Use the rand command to generate “X” of size [10000 1] and
the command histogram to plot the probability distribution of “X”
along with axis labels and a title that includes the mean and
variance for “X”. (B) Use a while loop and the rand command to
generate “X1”, also of size [10000 1] but with each element of “X1”
being the mean of 2 “samples” generated using rand, i.e. a “sample
size” of 2 separate numbers...

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...

A uniform random variable on (0,1), X, has density function f(x)
= 1, 0 < x < 1. Let Y = X1 + X2 where X1 and X2 are
independent and identically distributed uniform random variables on
(0,1).
1) By considering the cumulant generating function of Y ,
determine the first three cumulants of Y .

USING MATLAB
Code for pseudo Random
Input N
M=0
For i=1 to N
X=rand#
Y=rand#
If X^2+ y^2 <= 1, then M=M+1
End the loop
Print M/N (This is the probability)
Print M/N (this is approximately = Py

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.

The random variables X and Y are independent.
X has a Uniform distribution on [0, 5], while Y
has an Exponential distribution with parameter λ = 2. Define W
= X + Y.
A. What is the expected value of
W?
B. What is the standard deviation of
W?
C. Determine the pdf of
W. For full credit, you need to write out
the integral(s) with the correct limits of integration. Do not
bother to calculate the integrals.

Show how to use Metropolis Algorithm to generate a random variable
with an approximate student’s t distribution with v degrees of
freedom, starting from N(0,1) random variables.
(Not using programming codes)

We are given a random number generator that generates a uniform
random variable X over the interval [0,1]. Suppose we ﬂip a fair
coin and if H occurs, we report X and if T occurs, we report 2X +
1. Let Y be the reported random variable.
(a) Derive the cdf and pdf of Y [15 points].
(b) Which one is more likely to occur: Y ∈ [0,1] or Y ∈ [1,2]?
Explain your answer [10 points].

X and Y are independent variables, with X having a uniform (0,1)
distribution and Y being an exponential random variable with a mean
of 1.
Given this information, find P(max{X,Y} > 1/2)

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 46 minutes ago

asked 48 minutes ago

asked 56 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago