PMF.get_mean: Get the mean of the distribution from a PMF object

View source: R/PMF.R

PMF.get_meanR Documentation

Get the mean of the distribution from a PMF object

Description

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.

See Also

PMF.get_var(), 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 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)


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