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()
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);
----
Get Answers For Free
Most questions answered within 1 hours.