how to include a 'probability' when coding.

I wanted to include the concept of 'probability' when coding. For example, giving me a reward of +1 only 60% of the time. How do in incorporate this '60 %' idea?

댓글 수: 1

Jonas
Jonas 2021년 4월 22일
you could generate a random number between 1 and 10 and add 1 if your random number is <=6

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

 채택된 답변

Stephan
Stephan 2021년 4월 22일
편집: Stephan 2021년 4월 22일

2 개 추천

Use this every time you want to reward by random
reward = rand(1) <= 0.6
reward = logical
1
reward = rand(1) <= 0.6
reward = logical
1
reward = rand(1) <= 0.6
reward = logical
0
reward = rand(1) <= 0.6
reward = logical
0
reward = rand(1) <= 0.6
reward = logical
1

추가 답변 (0개)

카테고리

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

태그

질문:

cgo
2021년 4월 22일

댓글:

2021년 4월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by