Cpp function: Sample from Categorical distribution

rSample(Prob)

Arguments

Prob

A matrix with n row and p column. Each column represent a class. The ith row is the probability distribution of ith sample.

Value

A matrix of n row and p column. The ith row draw one sample from categorical distribution with probability in the ith row in Prob.