tsb: generate stick-breaking prior (truncated) from a vector of...

Description Usage Arguments Value Examples

View source: R/utils.R

Description

generate stick-breaking prior (truncated) from a vector of random probabilities

Usage

1
tsb(u)

Arguments

u

a vector of probabilities, with the last element 1.

Value

a vector of the same length as u; sum to 1.

Examples

1
2
3
4
5
6
7
8
9
graphics::par(mfrow=c(3,3),oma=c(0,1,5,0),
   mar=c(1,2,1,1))
for (iter in 1:9){
 u   <- c(rbeta(9,1,0.8),1)
 res <- tsb(u)
 barplot(res,ylim=c(0,1),main=paste0("Random Sample #", iter),ylab="Probability")
}
graphics::mtext("Truncated Stick-Breaking Dist. (10 segments)",3,
     outer=TRUE,cex=1.5,line=1.5)

oslerinhealth/baker documentation built on May 22, 2021, 12:05 p.m.