PMF.get_mean | R Documentation |
Returns the mean from the PMF specified by pmf
.
PMF.get_mean(pmf)
pmf |
the PMF object. |
A numerical value for mean of the distribution.
PMF.get_var()
, PMF.get_quantile()
, PMF.sample()
, PMF.summary()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.