how to include a 'probability' when coding.

조회 수: 1 (최근 30일)
cgo
cgo 2021년 4월 22일
댓글: Jonas 2021년 4월 22일
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일
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개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by