Computes probabilities based on stick breaking construction.
stick_breaking(z, log = 0)
The stick breaking function produces a vector of probabilities that add up to one,
based on a series of individual probabilities in
z, which define the breaking
points relative to the remaining stick length. The first element of
the first probability based on breaking a proportion
z from a stick of length one.
The second element of
z determines the second probability based on breaking a
z from the remaining stick (of length
1-z), and so forth.
Each element of
z should be in
The returned vector has length equal to the length of
z plus 1.
z[k] is equal to 1 for any
k, then the returned vector has length smaller than
If one of the components is smaller than 0 or greater than 1,
NaNs are returned.
Sethuraman, J. (1994). A constructive definition of Dirichlet priors. Statistica Sinica, 639-650.
z <- rbeta(5, 1, 1) stick_breaking(z) ## Not run: cstick_breaking <- compileNimble(stick_breaking) cstick_breaking(z) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.