generate 0 and 1
조회 수: 21 (최근 30일)
이전 댓글 표시
how do I generate a binary sequence with certain probabilities?
for instance, I want 0 to have 0.6 and 1 to have 0.4 probability
It would be very helpful if you give me the whole code to this
댓글 수: 0
채택된 답변
John D'Errico
2020년 3월 28일
rand() < 0.6
If you want a random binary sequence of length n, then this is sufficient:
rand(1,n) < 0.6
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
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!