Last answered:

16 Jan 2022

Posted on:

20 May 2021

0

choice method probability don't have clear explanation

array_RG = gen(pcg(seed=365))
array_RG.choice([1,2,3,9,3,6], p=[0.1,0.1,0.1,0.1,0.1,0.5], size=(5,5))



what is the use of p here, can you explain why values are displayed so and so

Output

array([[6, 6, 6, 3, 6],
       [1, 6, 2, 6, 3],
       [6, 3, 1, 6, 9],
       [3, 3, 3, 6, 6],
       [6, 1, 6, 6, 2]])
2 answers ( 0 marked as helpful)
Posted on:

30 Nov 2021

1

p stands for probability. If not specified, all the probability are equal. "p=[0.1,0.1,0.1,0.1,0.1,0.5]" is where you *manually* set the probability to how you like. In the example you provided:

array_RG.choice([1,2,3,9,3,6], p=[0.1,0.1,0.1,0.1,0.1,0.5], size=(5,5))

The probability for 1 showing up is approximately 0.1, and the probability for 6 showing up is approximately 0.5.

Posted on:

16 Jan 2022

0

P specifies the number of times each sequence value will appear in the outcome.

Submit an answer