CertSafari
    Snowflake SnowPro Advanced: Data Scientist (DSA-C03)· Lessons

    Domain 1 · Lesson 4/16

    Statistics for data science: skew, sampling, z and t tests, confidence intervals

    Define statistical concepts for data science.

    20 min read
    4.25% of exam
    10 sources
    Published 20 Oct 2026
    Docs as of 18 Oct 2026

    What you will be able to do

    • Recognise a normal versus a right- or left-skewed distribution from SKEW, mean and median, and choose which centre to report
    • Pick summary statistics for centre and spread that hold steady when outliers arrive
    • Describe the sampling distribution of a mean using the central limit theorem and the standard error σ/√n
    • Choose between a z test and a t test, and say how degrees of freedom enter
    • Build a confidence interval for a mean, spot the missing-√n defect, and state what the confidence level promises
    • Bootstrap a sampling distribution by resampling with replacement when no formula exists

    Key concept

    Sampling distribution — A statistic such as a mean or median comes out different for every random sample, and the distribution of those values across repeated samples is its sampling distribution. Its spread, the standard error, is what z tests, t tests, confidence intervals and the bootstrap all measure.

    1.Normal and skewed distributions

    Every summary statistic assumes something about the shape of the column it describes, so shape comes first. A normal distribution is symmetric and bell-shaped. Values cluster around the mean and get rarer the further they are from it, and the standard deviation sets the width. The empirical rule says how much data sits in each band: about 68% within one standard deviation of the mean, about 95% within two, and about 99.7% within three. You can see the first band in Snowflake's NORMAL generator. With mean 0 and standard deviation 1, roughly 68.2% of the generated values land between -1 and +1.

    A skewed distribution has one tail longer than the other. Order totals, session durations, incomes and card transaction amounts usually look like this: most rows are modest, a few are huge, and none can go below zero. That shape is right-skewed, or positively skewed. Left skew, a long tail toward small values, is the mirror image.

    SKEW turns asymmetry into a number. A symmetric distribution scores 0, a positive value means a long right tail, and a negative value means a long left tail. Take a table aggr with an integer column k holding five values: 1, 2, 2, 2, 2. That single low value among the 2s makes SELECT SKEW(k) FROM aggr return -2.236069766, a strong left skew. The aggregate needs at least three non-NULL values and returns NULL below that. The SNOWFLAKE.CORE.SKEW data metric function uses the same sample formula, so you can track a column's skewness on a schedule.

    Tails can also be heavy without being lopsided. Excess kurtosis measures that, and a normal distribution has an excess kurtosis of about 0. A fast shape check for any numeric column puts three numbers side by side: AVG, MEDIAN and SKEW. A mean close to the median with skew near 0 suggests a roughly normal column. A mean well above the median with a large positive skew means a long right tail.

    Checkpoint 1 of 9· Check yourself

    You profile a numeric column in Snowflake and get AVG = 52.1, MEDIAN = 51.8 and SKEW = 0.03. What does this tell you about the column's shape?

    Sources1234

    2.Mean versus median when outliers are present

    The mean uses the size of every value, while the median uses only rank position. That one difference decides which to report. After the change, the four orders sum to 3,055, so the mean jumps to 763.75. The median is still 22.5, the average of the two middle values, because the middle ranks did not move. On a right-skewed column the long tail drags the mean up, and the median stays near the typical row.

    MEDIAN per group. Group 2 holds 10, 20, 25 and 30, an even count, so the median is the midpoint of the two centre valuessql
    SELECT k, MEDIAN(v)
      FROM aggr
      GROUP BY k
      ORDER BY k;
    
    +---+-----------+
    | K | MEDIAN(V) |
    |---+-----------|
    | 1 |  20.00000 |
    | 2 |  22.50000 |
    | 3 |      NULL |
    +---+-----------+

    For a KPI that describes a typical order on a skewed column, publish the median. The mean still has a job: mean times row count gives total revenue, so use it when the question is about totals. Averaging every row does not make the mean the right centre for a skewed column. A high percentile such as the 99th answers a third question, how large the biggest orders get. That describes the tail, not the typical customer.

    Standardising does not remove skew. A z-score subtracts the mean and divides by the standard deviation. Every value is shifted and rescaled by the same rule, so the sorted order and the shape stay the same, and so does SKEW. Use z-score standardisation as a feature step to put columns on a common scale, not to make a skewed column symmetric.

    Measures of spread split the same way. Standard deviation squares each distance from the mean, so a few extreme values dominate it. The range, MAX minus MIN, changes whenever a new value goes past the current maximum. The interquartile range (IQR), the 75th percentile minus the 25th, depends only on two rank positions, so extra values in the tails barely move it. SNOWFLAKE.CORE.OUTLIER_COUNT is built on quartiles. It computes Q1, the median and Q3, then counts the values outside fences drawn from them. It returns 0 for columns with fewer than 100 values. OUTLIER_ZSCORE_PERCENT instead flags values more than 3 standard deviations from the mean. Outliers inflate that mean and standard deviation themselves, so on a heavily skewed column the quartile-based count is the steadier detector.

    How common statistics react when a few very large values are added to a column
    StatisticSnowflake aggregateEffect of a few added extremes
    MeanAVGPulled toward the extremes, because every value's size counts
    MedianMEDIANStable, because it depends only on the middle rank
    Standard deviationSTDDEVInflated, because squared distances from the mean are dominated by the extremes
    RangeMAX minus MINChanges as soon as a new value goes past the current maximum
    Interquartile rangePERCENTILE_CONT or APPROX_PERCENTILE at 0.75 minus 0.25Stable, because it ignores both tails

    Checkpoint 2 of 9· Check yourself

    A right-skewed order_total column has a handful of enormous orders. A data-quality job has to flag the unusual rows reliably, without the extremes hiding themselves. Which system DMF fits best, and why?

    Checkpoint 3 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?

    Checkpoint 4 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)

    0 of 2 selected

    Sources5678

    3.Sampling distributions and the central limit theorem

    A statistic computed from a sample is a random quantity. Draw another random sample and the mean changes. In Snowflake, a SAMPLE query with no seed returns different rows each time it runs, and each run gives a different AVG. The distribution of a statistic over all possible samples of size n is its sampling distribution. Its standard deviation is the standard error.

    The central limit theorem describes that histogram. Take independent random samples of size n from a population with mean μ and standard deviation σ. The sample mean is approximately normal, centred on μ, with standard error σ/√n. This holds even when the population is skewed, as long as n is large enough. A common rule of thumb is n of 30 or more, and a very skewed population needs more. The centre is the population mean. For right-skewed durations that is above the population median, so the means pile up around μ, not around the middle-ranked session.

    In the clickstream case, each sample mean averages 60 durations. Its standard error is σ/√60, about σ/7.7, so the means sit far closer together than individual sessions do. A flat histogram would be a different distribution altogether: that is the uniform shape you get from raw RANDOM output, where results spread evenly over the possible range. Random selection gives every session an equal chance of being picked. It does not make the averages come out flat.

    The √n in the denominator matters in practice. Quadrupling the sample size halves the standard error. The standard deviation of the data itself does not shrink as you collect more rows. It describes individual values, and the standard error describes the estimate.

    Checkpoint 5 of 9· Check yourself

    A teammate expects the 2,000 sample means (60 sessions each) to form a flat histogram, because SAMPLE gives every session an equal chance of being picked. Which correction is right?

    Checkpoint 6 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?

    Sources91

    4.Z tests and t tests

    A hypothesis test asks whether an observed difference is bigger than sampling noise alone would produce. The starting assumption is the null hypothesis, the 'no difference' claim, for example that the true mean basket size equals the old value. To test it, standardise the difference against the sampling distribution: test statistic = (observed mean − hypothesised mean) / standard error. If the null hypothesis is true, this statistic follows a known reference distribution. A two-sided test counts a difference in either direction, too high or too low, as evidence against the null. For a z statistic the cutoff is ±1.96, because only 5% of a standard normal distribution falls outside that range. It is the sharper version of the empirical rule's roughly 95% within two standard deviations. A two-sided z statistic beyond ±1.96 is therefore significant at the 5% level: a gap that large would turn up less than 5% of the time if the null were true.

    The choice between z and t depends on where σ comes from. Use a z test when the population standard deviation σ is known, or when n is large enough that the sample estimate is effectively exact. The standard error is then σ/√n and the reference is the standard normal. Use a t test when σ is estimated by the sample standard deviation s from a small sample. The standard error becomes s/√n and the reference is the t distribution with n − 1 degrees of freedom. The t distribution has heavier tails to allow for the extra uncertainty in s. For a two-sided 5% test, the critical value is about 2.09 with 19 degrees of freedom and 1.96 for z. As n grows, the t distribution converges to the normal.

    Snowflake gives you both versions of the spread. STDDEV, an alias of STDDEV_SAMP, returns the sample standard deviation, which is the s in a t statistic. STDDEV_POP applies the population formula. With a single record, STDDEV returns NULL. One value says nothing about spread, and it leaves zero degrees of freedom.

    Choosing between a z test and a t test for a mean
    TestStandard errorWhen it appliesReference distribution
    z testσ/√n with σ knownPopulation σ known, or n largeStandard normal
    t tests/√n with s from STDDEVσ estimated from a small samplet with n − 1 degrees of freedom

    Comparing two groups, such as basket size under an old and a new checkout, uses the same template. The observed value is the difference in means. Its standard error combines both groups: √(s₁²/n₁ + s₂²/n₂).

    Checkpoint 7 of 9· Check yourself

    A two-sided z test on a column's mean gives a test statistic of 2.5. How should you read that number?

    Sources10

    5.Confidence intervals

    A confidence interval is the estimate plus or minus a critical value times the standard error. For a mean with large n, a 95% interval is x̄ ± 1.96 × s/√n. With a small sample, swap 1.96 for the t critical value at n − 1 degrees of freedom.

    The most common defect is leaving out √n. STDDEV measures how much individual baskets vary, so mean ± 1.96 × STDDEV marks out where single baskets fall, not how precisely the mean is known. The fix is to divide by SQRT(COUNT(basket)) before multiplying by the critical value. The interval then narrows as the table grows, as an estimate's uncertainty should.

    A confidence level is a promise about the procedure, not about one interval. If you repeated the sampling many times and built a 95% interval each time, about 95% of those intervals would contain the true mean. A single computed interval either contains it or does not, so it is wrong to say there is a 95% probability that μ lies in this particular range. The interval also does not claim to hold 95% of the data. It does not protect against a biased, non-random sample either. Two settings control the width. A higher confidence level means a bigger critical value and a wider interval. A larger n shrinks the interval in proportion to √n.

    Intervals and tests give the same answer. A 95% interval leaves out a hypothesised value exactly when a two-sided test at the 5% level rejects that value.

    Checkpoint 8 of 9· Check yourself

    From 10,000 rows of session durations, an analyst reports a 95% confidence interval for the mean session length. A colleague then says: "So 95% of our sessions last somewhere in this range." Which response is right?

    Sources10

    6.Bootstrapping a sampling distribution

    The central limit theorem gives a standard error formula for the mean, but many statistics have no simple formula. Examples include the median, a 90th percentile, a ratio of two sums, and a difference in medians between two groups. Bootstrapping gets their sampling distribution by treating the observed sample as a stand-in for the population:

    The procedure, for a sample of n rows:

    1. Draw n rows from the observed sample with replacement, so the same row can appear more than once.
    2. Compute the statistic, for example the median order total, on that resample.
    3. Repeat steps 1 and 2 many times, typically 1,000 to 10,000.
    4. The standard deviation of the resampled statistics is the bootstrap standard error. Their 2.5th and 97.5th percentiles form a 95% percentile interval.

    Replacement is what makes this work. Draw n rows from n without replacement and you get the original sample in a new order, so the statistic is identical on every resample and shows no variability. Snowflake's SAMPLE with Bernoulli sampling flips a weighted coin for each row, so each row appears at most once. That is subsampling, not a bootstrap resample. A bootstrap needs a draw that can pick the same row again.

    The bootstrap only reflects the variability in the data you actually collected. A tiny sample, or one drawn in a biased way, produces an interval that looks precise but is centred in the wrong place.

    Checkpoint 9 of 9· Put it in order

    Arrange the steps that produce a bootstrap standard error and 95% percentile interval for the median order total of a sample of n rows

    1. 1.Draw n rows from the observed sample with replacement, so the same row can come up more than once
    2. 2.Take the standard deviation of the resampled medians as the bootstrap standard error, and their 2.5th and 97.5th percentiles as the 95% interval
    3. 3.Compute the median order total on that resample
    4. 4.Repeat the draw and the median calculation many times, typically 1,000 to 10,000

    Sources9

    Sources

    (10)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “approximately 68.2% of returned values from multiple calls will be between -1.0 and +1.0 (i.e. within one standard deviation of the mean)”
      ↩︎ Normal and skewed distributions
      “Values closer to the specified mean are more likely to occur than values far from the mean.”
      ↩︎ Normal and skewed distributions
      “When RANDOM is called a large number of times, the results are more or less evenly distributed over the range of possible values.”
      ↩︎ Sampling distributions and the central limit theorem
      “The accumulated results of a large number of repeated calls approximate a normal distribution.”
      ↩︎ Exam trap 3
      “The accumulated results of a large number of repeated calls approximate a normal distribution.”
      ↩︎ Prediction
      “approximately 68.2% of returned values from multiple calls will be between -1.0 and +1.0 (i.e. within one standard deviation of the mean)”
      ↩︎ Checkpoint
    2. 2.
      “Intuitively, skew describes how asymmetric the underlying distribution is.”
      ↩︎ Normal and skewed distributions
      “For inputs with fewer than three records, SKEW returns NULL.”
      ↩︎ Normal and skewed distributions
    3. 3.
      “A symmetric distribution has a skewness of 0.”
      ↩︎ Normal and skewed distributions
      “The function uses the same sample formula as the SKEW aggregate function. A symmetric distribution has a skewness of 0.”
      ↩︎ Checkpoint
    4. 4.
      “A normal distribution has an excess kurtosis of about 0.”
      ↩︎ Normal and skewed distributions
    5. 5.
      “The median is more robust than the average for columns with skewed distributions.”
      ↩︎ Mean versus median when outliers are present
      “The median is more robust than the average for columns with skewed distributions.”
      ↩︎ Exam trap 1
    6. 6.
      “If the number of non-NULL values is an even number, this returns a value equal to the average of the two center values.”
      ↩︎ Mean versus median when outliers are present
    7. 7.
      “The function computes the first, second (median), and third quartiles (Q1, Q2, Q3) of the non-NULL, non-NaN values”
      ↩︎ Mean versus median when outliers are present
      “The function returns 0 if the column has fewer than 100 non-NULL, non-NaN values”
      ↩︎ Mean versus median when outliers are present
      “The function computes the first, second (median), and third quartiles (Q1, Q2, Q3) of the non-NULL, non-NaN values, then counts values”
      ↩︎ Checkpoint
      “The function computes the first, second (median), and third quartiles (Q1, Q2, Q3) of the non-NULL, non-NaN values”
      ↩︎ Checkpoint
    8. 8.
      “measures the percentage of values whose absolute difference from the mean is more than 3 standard deviations (a Z-score greater than 3)”
      ↩︎ Mean versus median when outliers are present
      “measures the percentage of values whose absolute difference from the mean is more than 3 standard deviations (a Z-score greater than 3)”
      ↩︎ Exam trap 2
      “absolute difference from the mean is more than 3 standard deviations (a Z-score greater than 3)”
      ↩︎ Checkpoint
    9. 9.
      “If no seed is specified, SAMPLE generates different results when the same query is repeated.”
      ↩︎ Sampling distributions and the central limit theorem
      “Includes each row with a probability of p/100.”
      ↩︎ Bootstrapping a sampling distribution
      “This method is similar to flipping a weighted coin for each row.”
      ↩︎ Bootstrapping a sampling distribution
      “If no seed is specified, SAMPLE generates different results when the same query is repeated.”
      ↩︎ Key concept
    10. 10.
      “Returns the sample standard deviation (square root of sample variance) of non-NULL values.”
      ↩︎ Z tests and t tests
      “See also STDDEV_POP, which returns the population standard deviation (square root of variance).”
      ↩︎ Z tests and t tests
      “For single-record inputs, STDDEV and STDDEV_SAMP both return NULL.”
      ↩︎ Z tests and t tests
      “Returns the sample standard deviation (square root of sample variance) of non-NULL values.”
      ↩︎ Confidence intervals
      “Returns the sample standard deviation (square root of sample variance) of non-NULL values.”
      ↩︎ Exam trap 4

    Ready to test yourself?

    Practise the 16 questions on this subdomain.

    Spotted a mistake, or was something unclear? Tell us.