how to include a 'probability' when coding.

3 Ansichten (letzte 30 Tage)
cgo
cgo am 22 Apr. 2021
Kommentiert: Jonas am 22 Apr. 2021
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 Kommentar
Jonas
Jonas am 22 Apr. 2021
you could generate a random number between 1 and 10 and add 1 if your random number is <=6

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Stephan
Stephan am 22 Apr. 2021
Bearbeitet: Stephan am 22 Apr. 2021
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

Weitere Antworten (0)

Kategorien

Mehr zu Environments finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by