Background
In Julia programming we have a Rand function which sintaxis is :
rand([rng=GLOBAL_RNG], [S], [dims...])
which pick a random element or array of random elements from the set of values specified by S and gives an array of dimension of the third arg.
Question
I want to apply the same logic to make a simulation for an assurance policy problems:
m = 60000
n = len(policy.AGE)
k=1/10
@time begin
Death = zeros(Bool, m, n)
Accident = rand(Bernoulli(k), m, n)
for j ∈ 1:n
Death[:, j] = rand(Bernoulli(q[policy.AGE[j]]), m)
end
for i ∈ 1:m
S[i] = sum(policy.INSAMOUNT .* Death[i, :] .* (1 .+ Accident[i, :]))
end
end
Which is Julia Code, but when taking this to python i don't find the correct form of rand(Bernoulli(k), m, n)
I know to simulate a Bernoulli is just bernoulli.rvs(k,n) but the part that set of values specified by S and gives an array of dimension of the third arg.