I would like to repeat 0.1 five times as the total number of probabilities required equals to 9. Any suggestions? In R, it can be done by using rep
function. Any similar function in python?
import numpy as np
np.random.choice(np.arange(1, 4, 1/3), 3, p=[[0.1]*5, 0, 0.3, 0.2, 0])
#> TypeError: float() argument must be a string or a number, not 'list'
#>
#> The above exception was the direct cause of the following exception:
#>
#> Traceback (most recent call last):
#> File "F:\miniconda_pf\envs\tensor\lib\site-packages\reprexlite\code.py", line 69, in evaluate
#> result = eval(str(self).strip(), scope, scope)
#> File "<string>", line 1, in <module>
#> File "mtrand.pyx", line 918, in numpy.random.mtrand.RandomState.choice
#> ValueError: setting an array element with a sequence.