How to generate random numbers non-uniformly

13 次查看(过去 30 天)
I want to generate 50 random numbers between 0 and 5, but I need a higher density of numbers within a smaller range. So, for example, 30 of the 50 numbers generated are between 1.25 and 1.75, while the remaining 20 are uniformly generated between 0 and 1.25 and betweeen 1.75 and 5. I tried using randscr,normrnd, and some other functions that use mean and standard deviation, but I could not fix the ranges. I also need to alter the probability distribution of a function, and use that function, I cannot generate using: 0+(1.25-0)*rand(5,1) and 1.25+(1.75-1.25)*rand(30,1) and 1.75+(5-1.75)*rand(15,1)
Thank you

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by