Tag: statistics

  • Understanding Cannot be Taught

    Nov. 27, 2026

    Previously, I’ve questioned how you can really know if you understand something.

    The challenge for educators is even more complex: How do you evaluate whether someone else really understands something?

    As I’ve shown before, an entire advanced degree can be earned without necessarily understanding the topic area with any particular depth. (I hasten to blame the system for such a failure, not the student. Mainly because the system can’t defend itself against my critiques.)

    As such, the abilities to answer questions and even solve novel problems are NOT sufficient indications of understanding. Maybe those are some of the best indicators we have access to, but that doesn’t necessarily make them compelling indicators.

    As a statistics educator, I’m not sure that I can teach anyone how to understand statistics.

    Certainly, I can teach key terms, principles, methods, formulas, interpretation guidelines, etc.

    But I don’t have the power to convey actual understanding.

    That’s something that happens inside the learner’s head. Understanding must be chosen AND discovered—but both of those verbs belong solely to the learner. As the educator, I have no control over either.

    Instead, what I’m doing is more like placing a variety of learning materials in front of students and then facilitating opportunities to engage with those materials.

    In-class lectures, visuals, and demonstrations are exposures to knowledge. There’s no guarantee that anything will be grasped immediately (or ever). The only thing I can truly guarantee is increasing familiarity.

    And that can be a trap, because familiarity starts to feel like understanding. Yet we commonly feel comfortable with and even accept ideas that we couldn’t explain if pressed.

    Ultimately, the student will learn on their own, if they invest enough time and energy.

    Even if they study with peers or engage their instructors in long dialogues, the formation of understanding is a solitary phenomenon, occurring within a conceptual framework that the learner alone has access to.

    They will come to understand a given concept only if they wrestle with it until they’ve formed their own independent mental representation of it, distinct from the provided learning materials.

    In this way, the educator does NOT teach understanding. They only create the conditions for it.

  • Empirically Deriving the Normal Distribution

    Nov. 21, 2026

    A few weeks back, while explaining how to calculate p-values using the slicing method, I off-handedly tossed out the fact that the density of the standard normal (Gaussian) distribution is given by…

    [1/√(2π)] ⋅ e^(-x²/2)

    As you might imagine, most people do not find this very intuitive.

    In this post, we’re going to bypass the need for the formula altogether…

    Briefly, the formula above is the probability density function (PDF) for the standard normal distribution. That just means it gives the height of curve at any location along the x-axis.

    For example, this is what we get when we plug this formula into R, over the x range of -4 to +4…

    > curve((1/sqrt(2*pi))*exp(-x^2/2),
    + -4,4,ylab='Density')

    This curve is useful for a variety of HR analytic applications (e.g., evaluating adverse impact using a z-test for proportions).

    But we don’t actually need the formula to derive this curve.

    In fact, we can produce it from statistics that are completely unrelated to whatever our actual analytic context is.

    The normal curve (or some transformation of it) describes how scores, measurements, and statistics commonly pile up.

    As such, we can approximate this curve simply by piling up many such values (using simulation) and then checking the relative heights throughout the distribution.

    It’s okay if that doesn’t make sense yet. Let’s walk through an example…

    First, some context for our demonstration.

    In one recent post, I showed how to calculate the p-value for a correlation coefficient (r) using an empirically derived null distribution.

    Basically, I generated two columns of random data and correlated them. Random data don’t correlate with anything, so any finding other than r = 0 was due to randomness.

    I did this 1 million times and piled up the resulting correlations into a null distribution. (Incidentally, the fabled “p-value” is the proportion of the distribution at least as extreme as the observed r calculated using real data.)

    In the bonus section at the end of the post, I noted that the sampling distribution might have appeared normal (Gaussian), but it wasn’t, because there were floor and ceiling effects happening.

    This is necessarily the case, because correlation coefficients are defined such that -1 ≤ r ≤ +1. This “crushes” the distribution in toward zero from both the left and right.

    But what if there were no lower or upper bound?

    There’s a solution involving Fisher’s z transformation, which essentially removes the floor and ceiling by stretching them out toward negative and positive infinity, respectively.

    Instead, I’m going to use a method that I find even more intuitive: Simulate a sufficiently large number of correlations, each based on sufficiently large samples, so that the floor and ceiling effects become almost unnoticeable.

    1. The larger the samples (i.e., number of datapoints in each column), the narrower the sampling distribution becomes, which increases its distance from the floor and ceiling, thereby minimizing their crushing effect.
    2. And the more correlations we simulate overall, the more precisely the sampling distribution will converge on a normal distribution.

    This time, I’m going to simulate the data using flat, uniform distributions (i.e., runif() rather than rnorm()), just to show that the normal curve isn’t emerging due to some “special case” like starting out with normal data.

    I’ll use a sample size of n = 500, which is a bit of overkill, but that’s okay.

    And I’ll run the simulation a million times (reps = 1e6), which is ALSO overkill.

    What? I like overkill.

    > # Setup
    > n=500; SE=1/sqrt(n-1); reps=1e6
    > set.seed(123)
    > rs=replicate(reps,cor(runif(n),runif(n)))

    ^^Here’s the breakdown…

    • The standard error (SE) is the standard deviation of the sampling distribution, which is an index of spread. If the true correlation is 0 (which it is in this case), then the standard approximation is 1/√(n ‒ 1).
    • I’m arbitrarily setting the seed as “123” for reproducibility.
    • The replicate() line is simulating a million pairs of columns of random data (each with 500 values) and correlating them.

    It took my device ~57 seconds to run that code. (A million times is a lot.) If you want to run this faster on your device, just use reps=1e5.

    Next, let’s see what the histogram of simulated rs looks like.

    > # Histogram Version
    > (h=hist(rs,breaks=50,main='',
    + xlab='Simulated Correlations',col='#99CCFF'))
    > curve(dnorm(x,0,SE)*1e6*diff(h$breaks[1:2]),
    + add=T,col='firebrick3',lty=2,lwd=2)

    What do you know? The distribution of simulated correlations is nearly identical to a normal distribution!

    A few technical comments on the code above…

    • I assigned the histogram to “h” and put that entire first snippet inside parentheses so that it would show me the plot AND save the histogram information for repeat use in the next few lines.
    • The second snippet plots the theoretical normal curve, scaling it vertically by the number of simulations (1e6) and the width of a given bar (diff(h$breaks[1:2])). In other words, this expresses the curve in terms of frequencies, NOT densities.

    Finally, let’s move this into the realm of the standard normal distribution, which is where we would be working in a real-world application like evaluating adverse impact with a z-test for proportions.

    > # Density Version
    > d=density(rs/SE)
    > plot(d,xlim=c(-4,4),ylim=c(0,.4),main='',bty='n',
    + xlab='Simulated rs (SE Units)',ylab='Density')
    > curve(dnorm(x),add=T,col='firebrick3',lty=2,lwd=2)

    This is the same as the histogram, except we’ve…

    1. Used kernel density estimation to smooth out the bars into a clean, pretty curve.
    2. Divided by the SE, which means the x-axis is now expressed in SE units. (This is the scale typically used to calculate p-values.)

    Let’s run a few quick checks to make sure that we get approximately the same densities (i.e., curve heights) regardless of which method we use…

    > # Comparisons
    > z=c(-3,-2,-1,0,1,2,3)
    > # Theory Prediction vs. Empirical Finding
    > round(dnorm(z),3); round(approx(d$x,d$y,xout=z)$y,3)
    [1] 0.004 0.054 0.242 0.399 0.242 0.054 0.004
    [1] 0.005 0.054 0.243 0.396 0.241 0.054 0.004

    ^^Here, we have the heights of the curves for 7 different values (-3, -2, -1, 0, 1, 2, 3). The two methods match to within ~.003.

    If we wanted them to match even more precisely, we could increase the number of simulated correlations (1e7? 1e10?). But that would take a long time on my device.

    And besides, we’ve already demonstrated the point we wanted to.

    A normal curve is just the way that particular values tend to pile up under certain conditions; the intimidating PDF formula is simply capturing how that piling occurs.

    You can do anything you want (including calculating p-values and the like) without ever touching the formula. The same results can be produced to some satisfactory approximation using simulation.

  • I Was Wrong About Gemini

    Nov. 7, 2026

    In a previous post, I tested whether Gemini and Claude could extract training evaluation data from PDF summaries and calculate weighted means based on number of responses.

    This involved extracting >100 datapoints and then correctly combining different pieces of information to weight the means appropriately. Because the two LLMs produced different results (and because I generally don’t trust AI output), I double-checked the results myself.

    In short, Claude’s results on the first try were identical to my own, which is strong evidence of accuracy (because triangulation).

    In contrast, Gemini got every single result wrong. The results were in the general ballpark, but they were too far off to be explained by rounding error.

    My takeaway was that we’re still not to a point where AI can be trusted to produce accurate results without any quality verification.

    But then I saw a LinkedIn post by Ethan Mollick, where he argued that “there is too much concern expressed about the need for human verification of AI output in everyday work due to a risk of factual errors.”

    He also said, “the idea that the job of humans should be checking AI work for mistakes is likely already not true today…”

    Essentially, his argument was that our intuitions about AI accuracy are miscalibrated, because models have improved dramatically over a short period of time. It used to be true that their output was not trustworthy, but at this stage, human verification may be unnecessary.

    I generally trust EM’s takes on AI issues, so this was a real surprise to me.

    In the comments, several individuals mentioned finding errors in AI output all the time. In reply, EM suggested that such personal experiences were likely due to using lower-quality models: “I am curious how much of that is people using free or older models. I suspect a lot.”

    My intuition is that this may be domain-specific. I’m sure there are certain contexts where AI outperforms humans to the extent that verification only introduces error if anything…but I also suspect there are many contexts where AI results remain highly unreliable.

    Regardless, seeing EM’s post made me realize that my test of Gemini vs. Claude (vs. me) was not very fair, because I didn’t even pay attention to which models I was using. I just dumped the relevant PDFs into the online chat interfaces that popped up and gave the instructions.

    Claude’s default model was Opus 5.5 Medium, which was enough to produce the correct results.

    Gemini’s default model was 3.6 Flash, which produced entirely incorrect results. Looking back, I see that all its response counts were wrong, which could be part of why the resulting weighted means were wrong.

    To give it a fair shot, I changed the Gemini model to 3.8 Thinking, which seems to be the most advanced model currently available to me.

    And it got every single calculation correct. (That is, its results matched both mine and Claude’s.)

    So, I guess I have to update my previous conclusion…

    Can AIs handle tasks like extracting average ratings and then weighting them and aggregating across 10 different summary reports?

    It appears so, at least for manageable document sizes. I don’t know what the boundary conditions are.

    But it does help to select a newer, higher-powered model.

  • Calculating p-Values Using the Slicing Method

    Nov. 4, 2026

    I’ve previously explained p-values and checked the accuracy of the explanation using R code.

    Now, let’s do what I originally planned to do before getting side-tracked, which is to show how we can calculate our own p-values using calculus.

    Most p-values are not directly calculated by the individuals using or reporting them. Instead, they appear “magically” in the output of the analysis, which is often run using a platform like R, Python, SPSS, Stata, or MS Excel.

    But as explained in the last two posts, the p-value is simply the proportion of a null distribution that’s at least as extreme as the result we actually calculated.

    Using that information, we can calculate our own p-values rather than relying on canned code or hidden procedures.

    • This serves as a second check on whether our understanding of p-values holds up.
    • It also serves as another confirmation that we understand the basic idea behind integration in calculus.

    The “slicing approach” to calculus finds the area of a shape by slicing it into many thin strips, approximating the area of each, and then adding them all up.

    The narrower each slice is, the more the resulting sum converges on the true area. Therefore, to get precisely the correct answer, the widths of our slices must collapse toward zero.

    If we understand both of these concepts correctly, then we can do a quick check in R (or whatever programming language).

    Let’s put this in a hiring context…

    Suppose we’re conducting an adverse impact analysis for an employee selection process. We have two groups (let’s call them “Group 1” and “Group 2”), and we are examining the difference between their selection ratios (i.e., the proportions hired out of the totals that applied).

    Imagine that we run some relevant calculations and find that the difference can be described by z = 2.20 in a standard normal distribution.

    A p-value can tell us the probability of a result at least this extreme if the “true effect” is zero (i.e., if there’s hypothetically no real difference in hiring rates, beyond random noise).

    This is equivalent to the area under the standard normal curve that lies beyond ±2.20 (in dark red below), expressed as a proportion of the total area under the curve…

    To calculate p using the slicing method, we will…

    1. Slice up all the area under the curve more extreme than ±2.20
    2. Approximate the area of each slice
    3. Sum the areas

    The purpose here is to demonstrate that our mental model of these concepts is accurate. We’ll do that by creating a digital representation of the concepts and then checking if it produces the correct results to some acceptable approximation.

    First, let’s slice up the area under the curve more extreme than ±2.20…

    > # 1. Identifying Slices
    > slices=c(seq(-10,-2.2,by=1e-6),
    + seq(2.2,10,by=1e-6))

    Because the area under the curve gets so small the further out you go, I’m only going to approximate this with the ranges z = -10 to -2.2 and z = 2.2 to 10.

    Notice that this code specifies the slice width as an arbitrarily narrow value of 1e-06 = .000001. (The narrower we set it, the more precisely our approximation will match the true result.)

    Next, we need to approximate the area of each slice. For this, we’ll treat the slices as rectangles with equal width and with heights equal to the vertical distances under the curve. (The areas aren’t really rectangles, but because the slices are so thin, the slight error is negligible.)

    We already know the widths…

    > # 2. Approximating Areas of Slices
    > # 2a. Widths
    > slice_width=1e-6

    The slice height can be calculated using the probability density function for a normal curve, which is …

    [1/√(2π)] ⋅ e^(-x²/2)

    For example, we could manually calculate this for z = 2.5…

    > (1/sqrt(2*pi))*exp(-2.5^2/2)
    [1] 0.0175283

    Or we could simply use a built-in function, like dnorm(), which gives the same result…

    > dnorm(2.5)
    [1] 0.0175283

    Either way, let’s assign those slice heights…

    > # 2b. Heights
    > slice_height=dnorm(slices)

    Next, because the area of a rectangle is simply Area = Base ⋅ Height, that’s our next step…

    > # 2c. Slice Areas
    > slice_areas=slice_width*slice_height

    Finally, we sum these areas to get the full area under the curve more extreme than ±2.2 (i.e., the p-value)…

    > # 3. Summing Approximated Slice Areas
    > sum(slice_areas)
    [1] 0.02780693

    We can check this in multiple ways.

    First, let’s see how this stacks up against the more precise calculation using the pnorm() function…

    > # Precise p-Value
    > 2*pnorm(-2.2)
    [1] 0.0278069

    Clearly, our result matches the more precise calculation to several significant digits. This is more evidence that our understanding of p-values is correct.

    Next, let’s check if our understanding of the slicing method is on-target. We can do this by using the integrate() function in R…

    > 2*integrate(dnorm,2.2,10)$value
    [1] 0.0278069

    This matches our slicing approximation to several significant digits as well.

    By the way, we could also integrate from ±2.2 to negative and positive infinity, which would cover both entire tails of the distribution…

    > 2*integrate(dnorm,2.2,Inf)$value
    [1] 0.0278069

    Okay, it all worked out as expected. These demonstrations further support our belief that our mental models of both p-values and the slicing method of integration are on target.

    Obviously, you wouldn’t actually calculate p-values in this “manual” way in your own work or research. It’s super inefficient.

    But that’s not the point. The purpose of exercises like these is to evaluate the extent to which you genuinely understand the concepts at a relatively deep level.

    Once you do understand, then it’s almost irresponsible not to use more efficient code.

    Understand, then automate.

  • Do We Understand p-Values? (Pt. 2)

    Nov. 3, 2026

    Last time, I explained how I think about p-values, which only partly aligns with the classical null hypothesis significance testing paradigm. (In brief, I view a p-value as a graded piece of information, NOT as a binary indicator of “statistical significance.”)

    This time, let’s see if we can represent this concept using R code. If the representation is accurate, then the results of our custom code should match the results of a standard analysis using canned R code from existing packages.

    First, let’s simulate some data for two variables…

    > # Generating Random Data
    > set.seed(123)
    > x=rnorm(500,100,15)
    > y=x*2+rnorm(500,sd=160)

    I know these two sets of scores will be correlated, because I directly defined the second set (y) based on the first (x), with some random noise added in.

    Next, let’s correlate the two sets of scores and save that as “r”…

    > # Checking the Correlation (r)
    > (r=cor(x,y))
    [1] 0.1276118

    Okay, so there’s a correlation of r ≈ .128.

    But what is the p-value for that r? Let’s check…

    > # Extracting the p-Value from a Significance Test
    > (p=cor.test(x,y)$p.)
    [1] 0.004262684

    This correlation is associated with p ≈ .004. This means that, if the true effect were precisely ρ = 0 (that’s rho, not p), then we’d observe an effect at least as extreme as r = .128 only .4% of the time (i.e., about 4 times in 1000).

    That’s not very often. One might suggest that this is relatively unlikely if the null is true…in which case, perhaps the null is untrue…

    More information would need to be taken into account, but, all else being equal, a smaller p-value may be interpreted as evidence against the null hypothesis that there is zero effect.

    (Remember the signal detection logic from last time.)

    ((Also, if that claim just triggered you, then go read my previous post on this topic. I define “evidence” as any piece of information that sways your credence toward a particular belief. If you’re feeling agitated, it’s probably because you are defining “evidence” differently.))

    Also Note: I don’t need to check the statistical assumptions in this particular case, because I defined the two variables so that the assumptions would be met.

    Next, let’s walk through the process of creating a null distribution (a pile of results that would be expected if the true effect were literally zero).

    There are more elegant ways to do this, but I’m going to use brute force, because this approach is easier for me to understand (which is the entire point)…

    Below, I’ll simulate 1 million independent pairs of distributions—meaning the true correlation between each of them MUST be nothing (i.e., ρ = 0)—and then I’ll correlate them all. The pile of correlations will serve as our null distribution.

    > # Simulating 1 million pairs of unrelated datasets
    > set.seed(1234) # For reproducibility
    > sim_rs=replicate(1e6,cor(rnorm(500),rnorm(500)))

    It is important that n = 500 for each simulated dataset, because that’s the size of our “observed data” from before.

    On my device, the above code took about 1 minute to run.

    Before calculating the p-value, let’s visualize this null distribution…

    > # Plotting the Null Distribution
    > plot(density(sim_rs),xlim=c(-.3,.3),
    + xlab='',ylab='',main='')
    > abline(v=r,lty=2,lwd=2,col='blue')

    I drew a blue dashed line to represent where our original observed statistic (r = .128) lies in this null distribution.

    Now, remember that the p-value is the proportion of this distribution that is at least as extreme as r = .128 (whether positive or negative).

    We can calculate that using this R code…

    > # Calculating an empirical p-value...
    > mean(abs(sim_rs) >= abs(r))
    [1] 0.004167
    > # Compare to the p-value that cor.test produced...
    > p
    [1] 0.004262684

    Our simulation produced an approximation (p = .004167), which is pretty close to the more precise value calculated earlier (p ≈ .004263).

    The reason it’s not even closer is that I “only” used 1 million pairs of distributions in the simulated datasets.

    If we want our approximation to be even closer, we could simulate, say, 10 million pairs of datasets.

    I did it so you wouldn’t have to (took about 10 minutes on my device)…

    > # Simulating 10x more data
    > set.seed(1234)
    > sim_rs=replicate(1e7,cor(rnorm(500),rnorm(500)))
    > # Calculating an empirical p-value
    > mean(abs(sim_rs) >= abs(r))
    [1] 0.0042553
    > p
    [1] 0.004262684

    The two calculations would only continue to converge as we increased the number of pairs of simulated datasets.

    Okay, that does it for the demonstration.

    As we can see, our conceptualization of what a p-value is and where it comes from DOES seem to align with results that are produced from mathematical theorems (at least to an approximation).

    Again, the interpretation of a given p-value is still up to the individual. As can be seen from the graph above, a correlation this extreme is fairly surprising in this null distribution. But it certainly doesn’t seem unfathomable by any stretch, at least not in my opinion…

    At the risk of belaboring the point, this demonstration reveals another intuitive way to think about significance tests…

    They ask, “Is the effect far enough away from zero, relative to the amount of noise in the data, that it seems like more than mere noise?”

    This is fundamentally what any signal-to-noise ratio is all about.

    All right. Enough on all that. Next time, I’ll (finally) get to how we can use calculus to calculate p-values by hand.


    BONUS: The plot above may have given the impression that the distribution of rs is normal (i.e., Gaussian), but it actually isn’t.

    A normal distribution extends infinitely to both the left and right, but the plot above does not. In fact, it cannot.

    This is because correlation coefficients are bounded by -1 and +1, which crushes the null distribution in toward 0.

    You may be able to see this if we zoom our plot out to include those boundaries…

    > # Wider-View Plot
    > plot(density(sim_rs),xlim=c(-1,1),
    + xlab='',ylab='',main='',yaxt='n',bty='n')
    > abline(v=c(-1,1),lwd=2,lty=2)

    Okay, enough nerdy stuff for today…

  • Do We Understand p-Values? (Pt. 1)

    Nov. 2, 2026

    Originally, this post was going to be about how to use calculus to calculate p-values. This would be yet another demonstration of how we can use digital representations of our mental models (i.e., code) to test how well we understand a concept.

    However, that explanation relies on the reader already understanding p-values at a relatively deep level.

    So, instead, this post became an introduction to p-values…

    (This is the verbal expression of my conceptualization; next time, we’ll convert this into a digital representation.)


    Few statistical concepts are as misunderstood (or maligned) as the mythical p-value.

    Many people who frequently use p-values don’t really understand them. For example, a substantial number have simply memorized that “If p < .05, it’s statistically significant,” which they use as a decision rule.

    But while those who hate p-values usually do understand them fairly well, the uniform disapproval of their use reflects a different kind of confusion.

    There is nothing wrong with p-values—so long as you don’t misuse them.

    What’s a p-value?

    In the context of statistical significance testing, a p-value is simply the proportion (p) of a null distribution that is at least as extreme as an observed result. (Nothing inherently good or bad about it.)

    Okay, but what does THAT mean?

    Essentially, a significance test is about signal detection. Most of the time, the question is, “Is there any effect at all?” Or, put another way, “Does it seem like the effect is different than literally zero?”

    (It’s debatable how informative that question is, as well as whether there aren’t better questions we could be asking, but let’s keep walking through it for now.)

    In this context, an effect refers to an association between two variables. For example, is there any link between supervisor quality and intent to quit your job? We might check by gathering some data and calculating a statistic like a correlation.

    • If there’s no link whatsoever, then the effect is zero.
    • If there is some link, whether positive or negative, whether large or small, then the effect is NOT zero.

    A significance test evaluates this question using a backwards sort of logic:

    1. Assume (hypothetically) that the effect is literally zero.
    2. Calculate the result we’d expect to see if this were true.
    3. Repeat this calculation many, many times. (Due to randomness, the results will vary somewhat.)
    4. Pile up all the calculated results into a distribution (i.e., a null distribution).
    5. Check where your observed result lies within this distribution.

    (Fortunately, we don’t actually have to run an infinite number of analyses. We can use math and/or simulations to derive this null distribution.)

    In this way, you are comparing the result of your actual analysis to the various possible results that would be expected due to mere randomness.

    This is a signal-to-noise evaluation…

    • If your result is similar to what would be expected due to random noise, you might interpret that as evidence* favoring zero effect.
    • If your result is very different from what would be expected due to random noise, you might interpret that as evidence* favoring a nonzero effect.

    *NOTE: I broadly define the term evidence to mean any piece of information that sways one’s credence toward a particular belief. In this way, I’m essentially using a p-value as a (very) loose proxy for a Bayes Factor, if you know what that is. (Not getting into that right now.)

    Regardless, note that this is NOT how some statisticians use the term “evidence.” And that’s fine. Words are just labels for concepts, so if we explain what we mean by them, we can use them however we like.

    But how do you determine how compatible your result is with random noise?

    This determination is based on where your observed result lies relative to the rest of the distribution…

    The shape of the null distribution describes how relatively likely different results are (assuming the true effect is zero). In locations where the distribution piles up higher, those results are more likely.

    Therefore, the nearer your observed result lies to the densest mass of the distribution, the more compatible it is with zero effect. That’s because your finding is the sort of result that would be predicted under zero effect.

    In contrast, the further your observed result lies from the mass of the distribution, the less compatible it is with zero effect…because your finding is NOT the sort of result that would be predicted under zero effect.

    So, how to quantify the position of the observed result relative to the rest of the distribution?

    This is where the p-value comes in: it is simply the proportion of results in the null distribution that are at least as extreme as the actual result of your analysis.

    For example, if your result is way far away from the main mass of the null distribution, that proportion will be quite small (say, p = .00003). In contrast, if your result is near the main mass, the proportion will be relatively larger (say, p = .47).

    So, all things being equal, a larger p-value is more compatible with the notion of zero effect (i.e., the data resemble what random noise would produce)…

    And a smaller p-value is less compatible with the notion of zero effect (i.e., the data do NOT resemble what random noise would produce).

    It is extremely commonplace to treat this as a binary evaluation:

    • If p < .05, the result is “statistically significant.”
      • (A result at least this extreme would occur less than 5% of the time if the true effect is zero.)
    • If p ≥ .05, the result is “NOT statistically significant.”
      • (A result at least this extreme would occur at least 5% of the time if the true effect is zero.)

    In my opinion, this binary interpretation is a bad idea. It lends itself to overly simplistic decision rules, which are nearly always indicative of shallow understanding. It also eliminates the majority of the information that the p-value itself provides.

    Instead, I interpret p-values as what they literally are: The probability of a result at least as extreme as our analysis showed, if we assume the true effect is zero.

    I like to imagine a p-value as a slider… As p gets smaller, your credence (level of belief) in zero effect should fall; slide it back the other way, and your credence should rise again.

    But note that this slider only indicates direction, not precise amount. The extent to which your credence should adjust based on a p-value depends on various other factors, such as sample size, data quality, your previous beliefs, etc.

    In this way, a p-value can be interpreted as some amount of evidence for or against the notion of no effect. But it’s up to the individual to judge exactly how persuasive that evidence is.

    The binary decision rule seems to serve primarily as a mechanism to avoid individual judgment. That’s a cognitive trap.


    Understood correctly, there’s nothing inherently good or bad about p-values. They are simply a property of a result, assuming certain conditions hold.

    A person’s interpretation of what that value means can certainly be wrong. But the value is what it is.

    Next time, we’ll check if this explanation holds up by converting it into digital form (i.e., code), and then testing it.

  • Using Calculus to Find the Area of a Triangle

    Nov. 1, 2026

    The area of a triangle can be found with (1/2) base ⋅ height, which makes sense because a right triangle is half of a rectangle with area base ⋅ height.

    Hopefully, that formula already seems intuitively clear.

    But we can also find the area of a triangle using calculus…

    I like to think of calculus as geometry for weird shapes, but it can also be used to find the area of commonplace shapes like squares, triangles, and circles.

    One way to think of integration is as a method of slicing up a shape into many thin strips, where the width of each strip approaches 0. In other words, you’re slicing the shape as thinly as possible.

    The area of each slice can then be approximated by a rectangle with a width approaching zero and a height determined from the dimensions of the original shape.

    The area of the shape can therefore be found by summing the areas of all these thin slices.

    For example, consider a triangle with base = 5 and height = 10. We know from the basic geometric formula that the area is (1/2) 5 ⋅ 10 = 25.

    If we “sliced” this into vertical strips, the leftmost strip would have a height of 0, and the rightmost strip would have a height of 10. If we summed the areas of all the vertical slices from height 0 to height 10 (i.e., from x = 0 to x = 5), the total would be 25.

    We can check whether our understanding of integration is correct using R code.

    There are multiple ways to do this, but I’m going to approximate the correct answer by literally slicing the triangle into many very thin strips.

    Specifically, I’m going to cut it into 50 million slices. (That’s a lot, but R does it in a split-second on my device.)

    > # Triangle Dimensions
    > base=5
    > height=10
    > # Standard Area Check
    > (area=base*height/2)
    [1] 25
    > # Specifying 50 million slices
    > slices=seq(0,5,1e-7)

    Now, how do we approximate the area of each slice? Each width has been defined as 1e-7 = .0000001.

    If we examine the triangle, we’ll notice that the height of each vertical strip is twice its position along the x-axis (i.e., the distance from the left end of the triangle). For example…

    1. When x = 0, the height is 0
    2. When x = 2.5, the height is 5
    3. When x = 5, the height is 10

    Another way of saying this is that the top edge of the triangle is a line described by y = 2x (the slope is 2).

    So, now let’s identify the height of each slice….

    > # Heights of slices
    > slice_heights=slices*2

    And then combine the heights and widths into areas of each slice…

    > # Areas = Heights * Widths
    > slice_areas=slice_heights * 1e-7

    And the last step is to sum the areas of these slices…

    > sum(slice_areas)
    [1] 25

    Note that we only get precisely 25 because R displays just 7 significant digits by default. If we instruct R to be more precise, we’ll see that the calculation is not quite 25…

    > # This is less precise than it seems...
    > print(sum(slice_areas),digits=15)
    [1] 25.0000005

    But the narrower the slices we use, the more the result will dial in on precisely 25.

    Okay. I think the concept has been demonstrated well enough.

    Clearly, there are much more rigorous ways to approach this kind of thing. And I’m sure that any actual mathematician reading this would fly into a rage at the imprecision in my explanations and demonstrations.

    But the point is we’ve written code to represent our understanding of the concept (integration), and this code accurately produced expected results to an acceptable degree of approximation.

    Next time, I’ll apply the same concept to show how we calculate these magical p-values that stats folks are always talking about…

  • Using Code to Represent Deeper Understanding

    Oct. 31, 2026

    I believe everyone should learn to code, because it allows for creating digital representations of the concepts that exist in our minds, and this allows for testing them for accuracy.

    In the previous post, however, I showed that a coded representation of an idea can still be incredibly shallow. In that example, I showed that creating custom R code for the arithmetic mean could simply reflect a basic formulaic understanding: “Add up the parts, divide by the number of parts.”

    A deeper level of understanding might involve realizing that the arithmetic mean is only one specific case of a set of general functions (e.g., geometric mean, harmonic mean, exponential mean)…

    For all these functions, there is some operation (e.g., addition, multiplication, etc.) conducted on each value in the distribution, and then they are aggregated in a way that shows what an “equal contribution” of each would be.

    For example, with the arithmetic mean, we are adding all the parts up. And the mean represents the single value that could replace every datapoint in the distribution while still summing to the same total as the original dataset. In this way, it’s a sort of “typical” score in an additive sense.

    Suppose we had 3 scores: (1, 2, 3)…

    • The arithmetic mean is (1 + 2 + 3)/3 = 2.
    • The sum of the original dataset is 1 + 2 + 3 = 6
    • If we replaced each value with the mean (2), we would get precisely the same sum: 2 + 2 + 2 = 6

    So this family of means (which is infinitely large) says: If you perform some operation on all the scores, then the mean will be the value that could replace each without changing the result of the operation. In other words, it shows what an “equal contribution” to the operation would be.

    If this understanding is correct, then we should be able to write a function in R (or whatever programming language you prefer) that takes as its inputs (1) a set of scores and (2) the operation being performed, and then produces the resulting mean.

    Let’s take 4 examples from this family of means…

    1. Arithmetic Mean = Σx/n (Operation: Addition)
    2. Geometric Mean = ⁿ√(Πx) (Operation: Multiplication)
    3. Harmonic Mean = n / Σ(1/x) (Operation: Addition of reciprocals)
    4. Quadratic Mean = √(Σx²/n) (Operation: Addition of squares)

    Pulling this off successfully will require understanding a more general algorithm that binds all these (and all others in this family) together…

    Geometric Mean

    When each value in a set is multiplied, the arithmetic mean produces misleading results.

    Example: Suppose you invest $100. If your return in the first year is +30% (i.e., 130% of original) and then your return in the second year is -30% (i.e., 70% of Year 1), then what is the average growth?

    The arithmetic mean would seem to suggest 0% growth…

    • Σx/n = (1.30 + (.70)) / 2 = 1
      • (In this case, 1 means 100% of the original, so zero return overall)

    But this is obviously incorrect if we check step-by-step…

    1. Year 1: $100 ⋅ 1.30 = $130
    2. Year 2: $130 ⋅ .70 = $91

    We’ve lost $9…so clearly it’s not 0% growth.

    The better solution is the geometric mean, which gives the typical multiplicative value…

    • ⁿ√(Πx) = ²√(1.30 ⋅ .70) ≈ .9539

    We could replace each year’s return with this value and then get the correct ending value…

    1. Year 1: $100 ⋅ .9539 = $95.39
    2. Year 2: $95.39 ⋅ .9539 ≈ $91

    So what’s the link between the arithmetic mean and the geometric mean?

    Well, the real question is, “What’s the link between addition and multiplication?” And the answer is logarithms.

    Specifically, log(a·b) = log(a) + log(b).

    This means that if we first take the log of each value, we can proceed to use the ordinary arithmetic mean…

    • [ln(1.3) + ln(.7)] / 2 ≈ -0.0472

    …then exponentiate (i.e., return to original units) to get the correct answer!

    • e^-0.0472 ≈ .9539

    This is the same result we got when using the geometric mean formula.

    Harmonic Mean

    When working with reciprocals, the ordinary arithmetic mean again fails…

    Example: If you drive at 50 mph on the way to your destination, then you drive back at 40 mph, then what was your average speed?

    It may seem intuitively clear that the answer is 45 mph (the midpoint between 40 and 50). That value is the arithmetic mean… and it is WRONG.

    That calculation would only work if you traveled for the same time units each time (e.g., 50 mph for 1 hour and then 40 mph for 1 hour).

    But you were traveling 10 mph faster on the way to the destination, so it did NOT take you the same amount of time each way.

    The real solution is the harmonic mean, which expresses the calculation in terms of the thing that is constant (i.e., distance to and from the destination). It’s as simple as flipping the miles / hour fraction…

    • (1/50 + 1/40) / 2 = .0225 hours per mile (hpm?)

    …then taking the reciprocal to put it back in the original units…

    • 1 / .0225 ≈ 44.44 mph

    Quadratic Mean

    When working with square units (e.g., tiles on a bathroom floor), the naive arithmetic mean again fails…

    Example: Suppose you’ve got 100 tiles to cover the floor of a room. Half are 6 inches across, and half are 8 across. What’s the average coverage of a given tile? And how much area will this cover?

    It might be tempting to just think, “Well the average tile is 7 inches across (i.e., the arithmetic mean of 6 and 8), so that’s 7² = 49 sq in. Multiply times 100 tiles to get 4,900 sq in.”

    Wrong, wrong, wrong…

    The 6″ tiles have area 6² = 36 sq in, and the 8″ tiles have area 8² = 64 sq in. The arithmetic mean is (36 + 64) / 2 = 50 sq in. And that multiplied times 100 tiles is 5,000 sq in.

    The quadratic mean, √(Σx²/n), handles this correctly. First, calculate the mean of the squares…

    • Σx²/n = [50⋅6² + 50⋅8²] / 100 = 50 sq in

    …And then we can take the square root to convert back to original units (inches rather than square inches)…

    • √50 ≈ 7.07107 in

    The average tile’s side length is 7″… but that does not accurately reflect the total tile area!

    (By the way, I’ve never laid tile before, so I don’t know if being off by this factor would be a serious problem or not. But I personally would want the correct calculation.)

    Quasi-Arithmetic Mean

    In case you haven’t noticed it yet, the general process is…

    1. Transform the scores
    2. Calculate the arithmetic mean: Σx/n
    3. Transform the scores back into original units (inverse transformation)

    The general form of this process is called the quasi-arithmetic mean…

    • Mean = f ⁻¹ [Σf(x) / n]

    (This formula is nothing new. It’s just expressing that 3-step process above using mathematical notation.)

    The transformation (f) could be taking the logarithm (for the geometric mean), taking the reciprocal (for the harmonic mean), taking the square (for the quadratic mean), and so on.

    Transform, calculate the arithmetic mean, then transform back to original units.


    Finally, we’re ready to write R code that takes any set of scores as input, along with a specification regarding the type of operation conducted, and that then spits out the resulting mean (whether arithmetic, geometric, harmonic, or whatever).

    Here’s a version where each step is explicitly laid out…

    > # Custom Mean Function
    > generalized_mean=function(data,transformation,inverse) {
    + t_data=transformation(data) # Transformation
    + m_t_data=sum(t_data)/length(t_data) # Arithmetic mean calculation
    + result=inverse(m_t_data) # Inverse transformation
    + return(result)
    + }
    > # Example 1: Arithmetic Mean
    > x1=1:3
    > generalized_mean(x1,identity,identity)
    [1] 2
    > # Example 2: Geometric Mean
    > x2=c(1.3,.7)
    > generalized_mean(x2,log,exp)
    [1] 0.9539392
    > # Example 3: Harmonic Mean
    > x3=c(50,40)
    > generalized_mean(x3,function(x) 1/x, function(x) 1/x)
    [1] 44.44444
    > # Example 4: Quadratic Mean
    > x4=c(rep(6,50),rep(8,50))
    > generalized_mean(x4,function(x) x^2, sqrt)
    [1] 7.071068

    All the results match our above calculations.

    But we can make it WAY cleaner by collapsing the function into a single line representing f ⁻¹ [Σf(x) / n]…

    > # Cleaner Generalized Mean Code
    > gen_mean_clean=function(x,f,inv_f) {inv_f(mean(f(x)))}
    > # Arithmetic
    > gen_mean_clean(x1,identity,identity)
    [1] 2
    > # Geometric
    > gen_mean_clean(x2,log,exp)
    [1] 0.9539392
    > # Harmonic
    > gen_mean_clean(x3,function(x) 1/x, function(x) 1/x)
    [1] 44.44444
    > # Quadratic
    > gen_mean_clean(x4,function(x) x^2, sqrt)
    [1] 7.071068

    If we check our work using the standard formulas, we get the exact same answers…

    > # Checking our work...
    > mean(x1)
    [1] 2
    > prod(x2)^(1/length(x2))
    [1] 0.9539392
    > length(x3)/sum(1/x3)
    [1] 44.44444
    > sqrt(sum(x4^2)/length(x4))
    [1] 7.071068

    In each of the 4 cases, the mean finds the value that would constitute an “equal contribution” to some result, namely…

    1. The sum of scores for the arithmetic mean
    2. The product of scores (i.e., sum of log-scores) for the geometric mean
    3. The sum of reciprocals (e.g., total time) for the harmonic mean
    4. The sum of squares (e.g., total area) for the quadratic mean

    If we can follow all of that, then I think it’s safe to say we have fairly deep understanding of the concept of the mean.

  • Code Can Reflect Shallow Understanding

    Oct. 30, 2026

    Previously (here and here), I’ve argued that everyone should learn to code (even truck drivers in 2026).

    The core concept is that code allows for creating digital representations of our internal mental models, which allows us to test and confirm whether our understanding is actually correct.

    But the fact that you can represent your understanding with code does not necessarily mean that you possess deep understanding.

    It’s entirely possible to write code that reflects shallow understanding.

    I’ll explore an example below, using a basic Stat 101 concept, the arithmetic mean (what is often meant by the term average).

    A shallow understanding of the mean might be demonstrated by describing it as, “The result of adding up the parts and dividing by the number of parts.”

    The definition is true, but it’s very basic, and one could utter these exact words in this sequence without really knowing what it means.

    We can represent this level of understanding using R code in a fairly straightforward way…

    > # Sample Data
    > (x=1:6)
    [1] 1 2 3 4 5 6
    > # Mean Formula from Scratch
    > seth_mean=function(data) {sum(data)/length(data)}
    > # Let's see if it works...
    > seth_mean(x)
    [1] 3.5
    > # It matches the result of the Base R mean function
    > mean(x)
    [1] 3.5

    We can try to break the new code, such as by messing with the inputs. For example, my custom function has a failure mode relating to NA values…

    > # Sample Data with a missing value
    > (y=c(x,NA))
    [1] 1 2 3 4 5 6 NA
    > seth_mean(y)
    [1] NA
    > # The Base R function can handle this...
    > # ...if we simply add an argument
    > mean(y,na.rm=T)
    [1] 3.5

    Note that the above approach “handles” the missing data by omitting those cases, which is not necessarily the best approach.

    Reagrdless, I can modify my custom function to accommodate missing values (say, by omitting them), maybe like this…

    > # Modified function that omits NA values
    > seth_mean2=function(data) {
    + data=na.omit(data)
    + sum(data)/length(data)
    + }
    > # Testing it out...
    > seth_mean2(y)
    [1] 3.5

    But what extent of understanding does this code actually convey?

    It could represent something deep… or it could merely reflect understanding equivalent to, “Uhh…it’s a statistic that you get when you add things up and divide by the number of them.”

    Next time, I’ll explore using code to represent a deeper level of understanding…

  • Code as Falsifiable Externalization of Understanding

    Oct. 29, 2026

    I dropped yesterday’s post (Everyone Should Learn to Code) into Claude just to see what it would say, and it commented, among other things…

    “Your idea is: code as a falsifiable externalization of understanding.”

    And as much as I usually hate AI writing, even I have to admit that’s a pretty clean summarization of what I’m trying to describe.

    I phrased it more like this: Coding allows us to create digital representations of concepts in our minds, which we can then test to see if they hold up.

    In one sense, this is more robust than the mental representations themselves, which aren’t directly subject to external verification.

    In this post, I’ll provide a simple demonstration of this concept: Deriving the formula for the diagonal of a cube.

    Along the way, I’m going to outline some ground rules for how to do it effectively…

    1. Your code has to be built up “from scratch” and incrementally.
    2. Your code has to come directly from your own mental model.
    3. Your code has to be verified using an independent method.
    4. Your code has to survive your best efforts to “break” it.

    1. Build the code from scratch.

    This is similar to first principles thinking, which basically entails breaking ideas down into their most fundamental parts (each of which seem axiomatically true to you) and then re-combining the parts.

    A key benefit of this approach is that it allows you to avoid memorizing a bunch of complicated information; instead, grasping a few basic principles enables you to combine them into more complex forms in the moment.

    Here’s a simple illustration: Offhand, I don’t recall the formula for the diagonal of a unit cube.

    (I remember it involves a square root or a cube root or something, but I don’t bother memorizing things like this. As this exercise shows, there’s no need to.)

    However, I do know the Pythagorean Theorem (PT), which can be used to derive the diagonal of a cube.

    Critically, I know the PT at an intuitive, visual level. I haven’t just memorized it; I know it virtually must be true (p > .99999), based on having seen dozens of proofs. I can’t imagine how it would be possible for it not to be true. So, for this exercise, we’ll accept the PT an an axiom or first principle.

    Okay, let’s see if we can work out what the diagonal of a unit cube would be… (note that this is a verbal representation)

    • By definition, each side of a unit cube is a square, and each edge has length 1 (let’s call each edge e, so e = 1).
    • When I visualize a cube in my mind (or draw one), I see that the biggest diagonal (not sure what it’s called, let’s call it D) cuts across the middle of the cube from one corner to the opposite one.
    • In my visualization, I notice D forms the hypotenuse of a right triangle, where one side is an edge of the cube (e), and the other is the diagonal of one of the square-sides (let’s call this smaller diagonal d).
    • I already know e = 1, but I need to find d. In my visualization, I can see that d is the hypotenuse of another right triangle, formed by d and two sides of that square. Therefore, we can use the PT to find this smaller diagonal…
      • e² + e² = d²
      • (1)² + (1)² = d²
      • 2 = d²
      • d = √2
    • Now, I can again apply the PT to find the hypotenuse of the larger triangle…
      • e² + d² = D²
      • (1)² + (√2)² = D²
      • 1 + 2 = D²
      • 3 = D²
      • D = √3

    (Okay, now I know why I was thinking there might be a “cube root”…it’s the square root of 3.)

    Now, I’m sure mathematicians could show much more efficient ways to derive the formula, but that would risk missing the point.

    The point here is that I can build up that higher-level concept in the moment, based on more basic concepts like the PT. My goal is understanding, not speed.

    All right. The task now is to write code that represents this concept.

    There are various ways I could do this, but I’m going to write an R function that finds the diagonal of any cube I define.

    > # This function takes the edge of any cube...
    > # ...and outputs the "big diagonal"
    > cube_diag=function(edge=1) {
    + d=sqrt(2*edge^2)
    + D=sqrt(d^2+edge^2)
    + return(D)
    + }
    > # By default, it assumes a unit cube (edge = 1)
    > cube_diag()
    [1] 1.732051
    > # Note that this is equal to √3...
    > sqrt(3)
    [1] 1.732051
    > # We can also scale the cube up, say to edge = 2...
    > cube_diag(2)
    [1] 3.464102
    > # So D scales proportionally with the edges...
    > cube_diag(2) / cube_diag()
    [1] 2
    > cube_diag(3) / cube_diag()
    [1] 3

    Clearly, I could simply treat D = e⋅√3 as a memorized fact, which is faster and more efficient…

    > cube_diag_fast=function(edge=1) {edge*sqrt(3)}
    > # This gives the same results with less code...
    > cube_diag_fast(1:2)
    [1] 1.732051 3.464102

    But, again, that would be missing the point.

    If we just wanted the answer, we could have Googled it from the start. The purpose is to create and verify a digital representation of our understanding.


    Some Caveats…

    Note 1: I don’t mean that ALL code should be built up from scratch. That would be incredibly inefficient for getting work done on a daily basis.

    I do think you should build anything you use from scratch the first time or two that you use it. But once you understand something intuitively, it becomes far more efficient to automate.

    Understand, then automate.

    Note 2: A reasonable question is, “Exactly how far do we need to break things down?” For example, should a person be able to represent these concepts with pure 0s and 1s? (I hope not, because I can’t do that.)

    The answer is subjective, but in my view, anything that you already grasp intuitively and visually can be kept “whole” in the code you write.

    For example, if you already have an intuitive grasp of the concept of addition, then it’s fine to just use the sum() function (or whatever the equivalent function is in your programming language).

    Note 3: I like to dispense with fancy, technical terms when possible. Those terms are important and useful, but the more I use them, the higher the risk that I accidentally end up relying on a concept by name only, without necessarily grasping the underlying idea.

    So, yeah…that’s my justification for calling it the “big diagonal.”

    (I looked it up just now, and it’s actually called a space diagonal or similar.)


    2. Build the code from your own mental model.

    If you copy code from another source, or if you regurgitate an explanation you heard someone else give, this does NOT demonstrate independence, which is a core feature of how I define deep understanding (explained here).

    To be fair, I’m sure I originally learned this solution, or at least something similar, from someone else a long time ago (geometry class?). But if so, then I’d forgotten it.

    I solved it today by visualizing the cube and its diagonal in my mind, independently of any formula or diagram I’ve seen. (Of course, this did rely on my remembering terms like cube and diagonal.)

    And I wrote the code myself, in a way that made sense to me. That said, I should definitely check it against an LLM or another source to make sure I didn’t screw anything up…

    3. Verify the code using an independent method.

    When independent processes come to the same conclusion for any sufficiently complex task, the probability of the result being incorrect decreases.

    I looked online, and it turns out there is another version of the formula that I had forgotten about: D = √(e² + e² + e²).

    (This jogs my memory about how we can extend into as many dimensions as we want [like hypercubes], and the diagonal will always be calculated by adding another e² under the square root for every additional dimension. But that’s getting off-track.)

    Let’s use this “separate” (though algebraically equivalent) method to confirm our calculations…

    > # Alternative (equivalent) Formula
    > cube_diag2=function(edge=1) {sqrt(edge^2+edge^2+edge^2)}
    > # It gives the same results as our other formula...
    > cube_diag2(1:2)
    [1] 1.732051 3.464102

    Claude also suggested identifying coordinates for a cube in geometric space and using the dist() function (for the distance formula).

    > # Using the Distance Formula
    > max(dist(expand.grid(x=c(0,1),y=c(0,1),z=c(0,1))))
    [1] 1.732051
    > max(dist(expand.grid(x=c(0,2),y=c(0,2),z=c(0,2))))
    [1] 3.464102

    It all matches up.

    I guess we could also use measurements of an actual physical box to confirm as well, at least to an approximation. But I think I’ll pass on that…

    4. Try to break the code.

    The goal here is to ensure that your representation is falsifiable. You want to seek out disconfirming evidence (prove yourself wrong), and if you fail, that makes you more confident (though not certain) that you understand correctly.

    To do this, let’s input some silly “edge lengths”…

    > # Let's see what kinds of results we get for differing inputs...
    > cube_diag(0)
    [1] 0
    > cube_diag(-1)
    [1] 1.732051
    > cube_diag(1e200)
    [1] Inf

    Clearly, our code representation has some assumptions about what lengths we’re dealing with.

    1. The code works just fine with lengths of 0, even though there is no cube (real or imagined) that contains no space.
    2. The code also works for negative edge lengths, which doesn’t make sense for a cube.
    3. The code concludes that a very large cube has an infinitely long diagonal, which is incorrect.

    So, if we wanted to employ this function more broadly, we’d need to add more specifications to avoid potential incorrect output.

    But overall, I’d say the code accomplishes its purpose.

    This exercise makes me more confident that I do understand the concept of a diagonal of a cube, including how it relates to the other properties of the shape.

    And this mental representation in my mind exists independently of formulas found online, textbook definitions, or other people’s explanations.

    Up next:

    1. Demonstrating shallow understanding of the mean
    2. Demonstrating deeper understanding of the mean