1. Home
  2. Explore
  3. Statistics
  4. Statistics for Data Science

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Statistics for Data Science

Speaker 1Speaker 2

Statistics for Data Science

23:10
0:00-23:10
  1. Michael

    Welcome to our introduction to statistics for data science and machine learning. The central idea is that statistics is not a crystal ball: it gives us disciplined ways to describe data, reason about uncertainty, and make decisions. We’ll move from the difference between statistical and machine-learning thinking to descriptive analysis, probability, and a few important probability distributions.

  2. Maria

    Let’s begin with that difference. In a traditional statistical approach, you usually start with a question, then decide what data you need to answer it. In a common machine-learning approach, you may start with a large collection of data and ask what patterns or useful information it contains.

  3. Michael

    That contrast matters in real work. A statistician might ask, “What do you want to know?” while a business leader might say, “I hired you to tell me what this data means.” The practical challenge is to connect the two: understand the business problem, ask a useful question, and find or collect appropriate data.

  4. Maria

    Take a watch company whose sales are falling. You could examine sales by year, region, customer age, or product type, and ask which customer groups are buying less, how quickly sales are declining, or where most sales come from. Those questions shape what data you inspect and what comparisons you make.

  5. Michael

    A useful analytics framework has three stages: descriptive, predictive, and prescriptive. Descriptive analysis tells us what has happened or what the data looks like. Predictive analysis estimates what may happen, or what might happen under a proposed change. Prescriptive analysis recommends what to do, while accounting for goals and constraints.

  6. Maria

    For the watch company, a descriptive question is, “Where are sales falling?” A predictive question might be, “If we lower prices, how might sales change?” A prescriptive question is harder: “What price and product strategy should we choose to increase sales while still making a profit?” It’s not enough to maximize sales if the resulting costs make the business unprofitable.

  7. Michael

    Prescriptions can involve many constraints. A doctor may use measurements and medical knowledge to recommend an action while trying to help a patient and avoid unnecessary harm. An autonomous car may need to avoid a person crossing the road without stopping so abruptly that it creates another danger. Data can inform those decisions, but it does not contain every relevant goal or rule.

  8. Maria

    Even description is more than simply printing numbers. A doctor might have an enormous amount of information available but must decide which measurements are relevant to the symptoms. Likewise, an analyst has to choose what to examine and how to summarize it. That choice takes judgment and context.

  9. Michael

    That brings us to randomness and variation. Blood measurements can differ across time or between samples because the body is continually changing. The same general idea applies to other measurements: a reading can depend on when and how it was taken. One observation may not represent the underlying situation very well.

  10. Maria

    Suppose a doctor uses 140 as a made-up threshold for a measurement. A reading of 135 is below it, but it is close; a reading of 120 is farther away. And if repeated readings are 135, 130, 157, and 128, a single number hides important variation. The analyst has to ask whether the threshold should be treated as a sharp boundary, or whether more measurements are needed.

  11. Michael

    That’s why descriptive summaries often include ranges, not just one value. But to go from describing a sample to saying how confident we should be about a larger group, we need probability. Statistics uses probability to express uncertainty and to reason from observed data toward populations or future observations.

  12. Maria

    Let’s make that concrete with a business example. Imagine a market research team studying customers who purchased treadmills at one store over the last three months. The goal is to understand customer profiles across different product lines. The dataset might include product, gender, age, education, relationship status, household income, planned weekly use, expected weekly distance, and a self-rated fitness score.

  13. Michael

    Those variables aren’t all the same kind of data. Age, income, and distance are numerical measurements. Gender, relationship status, and product line are categorical labels. A fitness score from one to five is numerical in appearance, but it is also ordinal: the values have an order, from poorer to better fitness, without necessarily representing equal-sized steps.

  14. Maria

    That distinction matters because different summaries make sense for different data. A mean of household income is meaningful, but a mean of product names is not. And a postcode may be stored as a number, yet it is a category—you can’t meaningfully average two postcodes to find a location between them.

  15. Michael

    In a data frame, software may infer whether a column is numeric or categorical, but it can mislead you if the values are encoded unusually. Analysts also need to know what each variable means, not just how it is stored. That description of the data is often called metadata or a data dictionary.

  16. Maria

    Let’s start summarizing numerical data with location. The mean is the sum of all observations divided by the number of observations. The median is the middle observation after sorting the data; if there are an even number of observations, it’s the average of the two middle ones.

  17. Michael

    The mean and median answer different questions. The mean is like the balance point of the values, while the median divides the observations into two halves. A very large outlier can pull the mean substantially, but the median usually changes little.

  18. Maria

    For example, if you calculate the average income of a small group and an exceptionally wealthy person joins the group, the mean rises sharply. The income of the typical person may barely change, so the median can better represent that typical person. Which one is useful depends on the question.

  19. Michael

    A standard summary of a numerical variable is the five-number summary: minimum, first quartile, median, third quartile, and maximum. The first quartile is the point at or below which roughly 25 percent of observations fall; the median marks 50 percent; the third quartile marks 75 percent.

  20. Maria

    The gap between the third and first quartiles is the interquartile range, or IQR. It describes the spread of the middle half of the data. The full range, maximum minus minimum, describes the distance from the smallest to the largest value, but it can be strongly affected by extreme observations.

  21. Michael

    A box plot displays that five-number summary visually. The box runs from the first to the third quartile, with a line at the median. In the convention discussed in the material, whiskers extend to the most extreme values within 1.5 times the IQR of the box; observations beyond that are plotted separately as potential outliers.

  22. Maria

    Potential outliers aren’t automatically mistakes. They are observations that stand apart under that plotting rule, and they may be real. They’re worth investigating because unusual values can affect summaries and models, especially summaries that respond strongly to distance from the mean.

  23. Michael

    That leads to measures of variation. The sample standard deviation summarizes how spread out observations are around the mean. In broad terms, calculate the deviations from the mean, square them so positive and negative differences don’t cancel, average those squared deviations using the sample adjustment of n minus one, and take the square root to return to the original units.

  24. Maria

    Squaring makes large deviations count especially heavily. A more outlier-resistant alternative is the mean absolute deviation, which averages absolute distances rather than squared distances. The IQR is another robust summary of spread because it focuses on the middle half of the observations.

  25. Michael

    Skewness is another feature to notice. A distribution is right-skewed when it stretches farther toward larger values, and left-skewed when it stretches farther toward smaller values. A mean larger than a median can be a clue to right skew, because some large values have pulled the balance point to the right.

  26. Maria

    That’s why the mean and median are informative together. In a roughly symmetric distribution, they tend to be similar. If they differ, that may signal skew or influential outliers—but you should inspect the data rather than treating the difference as a complete diagnosis.

  27. Michael

    Visualizations help. A histogram groups numerical values into bins and shows how many observations fall in each bin. It gives a quick sense of the distribution’s shape, center, spread, and possible skew. The exact appearance can change with the bin choices, so a histogram is best treated as a visual summary, not a precise record of every value.

  28. Maria

    For categorical data, a frequency table or cross-tabulation is often more appropriate. A cross-tab might count how many men and women purchased each treadmill product, or how product choices vary by relationship status. Those counts describe the sample; they do not by themselves establish whether the differences are statistically meaningful.

  29. Michael

    A pair plot gives another visual overview by placing variables against one another. Its diagonal panels often show each numerical variable’s histogram, while the off-diagonal panels show scatter plots for pairs of variables. The two panels for a pair contain the same relationship with the axes swapped.

  30. Maria

    Pair plots are useful for spotting patterns, but categorical columns may be left out or handled differently by plotting software. And a self-rated one-to-five score should be interpreted with its ordinal meaning in mind, even if a program stores it as a number.

  31. Michael

    Here’s a subtle step beyond describing the sample: we often care about a broader population. A company may have data on customers who already bought a treadmill, but wants to understand future customers. The observed people are a sample; the population is the wider group we want to learn about.

  32. Maria

    A histogram describes the particular sample. A smoothed density curve can help visualize a broader underlying distribution that we’re trying to estimate. It does not reveal that population distribution with certainty; it’s an estimate based on the observations and assumptions about how the sample relates to the population.

  33. Michael

    That is the heart of statistical inference: separate patterns that may persist from the random variation that comes from observing only a sample. If a new sample comes from the same underlying population, it won’t match the old one exactly, but we hope it will show a similar overall pattern.

  34. Maria

    The size and variability of a sample affect how uncertain an estimate is. More observations generally make an estimate more stable, while highly variable data makes it harder to pin down the center. How certain we want to be also matters: a more cautious interval generally has to be wider.

  35. Michael

    Now let’s compare two variables. Covariance summarizes whether they tend to vary together. For each observation, compare its X value with the mean of X and its Y value with the mean of Y; multiply those deviations and average them, using n minus one for a sample covariance.

  36. Maria

    If the covariance is positive, observations above the mean of X tend to occur with observations above the mean of Y, and below with below. If it’s negative, high values of one tend to accompany low values of the other. But the size of covariance depends on the units, so it’s difficult to compare across variables measured on different scales.

  37. Michael

    Correlation addresses that scale problem by dividing covariance by the standard deviations of the two variables. The result is between minus one and plus one. A value near plus one indicates a strong positive linear relationship; a value near minus one indicates a strong negative linear relationship; a value near zero indicates little linear association.

  38. Maria

    A correlation near zero does not prove there is no relationship. A curved relationship can be strong but still have a low linear correlation. And correlation is symmetric: the correlation of X with Y is the same as the correlation of Y with X. It does not tell us that one variable causes the other.

  39. Michael

    A correlation matrix shows correlations for many numerical variables, and a heat map can make the pattern easier to scan using colors. But even a striking correlation is a description of observed data. We still need context and further analysis to understand what it means beyond that sample.

  40. Maria

    When we want to summarize how one variable relates to several others, a linear regression equation is one option. It might look like Y equals an intercept plus a coefficient times X one plus another coefficient times X two. The coefficients describe how the fitted equation changes with its inputs, holding the other included variables fixed.

  41. Michael

    In a simple linear regression, the software chooses the line that minimizes the sum of squared differences between observed Y values and the line’s predictions. Squaring prevents positive and negative errors from canceling and makes large errors count more. The intercept is where the line crosses the axis, though it may have no practical meaning if zero is outside the relevant data range.

  42. Maria

    Regression can be used descriptively, predictively, or prescriptively, but those are different uses. A fitted relationship does not automatically imply cause and effect. A prediction for a new case also requires us to ask whether the model generalizes, and a prescription requires additional assumptions about what outcomes are desirable and what constraints apply.

  43. Michael

    Probability gives us a language for uncertainty. An experiment is a process that produces an outcome; an event is a specified outcome or set of outcomes; and the sample space is the set of all possible outcomes. Sometimes we run the experiment ourselves, as in an A/B test, and sometimes we observe events generated by others.

  44. Maria

    For three parts, each either good or defective, the sample space has eight outcomes: each part can be good or defective independently of how we label the other two. That detailed sample space lets us identify outcomes such as “at least two parts are defective.” If we record only the number of defects, we get the possible counts zero through three, but lose information about which parts failed.

  45. Michael

    A probability is a number from zero to one: zero means impossible and one means certain. For two mutually exclusive events, which cannot happen at the same time, the probability of either is the sum of their probabilities. In general, for A or B, add the two probabilities and subtract the probability that both occur, so the overlap isn’t counted twice.

  46. Maria

    Independence is different from mutual exclusivity. Two events are independent when knowing that one occurred does not change the probability of the other. If independent events both have to occur, multiply their probabilities. A part’s defect status might be modeled as independent of another part’s, but that is an assumption, not a universal fact.

  47. Michael

    Conditional probability asks for the chance of one event given that another has occurred. The probability of A given B is the probability that both A and B occur divided by the probability of B. In everyday terms, we restrict attention to cases where B is true, then ask what fraction of those cases also have A.

  48. Maria

    Imagine a survey of 200 families. Eighty have annual income above a threshold, and 42 of those families bought a car. The chance of a car purchase among the higher-income families is 42 divided by 80. That differs from the overall purchase rate, which uses all 200 families as the denominator.

  49. Michael

    Bayes’ theorem reverses a conditional probability. It lets us calculate the chance of a hypothesis given evidence by using the chance of that evidence under the hypothesis, along with the prior probability of the hypothesis. This is useful when evidence is easier to characterize for each group than the final question we want to answer.

  50. Maria

    For a simple spam example, suppose 30 percent of emails are spam. Suppose the word “congratulations” appears in 75 percent of spam emails and 35 percent of non-spam emails. Seeing that word raises the estimated probability that an email is spam from 30 percent to about 47 percent—not to 75 percent, because the word also appears in many non-spam emails.

  51. Michael

    Medical testing shows why the prior probability matters. Suppose one percent of a population has a condition, and a test is 95 percent sensitive and 95 percent specific. Among 100,000 people, about 1,000 have the condition; roughly 950 of them test positive. But among the 99,000 without it, about five percent—around 4,950—also test positive.

  52. Maria

    So among all the positive results, only about 950 of roughly 5,900 come from people with the condition. The chance of having the condition after a positive result is therefore about 16 percent in this example, not 95 percent. When a condition is rare, even a fairly accurate test can produce many false positives relative to true positives.

  53. Michael

    A second, independent test can provide additional evidence. Independence matters: repeating the same procedure with the same source of error may not reduce the false-positive problem as much as a genuinely independent test. The same reasoning applies to fraud detection and other settings where a positive signal is rare.

  54. Maria

    Now for the binomial distribution. It models the number of successes in a fixed number of independent trials, when each trial has the same probability p of success. The probability of exactly x successes in n trials is “n choose x” times p to the x power times one minus p to the n minus x power.

  55. Michael

    The combination term counts how many arrangements can place those x successes among the n trials. For three parts, each defective with probability 0.1, the chance of exactly two defects is three choose two, times 0.1 squared, times 0.9. That gives 0.027, or 2.7 percent.

  56. Maria

    The same structure works for a business question. If each of seven customers independently has a 60 percent chance of paying on time, the number who pay on time can be zero through seven. The probability of exactly two is seven choose two times 0.6 squared times 0.4 to the fifth power.

  57. Michael

    The expected number of successes in a binomial model is n times p. In that example, the expected number is 7 times 0.6, or 4.2. That doesn’t mean exactly 4.2 people pay; it’s the average over many comparable groups. The distribution tells us how likely each whole-number count is.

  58. Maria

    That can inform staffing or capacity. If a sales team expects a certain number of conversions but can complete only a limited number of follow-ups, the probability of exceeding that capacity matters. The model can help explore what happens if the conversion probability or team size changes.

  59. Michael

    The Poisson distribution is useful for counts when there isn’t a fixed number of trials in the same way. It models events occurring at an average rate, such as arrivals or defects in a specified interval. Its parameter, lambda, is the average count over that interval.

  60. Maria

    If a bank averages six customer arrivals every two minutes, the corresponding average is three arrivals per minute. A Poisson model can then estimate the probability of exactly four arrivals in a minute, or of more than a chosen number. The time interval matters: the rate has to match the interval in the question.

  61. Michael

    Finally, consider the normal distribution: a symmetric, bell-shaped model described by a mean and a standard deviation. If a distribution is normal, about 68 percent of observations lie within one standard deviation of the mean, about 95 percent within two, and about 99.7 percent within three.

  62. Maria

    Those percentages make the standard deviation easier to interpret, but they rely on the normal model. For example, if package weights are modeled as normal with mean 295 grams and standard deviation 25 grams, a weight of 280 grams is 0.6 standard deviations below the mean. The probability of a weight below 280 grams is about 27 percent.

  63. Michael

    For the same model, 350 grams is 2.2 standard deviations above the mean, so the chance of a package weighing more than 350 grams is about 1.4 percent. The chance of weighing between 260 and 340 grams is about 88 percent. Those are probability calculations based on the assumed mean, standard deviation, and normal shape.

  64. Maria

    That last point is essential: a probability model can answer a practical question even when we aren’t directly counting a particular set of observations, but it depends on assumptions and on where its parameters came from. A mean and standard deviation might be estimated from data, taken from another source, or specified for a planning exercise—and each choice carries uncertainty.

  65. Michael

    The normal distribution is common partly because averages and totals of many contributing factors can often be approximated by a normal model, a connection captured by the central limit theorem. But not every dataset is normally distributed, and other distributions may be more appropriate for particular situations. The model should fit the problem, not just be convenient.

  66. Maria

    So the big picture is: ask a clear question, identify the data and its type, describe its center and variation, and distinguish what the sample shows from what we hope to infer about a broader population. Then use probability and an appropriate model to quantify uncertainty—and remember that predictions and recommendations require more than a descriptive statistic.

  67. Michael

    Exactly. Statistics isn’t magic, and it doesn’t eliminate uncertainty. It gives us tools to make uncertainty visible, test assumptions, and reason carefully from data toward decisions.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent