Statistics and combinatorics
"Statistics"
data = [2, 4, 4, 4, 5, 5, 7, 9] @ hidden
folder "Summaries" { "Each of these reduces the list to a single number." n = length(data) @ hidden tot = total(data) @ hidden avg = mean(data) @ hidden mid = median(data) @ hidden low = min(data) @ hidden high = max(data) @ hidden}
folder "Spread" { "Sample and population standard deviation, variance, mean absolute deviation." s = stdev(data) @ hidden sp = stdevp(data) @ hidden v = var(data) @ hidden vp = varp(data) @ hidden dev = mad(data) @ hidden}
folder "Where a value falls" { "The quantile a fraction of the way through the list, and a quartile." q9 = quantile(data, 0.9) @ hidden q1 = quartile(data, 1) @ hidden "How far the mean is from 4, in standard errors." t = tscore(data, 4) @ hidden "Shown as the fraction it is." third = 1 / 3 @ displayEvaluationAsFraction}
folder "Two lists" { "A second list, paired with the first." other = [1, 3, 2, 5, 4, 6, 8, 9] @ hidden r = corr(data, other) @ hidden rho = spearman(data, other) @ hidden c = cov(data, other) @ hidden cp = covp(data, other) @ hidden}
folder "Distributions" { "A distribution is drawn as its density, and read with its members." N = normaldist(avg, s) @ color: ORANGE, hidden y = N.pdf(x) @ color: ORANGE, lineWidth: 3 below = N.cdf(5) @ hidden within = N.cdf(avg - s, avg + s) @ hidden "Shaded between two bounds, a distribution shows the probability of landing there." normaldist(0, 1) @ color: PURPLE, cdf: -1..1 B = binomialdist(8, 0.5) @ hidden heads = B.pdf(4) @ hidden}
folder "Testing" { "Is the mean of data different from 4? A t-test says how surprising the sample is if it were." T = ttest(data).null(4) @ hidden tp = T.pright @ hidden "A 95% confidence interval for the mean." ci_low = ttest(data).conf(0.95).lower @ hidden ci_high = ttest(data).conf(0.95).upper @ hidden}
folder "Seeing the data" { "The samples along a line." (data, 0) @ color: BLUE, pointSize: 14 "The mean, and one standard deviation either side." x = avg @ color: RED, lineWidth: 3 x = avg - s @ color: RED, lineStyle: DASHED, lineOpacity: 0.6 x = avg + s @ color: RED, lineStyle: DASHED, lineOpacity: 0.6 "A bell curve over the same centre and spread." y = exp(-0.5 * ((x - avg) / s) ^ 2) @ color: GREEN, lineWidth: 3}
folder "Charts" { "A histogram of the data in bins of width 2, a dot plot over it, and a box plot above both." histogram(data, 2) @ color: BLUE, binAlignment: left dotplot(data) @ color: PURPLE boxplot(data) @ color: GREEN, axisOffset: 8, breadth: 1.5 "The same numbers, as a row of summary statistics." stats(data)}
folder "Combinatorics" { "Choose, permute, factorial." ways = nCr(5, 2) @ hidden orders = nPr(5, 2) @ hidden fact = factorial(5) @ hidden "Row 6 of Pascal's triangle, as points." K = [0, 1, 2, 3, 4, 5, 6] @ hidden (K, nCr(6, K)) @ color: PURPLE, pointSize: 14}Open in playground →