Draw a random number through a probability distribution defined as an array

Torkel
Wed, 21 May 2025 09:36:47 +0000
General Usage

If I have an NxM matrix with decimal values (normalised so that the sum is 1):

prob_dens::Matrix{Float64.Float64}

is there a good way to randomly draw an index i,j with probability corresponding to the probability distribution at that index?

6 posts - 5 participants