how to include a 'probability' when coding.

2 次查看(过去 30 天)
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