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