` Hi all`

is the code below represent inverse cdf method?

y is pdf of any distribution

cdf_y = cumsum(y);

sum_y = sum(y);

for j = 1:N

randx = sum_y*rand();

i = 1;

while cdf_y(i) < randx

i = i + 1;

end

f(j) = x(i); end

please give me explain

Skip to content# MATLAB: What called this method of generation random sample

###### Related Question

acceptance rejectioncumsuminverse cdfrandom number generatorstatistics

` Hi all`

is the code below represent inverse cdf method?

y is pdf of any distribution

cdf_y = cumsum(y);

sum_y = sum(y);

for j = 1:N

randx = sum_y*rand();

i = 1;

while cdf_y(i) < randx

i = i + 1;

end

f(j) = x(i); end

please give me explain

- If y(i) contain 5 values such as 1,2,3,4,5. Then i want to sum all the values with a single command but i can’t solve this problem. Please help me out, the code is given below.
- How to plot a probability distribution object
- Transforming uniform variables to normal variables
- How to plot a summation vs the x
- Generate random numbers given distribution/histogram

## Best Answer