I current have a code like this in MATLAB:
bias = 2; AD = randsample(100,1,1,linspace(1,bias,100));
This makes it 2 times more likely for me to get a value of AD = 100 than to get a value of AD = 1. However, AD can only be between 1 and 10. I want it to be possible that AD = 0, in other words AD be between 0 and 10. How can I do this?
Thank you

댓글 수: 2

Adam
Adam 2016년 3월 7일
Don't you mean AD can be between 1 and 100, but you want it to be between 0 and 100?
Kyle Miller
Kyle Miller 2016년 3월 7일
Yes, this is what I mean. Sorry about that typo.

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

 채택된 답변

Adam
Adam 2016년 3월 7일

0 개 추천

bias = 2; AD = randsample(101,1,1,[1 linspace(1,bias,100)]) - 1;
would seem to achieve that though it depends what kind of bias you want for 0. Here it is equal to the bias for 1

댓글 수: 1

Kyle Miller
Kyle Miller 2016년 3월 7일
That is almost perfect! This should let me do what I want to do. The idea is that 100 would be "bias" times more likely to be produced than 0 and your suggestion captures this. The "in between" 0 and 100 is not quite the distribution I exactly want, but it is close enough.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Random Number Generation에 대해 자세히 알아보기

질문:

2016년 3월 7일

댓글:

2016년 3월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by