How to generate random numbers non-uniformly

조회 수: 15 (최근 30일)
Rakan Zabian
Rakan Zabian 2020년 2월 25일
댓글: Rakan Zabian 2020년 2월 25일
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
  댓글 수: 2
dpb
dpb 2020년 2월 25일
Rakan Zabian
Rakan Zabian 2020년 2월 25일
Great, got it. Thanks!

댓글을 달려면 로그인하십시오.

답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by