How could I generate 10000 samples of a random variable using rand?

Hello,
I am attempting to generate 10000 independent realizations of the following random variable (16*y)/(x+23)^(y+1) for x>=0.
This is what I have done so far:
X= rand(1,10000);
Y=rand(1,10000);
k= (16*Y)/(X+23).^(Y+1)
I get a 1X10000 double for X and Y but I only get one value for k.
How do I go about getting 10000 values for k?
thanks

 Accepted Answer

Use element-wise division ./
X= rand(1,10000);
Y=rand(1,10000);
k=(16*Y)./(X+23).^(Y+1);
size(k)
ans = 1×2
1 10000

More Answers (0)

Categories

Find more on Random Number Generation in Help Center and File Exchange

Products

Release

R2021a

Asked:

on 30 Apr 2022

Commented:

on 1 May 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!