dnCategorical
- The Categorical Distribution
p : | Simplex (pass by const reference) |
The probability for each category. |
# Define a stochastic variable x that is drawn from
# a categorical distribution with 4 categories, each
# category having the same probability, then examine
# the value of x.
x ~ dnCat( simplex(1,1,1,1) )
x
# Draw 10 values from the distribution and place them
# in a vector a, then examine a.
for ( i in 1:10 ) {
a[i] <- x
x.redraw()
}
a
# Use x in defining a deterministic variable y taking
# on values from a mixture of RealPos values representing
# rates from a discretized scaled gamma distribution
# with four categories.
shape ~ dnExp( 10.0 )
rates := fnDiscretizeGamma( shape, shape, 4 )
y := rates[x]