Generation of a pair of random numbers satisfying a constraint
1 次查看(过去 30 天)
显示 更早的评论
Hi, guys, I want to generate s sequence of two random numbers r1 and r2 satisfying the condition 0<r1<r2<1. How to do it using MATLAB. Your response is highly appreciated. Thank you!
Shah
1 个评论
Johannes Hougaard
2021-7-6
The easy way...but that also yields r1 < .5 and r2 > .5 is:
N = 99; % Or any other number but 99 is my go-to number of observations
r1 = rand(N,1)*.5;
r2 = randn(N,1)*.5 + .5;
采纳的回答
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Random Number Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!