how to include a 'probability' when coding.

3 ビュー (過去 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 Center および File ExchangeEnvironments についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by