construct_CDF_sampler_t Function

private pure function construct_CDF_sampler_t(w) result(res)

Construct a CDF sampler from given weights.

The weights do not have to be normalized. If all weights are zero, or the array is empty, the sampler will return the (non-existent) index 0 with probability 1.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: w(:)

Return Value type(CDF_Sampler_t)


Contents