What you will be able to do
- Tell a normal distribution from a skewed one using mean, median, SKEW and the empirical rule, and pick a robust summary when outliers are present
- Explain what the central limit theorem says about sample means, and what it does not say about raw data
- Choose between a z-test and a t-test, and keep a z-score outlier flag separate from a hypothesis test
- Describe how bootstrapping builds a sampling distribution by resampling with replacement, and why Snowflake's SAMPLE clause on its own is not a bootstrap
- Build and interpret a confidence interval for a mean using the standard error, not the standard deviation
Key concept
Standard deviation vs. standard error — The standard deviation measures how spread out the individual values in a sample are. The standard error measures how much a statistic, such as the mean, would vary from one sample to the next. For the mean it equals the standard deviation divided by the square root of n. The central limit theorem, z and t tests, bootstrapping and confidence intervals all describe the standard error, not the raw spread.
1.Normal versus skewed distributions: mean, median and outliers
Every later idea in this lesson assumes you know the shape of your data. A normal distribution is symmetric and bell-shaped. Its mean, median and mode all sit at the centre, and how likely a value is depends only on how far it is from that centre. Snowflake's NORMAL data-generation function lets you see this. You give it a mean and a standard deviation, and many calls trace out the bell curve. The documentation states the empirical rule directly: with mean 0 and standard deviation 1, about 68.2% of values fall between -1 and +1. The rest of the rule, which comes from general statistics rather than this page, is that about 95% of values fall within 2 standard deviations and about 99.7% within 3.
SELECT normal(0, 1, random()) FROM table(generator(rowCount => 5));Checkpoint 1 of 9· Exam question
A data scientist studies session durations in a clickstream table. The population distribution is strongly right-skewed. She draws 2,000 random samples of 60 sessions each and computes every sample's mean. What does the histogram of those 2,000 means look like?
Correct answer: A — Approximately bell-shaped, centred near the population mean, with a spread close to the population standard deviation divided by the square root of 60.
- A. Correct. The central limit theorem says means of sufficiently large independent samples are approximately normal around the population mean with standard error sigma over root n.
- B. Incorrect. The expected value of a sample mean is the population mean, not the median, so the sampling distribution stays centred on the mean.
- C. Incorrect. Individual samples reflect the skew, but the distribution of their means loses most of it as n grows, which is the point of the theorem.
- D. Incorrect. Equal selection probability affects fairness of sampling, not the shape of the sampling distribution, which concentrates and becomes bell-shaped.
Real business columns are rarely that tidy. Income, basket size, session length and claim amounts are usually right-skewed: most values are modest, and a long tail of large values pulls the mean up. The quickest test for skew is to compare the mean and the median. If the mean is well above the median, the data is right-skewed. If it is well below, the data is left-skewed. Snowflake's SKEW aggregate gives you a number for it. It is about 0 for symmetric data, positive for a right tail and negative for a left tail, and it needs at least three non-NULL records. As a rough guide, an absolute value above about 1 means strong skew.
Skew matters because the mean and the standard deviation are both pulled by the tail. A few extreme values can move the mean a long way from a typical row, while the median barely moves. Snowflake's MEDIAN data metric function says this in its own description. The usual responses to a heavily skewed feature are to report the median or a percentile instead of the mean, to apply a log or similar transform before modelling, and to look at the outliers to decide whether they are errors or real, informative extremes. Simply deleting them is not the default.
Checkpoint 2 of 9· Check yourself
A salary column has a long right tail. You need one number for a dashboard that describes a typical employee. Which summary should you pick?
In a skewed column the tail drags the mean away from a typical row. The median depends only on the middle of the ordered values, so a few extreme salaries hardly move it.
“The median is more robust than the average for columns with skewed distributions.”Source: docs.snowflake.com
Checkpoint 3 of 9· Exam question
A fraud analyst reviews card transaction amounts in which a handful of corporate-card payments are extremely large. Select TWO statistics that stay stable when a few more extreme values are appended to the data.(Select 2)
Correct answers: B, E — Median, because it depends only on the middle rank position of the sorted amounts and ignores how large the biggest values are.; Interquartile range, because it is built from the 25th and 75th percentiles and so ignores the extreme tails at both ends.
- A. Incorrect. Standard deviation squares each deviation from the mean, which makes it even more sensitive to extreme values than the mean itself.
- B. Correct. The median is a rank-based statistic, so a few extreme amounts at the top barely move it.
- C. Incorrect. The mean uses the sum of all values, so one very large payment shifts it noticeably, especially in a modest-sized sample.
- D. Incorrect. The range is defined by the single smallest and largest values, so adding one extreme payment changes it immediately.
- E. Correct. The interquartile range uses only the 25th and 75th percentiles, so values beyond them have no influence on it.
2.The central limit theorem: why sample means behave
If so much real data is skewed, why do confidence intervals and z and t tests rely on the normal curve? The answer is the central limit theorem (CLT). Take repeated random samples of size n from almost any population with a finite variance and compute each sample's mean. As n grows, the distribution of those means gets closer and closer to a normal distribution. Its centre is the population mean and its spread is sigma divided by the square root of n. That spread is the standard error.
Note what the CLT is about: the distribution of a statistic, not the data. The raw column stays exactly as skewed as it was. Only the sampling distribution of the mean becomes approximately normal. A common rule of thumb is that n of about 30 is enough for moderately skewed data. Heavy tails need larger samples. The square root of n also tells you what more data buys: to halve the standard error you need four times as many rows.
You can watch the CLT happen in Snowflake. UNIFORM produces values that are flat across a range, which is clearly not a bell. Generate many rows, put them into groups of, say, 30, take AVG per group and plot those averages. The raw draws stay flat, but the group averages pile up in a bell around the midpoint.
SELECT UNIFORM(1, 10, RANDOM()) FROM TABLE(GENERATOR(ROWCOUNT => 5));Checkpoint 4 of 9· Check yourself
You generate a million values with UNIFORM(1, 10, RANDOM()), bucket them into groups of 50 and average each group. Which statement is correct?
UNIFORM draws evenly across its range however many rows you generate. The CLT applies to the averages, whose distribution approaches a normal curve with a spread of sigma divided by the square root of 50.
“Generates a uniformly-distributed pseudo-random number in the inclusive range [min, max].”Source: docs.snowflake.com
Sources4
3.Z and T tests: standardizing against the right yardstick
Because sample means are approximately normal, you can ask how surprising an observed mean is. Both tests standardize the same way: (observed statistic minus hypothesized value) divided by its standard error. The difference is where that standard error comes from.
A z-test assumes the population standard deviation is known, or the sample is large enough that the sample estimate is effectively exact. The statistic is compared with the standard normal, so the two-sided 5% cut-off is plus or minus 1.96. A t-test is the usual choice when the standard deviation is estimated from the same sample, which is what Snowflake's STDDEV returns. Estimating sigma adds uncertainty, so the t-distribution has heavier tails than the normal and depends on degrees of freedom (n minus 1 for a one-sample test). With 10 rows the two-sided 5% cut-off is about 2.26, not 1.96. As n grows, t approaches z. Common variants are the one-sample test (mean against a target), the two-sample test (A vs. B; Welch's version does not assume equal variances) and the paired test (before vs. after on the same units). In each case a small p-value means the observed difference would be unlikely if the null hypothesis were true. It does not measure how large or how important the effect is.
Don't confuse these tests with a z-score on a single row. Snowflake's OUTLIER_ZSCORE_COUNT and EXTREME_OUTLIER_ZSCORE_COUNT data metric functions standardize each value by the column mean and standard deviation and count values more than 3 or 4.5 standard deviations out. That is a data-quality screen on individual rows. It tests no hypothesis about a mean, and on a skewed column it will flag the legitimate long tail.
Checkpoint 5 of 9· Check yourself
SNOWFLAKE.CORE.OUTLIER_ZSCORE_COUNT on a sensor_reading column returns 57. What does that result establish?
The function only counts values whose distance from the mean is more than three standard deviations. It tests no hypothesis, and it cannot tell you whether those values are errors or a real tail.
“counts values whose absolute difference from the mean is more than 3 standard deviations (a Z-score greater than 3)”Source: docs.snowflake.com
4.Bootstrapping: a sampling distribution without a formula
Z and t tests work because there is a formula for the standard error of a mean. For a median, a ratio, a 90th percentile or a model metric, that formula is either messy or doesn't exist. Bootstrapping replaces the formula with computation. Treat your sample of n rows as a stand-in for the population. Draw n rows from it with replacement, so some rows appear twice and others not at all. Compute the statistic, and repeat this B times (often 1,000 to 10,000). The spread of the B results estimates the standard error. The 2.5th and 97.5th percentiles of those results give a 95% percentile confidence interval.
Bootstrapping needs no normality assumption, which suits skewed data. It cannot fix a sample that is unrepresentative or very small, though, because every resample only reuses the rows you already have. With replacement is essential: without it, each resample of size n would just be the original sample in a different order.
That coin flip is why Snowflake's SAMPLE / TABLESAMPLE clause is not a bootstrap by itself. BERNOULLI (ROW) sampling includes each row with probability p/100. A row is either in or out, so it can never appear twice, and the result is a random subset smaller than the table. That is useful for exploring a large table or building a train/validation split, but it is sampling without replacement. A real bootstrap needs draws with replacement: either random row positions generated with UNIFORM and RANDOM and joined back to the data, or, more commonly, a resampling loop in Python over data pulled from Snowflake. For reproducible results, fix the seed. SAMPLE accepts one only for SYSTEM/BLOCK sampling.
Checkpoint 6 of 9· Fill the gap
This documented query uses block-level sampling with a fixed seed. SEED is supported only for one family of sampling methods. Which keyword fills the blank?
SELECT * FROM testtable SAMPLE ? (3) SEED (82);REPEATABLE/SEED applies only to SYSTEM and BLOCK sampling. BERNOULLI and ROW are row-level methods and do not take a seed.
Source: docs.snowflake.comSources8
5.Confidence intervals: estimate plus or minus the standard error
Everything so far comes together here. A confidence interval is a point estimate plus or minus a critical value times the standard error. For a mean, that is the sample mean plus or minus z* (or t*) times s divided by the square root of n. For a 95% interval z* is 1.96, and t* is a little larger when n is small. In Snowflake, s is STDDEV and n is COUNT, so the half-width is 1.96 * STDDEV(x) / SQRT(COUNT(x)). If you leave out the division by the square root of n, you get an interval for where individual rows fall, not for where the mean is. It will be far too wide.
Checkpoint 7 of 9· Fill the gap
This documented example returns 4 for the values 6, 10 and 14. That is the sample standard deviation, which is the s you divide by the square root of n. Which function fills the blank?
CREATE TABLE t1 (c1 INTEGER);
INSERT INTO t1 (c1) VALUES
(6),
(10),
(14);
SELECT ? (c1) FROM t1;STDDEV (an alias of STDDEV_SAMP) returns the sample standard deviation, 4 here. STDDEV_POP divides by n rather than n-1 and returns about 3.27 for the same data.
Source: docs.snowflake.comInterpret the interval correctly. "95% confident" describes the procedure: if you repeated the sampling many times, about 95% of the intervals built this way would contain the true parameter. It does not mean 95% of the data lies inside the interval, and it does not mean there is a 95% probability that this particular interval contains the parameter. Three things control the width: higher confidence makes it wider, more spread (larger s) makes it wider, and a larger n makes it narrower in proportion to the square root of n. When no simple formula exists, a bootstrap percentile interval from the previous section answers the same question.
Snowflake reports confidence intervals itself when you monitor models. MODEL_MONITOR_PERFORMANCE_METRIC can return a CI_VALUE column holding a 95% interval as lower and upper bounds. It uses a method suited to each kind of metric: the Wilson interval for proportion-style classification metrics and the Wald interval for error metrics. A wide CI_VALUE on a small monitoring window is a warning not to over-read a change in the metric.
| Performance metrics | CI_VALUE method |
|---|---|
| CLASSIFICATION_ACCURACY, PRECISION, RECALL, F1_SCORE, MICRO_AVERAGE_PRECISION, MICRO_AVERAGE_RECALL | Wilson CI |
| MSE, RMSE, MAE | Wald CI |
| Other performance metrics | NULL |
Checkpoint 8 of 9· Check yourself
You query MODEL_MONITOR_PERFORMANCE_METRIC for RMSE on a regression model. What does the CI_VALUE column contain?
RMSE is one of the error metrics (MSE, RMSE, MAE) that get a Wald interval. Wilson intervals are used for the proportion-style classification metrics.
“Wilson CI for CLASSIFICATION_ACCURACY, PRECISION, RECALL, F1_SCORE, MICRO_AVERAGE_PRECISION, and MICRO_AVERAGE_RECALL; Wald CI for MSE, RMSE, and MAE.”Source: docs.snowflake.com
Checkpoint 9 of 9· Exam question
A retail data scientist runs a query on a Snowflake `ORDERS` table and gets `AVG(order_total)` = 182, `MEDIAN(order_total)` = 64 and `SKEW(order_total)` = 4.1. The dashboard needs one KPI describing a typical order. Which summary is the MOST appropriate?
Correct answer: D — Publish the median of 64, because a long right tail of very large orders pulls the mean upward while the median stays near the typical row.
- A. Incorrect. The mean does use every row, but with strong right skew it is dominated by the tail and overstates what a typical order looks like.
- B. Incorrect. A 99th percentile describes the extreme upper tail, not the typical order, so it answers a different question than the KPI requires.
- C. Incorrect. Z-score standardisation only shifts and rescales values; it does not change the shape or skewness of the distribution, so the mean stays inflated by outliers.
- D. Correct. A skewness of 4.1 means a heavy right tail; the few very large orders drag the mean far above the median, which is the better description of a typical order.
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.A 95% confidence interval for a mean is AVG(x) plus or minus 1.96 * STDDEV(x).Why is that wrong?
STDDEV measures how spread out individual values are. The interval for the mean uses the standard error, STDDEV(x) / SQRT(COUNT(x)). Without that division, the interval is wider by a factor of the square root of n.
Covered in Confidence intervals: estimate plus or minus the standard error
2.Running SAMPLE (n) repeatedly on a table is a bootstrap.Why is that wrong?
Bernoulli sampling flips a coin for each row, so it returns a subset without replacement and no row ever appears twice. A bootstrap draws n rows with replacement from the sample.
Covered in Bootstrapping: a sampling distribution without a formula
3.The mean is the best single summary of a typical value, whatever the column's shape.Why is that wrong?
In a skewed column the tail pulls the mean away from a typical row. The median, or a log transform before modelling, gives a more representative centre.
Covered in Normal versus skewed distributions: mean, median and outliers
4.A non-zero OUTLIER_ZSCORE_COUNT is a significance test showing that the data contains errors.Why is that wrong?
The function only counts values more than three standard deviations from the mean. It is a screen on individual rows, not a z-test of a hypothesis, and on skewed data it flags real tail values.
Covered in Z and T tests: standardizing against the right yardstick
Sources
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“approximately 68.2% of returned values from multiple calls will be between -1.0 and +1.0”
↩︎ Normal versus skewed distributions: mean, median and outliers - 2.
“Intuitively, skew describes how asymmetric the underlying distribution is.”
↩︎ Normal versus skewed distributions: mean, median and outliers“For inputs with fewer than three records, SKEW returns NULL.”
↩︎ Normal versus skewed distributions: mean, median and outliers - 3.
“The median is more robust than the average for columns with skewed distributions.”
↩︎ Normal versus skewed distributions: mean, median and outliers“The median is more robust than the average for columns with skewed distributions.”
↩︎ Exam trap 3 - 4.
“Generates a uniformly-distributed pseudo-random number in the inclusive range [min, max].”
↩︎ The central limit theorem: why sample means behave - 5.
“counts values whose absolute difference from the mean is more than 3 standard deviations (a Z-score greater than 3)”
↩︎ Z and T tests: standardizing against the right yardstick“counts values whose absolute difference from the mean is more than 3 standard deviations (a Z-score greater than 3)”
↩︎ Exam trap 4 - 6.
“This is a wider threshold than OUTLIER_ZSCORE_COUNT uses, so it flags only the most extreme values.”
↩︎ Z and T tests: standardizing against the right yardstick - 7.
“Returns the sample standard deviation (square root of sample variance) of non-NULL values.”
↩︎ Z and T tests: standardizing against the right yardstick“Returns the sample standard deviation (square root of sample variance) of non-NULL values.”
↩︎ Key concept“Returns the sample standard deviation (square root of sample variance) of non-NULL values.”
↩︎ Exam trap 1 - 8.
“Includes each row with a probability of p/100. This method is similar to flipping a weighted coin for each row.”
↩︎ Bootstrapping: a sampling distribution without a formula“This parameter only applies to SYSTEM and BLOCK sampling.”
↩︎ Bootstrapping: a sampling distribution without a formula“Includes each row with a probability of p/100. This method is similar to flipping a weighted coin for each row.”
↩︎ Exam trap 2“the number of rows returned isn’t exactly equal to (p/100)*n rows, but it is close to this value”
↩︎ Prediction - 9.
“95% confidence interval with lower and upper bounds.”
↩︎ Confidence intervals: estimate plus or minus the standard error“Wilson CI for CLASSIFICATION_ACCURACY, PRECISION, RECALL, F1_SCORE, MICRO_AVERAGE_PRECISION, and MICRO_AVERAGE_RECALL; Wald CI for MSE, RMSE, and MAE.”
↩︎ Checkpoint - 10.
“Note that the functions STDDEV and STDDEV_SAMP do not return the same result as STDDEV_POP.”
↩︎ Confidence intervals: estimate plus or minus the standard error