Skip to contents

Returns the mean from the PMF specified by pmf.

Usage

PMF.get_mean(pmf)

Arguments

pmf

the PMF object.

Value

A numerical value for mean of the distribution.

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 mean corresponds to n*p
true_mean <- n*p
mean_from_PMF <- PMF.get_mean(pmf=pmf_binomial)
cat("True mean:", true_mean, "\nMean from PMF:", mean_from_PMF)
#> True mean: 6 
#> Mean from PMF: 6