# NOT RUN {
f <- c(A = 0.1, B = 0.2, C = 0.7)
v <- variance_number_of_distinct_alleles(3, f)
# now compute variance by hand from the full pr. dist of N
p <- pr_number_of_distinct_alleles(3, f)
n <- as.numeric(names(p))
p_n <- as.vector(p)
# compute expected value
ev <- expected_number_of_distinct_alleles(3, f)
# and variance by hand
v2 <- sum(p_n * (n - ev)^2)
stopifnot(all.equal(v,v2))
# }
Run the code above in your browser using DataLab