Sample standard deviation estimates variability from a subset of observations rather than an entire population. It uses the squared differences from the mean, divides by one fewer than the number of observations, and takes the square root. section 9.2.2
Use these distinctions when reviewing a calculation or an AI-generated implementation:
- Choose the sample formula when the values represent limited information about a larger population; choose the population formula when they represent the complete group. section 9.2.2
- Treat the divisor n − 1 as a degrees-of-freedom choice, and verify the explanation rather than accepting a confident generated answer. section 9.2.2
- Check generated code against the formula: one attempt omitted the mean-centered differences, while another produced an incomplete calculation. section 9.2.2
Reviewing a generated Python calculation
For numbers [1, 2, 3, 4, 5], a local Llama 2 interaction generated code using n − 1 and described the result as sample standard deviation. A follow-up role prompt changed the response toward population standard deviation, but the resulting code still required correction. Compare the implementation with the formula and test the result before using it. section 9.2.2
Figure 9.1 The formula for the sample standard deviation
Formula reference for the sample standard deviation. section 9.2.2
