PMF.get_var {bayesRecon}R Documentation

Get the variance of the distribution from a PMF object

Description

Returns the variance from the PMF specified by pmf.

Usage

PMF.get_var(pmf)

Arguments

pmf

the PMF object.

Value

A numerical value for variance.

See Also

PMF.get_mean(), PMF.get_quantile(), 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 variance corresponds to n*p*(1-p)
true_var <- n*p*(1-p)
var_from_PMF <- PMF.get_var(pmf=pmf_binomial)
cat("True variance:", true_var, "\nVariance from PMF:", var_from_PMF)


[Package bayesRecon version 0.3.0 Index]