PMF.get_quantile: Get quantile from a PMF object

View source: R/PMF.R

PMF.get_quantileR Documentation

Get quantile from a PMF object

Description

Returns the p quantile from the PMF specified by pmf.

Usage

PMF.get_quantile(pmf, p)

Arguments

pmf

the PMF object.

p

the probability of the required quantile.

Value

A numeric value for the quantile.

See Also

PMF.get_mean(), PMF.get_var(), PMF.sample(), PMF.summary()

Examples

library(bayesRecon)

# Let's build the pmf of a Binomial distribution with parameters n and p
n <- 10
p <- 0.6 
pmf_binomial <- apply(matrix(seq(0,10)),MARGIN=1,FUN=function(x) dbinom(x,size=n,prob=p))

# The true median is ceiling(n*p)
quant_50 <- PMF.get_quantile(pmf=pmf_binomial,p=0.5)
cat("True median:", ceiling(n*p), "\nMedian from PMF:", quant_50)



bayesRecon documentation built on Sept. 11, 2024, 9:08 p.m.