Inference by simulation instead of formula

Today let's look at a test where the usual formula already works, and then build a way to run that same test, and others like it, with no formula at all.

A checkout redesign went out to twenty customers: ten saw the classic checkout and ten saw a new one, and the time each person took to finish, in seconds, was recorded for all twenty. The ten classic times run from 38 to 45 seconds. The ten new-flow times mostly sit lower, in the high twenties and low thirties, except for one customer whose checkout stalled at 95 seconds.

Here is what those twenty checkout times look like, split by flow.

The average checkout time, and what the t-test says about it

Start with the most familiar comparison there is: the average time for each group.

RInteractive R
# The checkout times for each flow, and the gap between their means classic <- c(38, 41, 44, 39, 42, 45, 40, 43, 41, 39) new_flow <- c(30, 32, 29, 31, 33, 30, 28, 31, 32, 95) checkout <- data.frame(flow = rep(c("Classic", "New"), each = 10), seconds = c(classic, new_flow)) mean(classic) mean(new_flow) mean(classic) - mean(new_flow) #> [1] 41.2 #> [1] 37.1 #> [1] 4.1

  

The new flow's average is 4.1 seconds faster. That looks promising, but a gap between two averages can show up even when nothing real changed, just from which ten customers happened to land in which group. The standard way to check that is a two-sample t-test.

RInteractive R
# A two-sample t-test on the same two groups t.test(classic, new_flow) #> #> Welch Two Sample t-test #> #> data: classic and new_flow #> t = 0.6316, df = 9.2288, p-value = 0.543 #> alternative hypothesis: true difference in means is not equal to 0 #> 95 percent confidence interval: #> -10.52938 18.72938 #> sample estimates: #> mean of x mean of y #> 41.2 37.1

  

The line that matters is p-value = 0.543. That p-value comes from a formula: it assumes the sampling distribution of a mean difference follows a known shape, the t-distribution, and reads off how far 4.1 seconds sits inside that shape. A p-value this large, far above the usual 0.05 cutoff, gives no reason to think the two flows really differ. So on the mean alone, nothing here shows the new checkout is actually faster.