how to include a 'probability' when coding.

2 visualizaciones (últimos 30 días)
cgo
cgo el 22 de Abr. de 2021
Comentada: Jonas el 22 de Abr. de 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 comentario
Jonas
Jonas el 22 de Abr. de 2021
you could generate a random number between 1 and 10 and add 1 if your random number is <=6

Iniciar sesión para comentar.

Respuesta aceptada

Stephan
Stephan el 22 de Abr. de 2021
Editada: Stephan el 22 de Abr. de 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

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by