R/discrete.bayes.R

discrete.bayes=
function (df, prior, y, ...) 
{
    param = as.numeric(names(prior))
    lk=function(j)
       prod(df(y,param[j],...))
    likelihood=sapply(1:length(param),lk)
    pred = sum(prior * likelihood)
    prob = prior * likelihood/pred
    obj = list(prob = prob, pred = pred)
    class(obj) <- "bayes"
    obj
}

Try the LearnBayes package in your browser

Any scripts or data that you put into this service are public.

LearnBayes documentation built on May 1, 2019, 7:03 p.m.