inst/snippet/mean-coins01.R

vals <- 0:4
probs <- c(1, 4, 6, 4, 1) / 16     # providing probabilities directly
sum(vals * probs)
sum(0:4 * dbinom(0:4, 4, 0.5))     # using the fact that X is binomial

Try the fastR2 package in your browser

Any scripts or data that you put into this service are public.

fastR2 documentation built on Nov. 9, 2023, 9:06 a.m.