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

Statistics and Probability for Data Analysis

1. Statistics, machine learning, and analytical questions

Statistics and machine learning both use data, but they often begin from different starting points.

  • Statistical thinking is often problem-first: identify a question, formulate a problem, and then collect or select data that can help answer it. The analyst must clarify what decision or conclusion the data is intended to support.

  • Machine-learning thinking is often data-first: begin with available data and investigate what patterns or relationships it may contain. The analyst may need to discover which questions the data can help answer.

In practice, both approaches are necessary. Data alone does not determine what an organization should investigate. At the same time, a clearly stated question cannot be answered without relevant data. A useful analysis therefore connects the question, the data, and the decision that will follow.

For example, a company whose watch sales are falling might investigate:

  • Which customer groups account for the largest share of sales?

  • For which customer groups are sales declining most rapidly?

  • Do sales differ by region, age group, or product type?

  • When did the decline begin, and how quickly is it progressing?

These questions shape which data should be collected and how it should be organized. Comparing sales by region or customer group may reveal where the decline is concentrated, but it does not by itself explain why it is happening. Questions about competitors or changing consumer preferences may require information outside the company’s own records.

Effective analysis begins by defining the question the evidence is meant to address; the same dataset can support different analyses depending on the question.


2. Descriptive, predictive, and prescriptive analytics

Many analytical problems can be organized into three connected levels: descriptive, predictive, and prescriptive.

Descriptive analytics

Descriptive analytics summarizes what has happened or what is present in the data. It aims to locate patterns, differences, and variation without necessarily explaining their causes or predicting future outcomes.

A watch company might use descriptive analysis to identify:

  • Which regions have the most sales

  • Which customer segments have declining sales

  • How sales differ across product lines

  • How customer characteristics are distributed

Description requires judgment. A dataset can contain many variables, but not all are useful for every question. Selecting an appropriate measurement, summary, or visual display is itself an analytical skill.

Predictive analytics

Predictive analytics uses patterns in existing data to estimate an unknown or future outcome. It may ask:

  • What is likely to happen next?

  • How might sales change if prices change?

  • Which customers are likely to buy a product?

  • What outcome is likely for a new case with given characteristics?

For example, a company may model the relationship between watch prices and sales to estimate how sales could respond to a price reduction. Such estimates are predictions, not guarantees.

Prescriptive analytics

Prescriptive analytics considers what action should be taken to achieve a goal while respecting relevant constraints. It builds on descriptions and predictions but also involves objectives, trade-offs, domain knowledge, and decision rules.

A business may want to increase sales while preserving profit, maintaining cash flow, repaying loans, and retaining employees. These requirements can conflict. Raising sales by cutting prices may reduce profit; increasing prices may improve margin but reduce demand.

An autonomous vehicle faces similar trade-offs. It may need to avoid a pedestrian, obey traffic rules, avoid sudden braking that could injure passengers, and avoid creating a different hazard while steering away. A prescription is therefore not simply “choose the action that improves one measure”; it must account for several constraints and consequences.

How the three levels differ

Consider a cricket example:

  • Descriptive: How many centuries has a player scored?

  • Predictive: How many centuries might the player score in a future tournament?

  • Prescriptive: What could be changed to increase the player’s chances of scoring more centuries?

The first summarizes data, the second estimates an outcome, and the third considers interventions.


3. Data, measurements, and variable types

A variable is a characteristic recorded for each observation, such as age, income, gender, product type, or weekly treadmill use. Before summarizing or modeling data, an analyst must understand what each variable represents and what kind of values it can take.

Numerical variables

Numerical variables represent quantities for which arithmetic is meaningful.

  • Discrete numerical variables take countable values, such as the number of purchases or the number of visits.

  • Continuous numerical variables can take values across a range, such as weight, distance, or time.

Numerical values may still need careful interpretation. A recorded value can be a measurement, an estimate, or a respondent’s expectation. For example, “the number of times a customer plans to use a treadmill each week” is a recorded value, but it describes an intention rather than a guaranteed future behavior.

Categorical variables

Categorical variables identify groups or labels rather than quantities.

  • Nominal variables are categories without a meaningful order, such as product type, marital status, or gender.

  • Ordinal variables have a meaningful order, but the gaps between categories are not necessarily equal. A self-rated fitness scale from poor to excellent is an example.

A software system may store an ordinal rating as numbers, but that does not automatically make it a continuous measurement. A rating of 444 is higher than a rating of 333, but the difference may not represent the same amount of change as the difference between 222 and 111.

The reverse issue also occurs: a value may look numerical but function as a category. A postal or ZIP code is a label for a location, not a quantity. Adding two postal codes or calculating their average has no meaningful interpretation.

Data frames and metadata

A data frame is a structured collection of observations and variables. Software commonly records variable types, such as numeric or categorical, and can summarize the structure of a dataset.

A structural summary is not the same as a statistical summary. It may report the number of records, variable types, missing values, or storage formats, but it does not explain what the values mean.

For reliable reuse, data should be accompanied by metadata, or information about the data. A useful data dictionary describes:

  • What each variable represents

  • Its units and possible values

  • Whether it is numeric, nominal, or ordinal

  • How missing values are represented

  • Any transformations or categories applied to it

This information matters because analytical methods make assumptions about their inputs. For example, a numerical regression method and a categorical classification method do not necessarily accept or interpret variables in the same way.


4. Random variation and the need for repeated measurements

Measurements are often not perfectly stable. A person’s blood composition changes with time, food, exercise, and the body’s current needs. The temperature of a vehicle’s oil changes depending on whether and how the vehicle has been running. These quantities can be treated as random variables: their observed values vary across measurements or circumstances.

A single measurement may therefore provide an incomplete picture. If a reading is close to a decision threshold, it may be unclear whether the result reflects a persistent condition or ordinary variation.

For instance, suppose a decision is made around a threshold of 140140140. A reading of 135135135 is below the threshold, but it is close enough that another reading might lead to a different conclusion. Repeated measurements can reveal whether values are consistently near the threshold or fluctuate widely around it.

Two broad strategies can address a borderline measurement:

  1. Refine the decision boundary. Instead of treating the threshold as perfectly sharp, use a range or graded decision rule. This is related to fuzzy logic, where categories need not have an all-or-nothing boundary.

  2. Improve the measurement evidence. Take additional readings, possibly at different times or under defined conditions, and summarize the results.

Averages can reduce the influence of some short-term fluctuations, but they do not automatically solve the problem. The analyst must consider what is being measured, when measurements are taken, how variable the quantity is, and which decision the result will inform. Medical tests, for example, may specify fasting measurements or readings taken after a typical meal because the conditions affect what the result represents.


5. Describing a numerical distribution

A distribution describes how values of a variable are spread across possible outcomes. A distribution can reveal the center of the data, its variability, its asymmetry, and whether unusually distant observations are present.

Mean

The mean is the arithmetic average. For observations x1,x2,…,xnx_1, x_2, \ldots, x_nx1​,x2​,…,xn​,

xˉ=1n∑i=1nxi\bar{x} = \frac{1}{n}\sum_{i=1}^{n}x_ixˉ=n1​∑i=1n​xi​

The mean uses every observation and can be interpreted as the balance point, or center of gravity, of the values. Because it uses every value, an unusually large or small observation can pull it noticeably.

Median

The median is the middle value after the observations are ordered. If there are an even number of observations, it is the average of the two middle values.

The median divides the ordered data so that approximately half the observations are at or below it and half are at or above it. Unlike the mean, it is relatively resistant to extreme observations.

The mean and median answer different questions:

  • Mean: What is the average value across all observations?

  • Median: What value lies in the middle of the ordered observations?

For a right-skewed income distribution, a small number of very high incomes can raise the mean above the median. The median may better represent a typical individual, while the mean describes the overall arithmetic average.

Mode

The mode is the most common value or the peak of a distribution. It is especially straightforward for categorical or discrete data. For continuous data, its estimated value can depend on how observations are grouped into histogram bins, so it may be less stable than the mean or median.

A distribution can have more than one peak. The mode can therefore reveal common clusters that a single mean or median does not show.

Five-number summary and quartiles

The five-number summary consists of:

  1. Minimum

  2. First quartile, Q1Q_1Q1​

  3. Median, or second quartile, Q2Q_2Q2​

  4. Third quartile, Q3Q_3Q3​

  5. Maximum

The first quartile marks the point below which approximately 25%25\%25% of observations fall. The median divides the data approximately in half, and the third quartile marks the point below which approximately 75%75\%75% fall.

These five values provide a compact description of location and spread. For example, if the middle half of customer ages lies between 242424 and 333333, then a product designed for that interval addresses the central half of the observed customers, though it may not serve the youngest or oldest customers equally well.

Range and interquartile range

The range is the difference between the largest and smallest values:

Range=Maximum−Minimum\text{Range} = \text{Maximum} - \text{Minimum}Range=Maximum−Minimum

The interquartile range measures the spread of the central half of the data:

IQR=Q3−Q1\text{IQR} = Q_3 - Q_1IQR=Q3​−Q1​

Because the IQR focuses on the middle half, it is less affected by extreme values than the full range.

Variance and standard deviation

The variance measures average squared distance from the mean. For a sample, the sample variance is

s2=1n−1∑i=1n(xi−xˉ)2s^2 = \frac{1}{n-1}\sum_{i=1}^{n}(x_i-\bar{x})^2s2=n−11​∑i=1n​(xi​−xˉ)2

The sample standard deviation is the square root of the sample variance:

s=1n−1∑i=1n(xi−xˉ)2s = \sqrt{\frac{1}{n-1}\sum_{i=1}^{n}(x_i-\bar{x})^2}s=n−11​∑i=1n​(xi​−xˉ)2​

Each difference from the mean is squared so that values above and below the mean do not cancel. Taking the square root returns the measure to the original units: for age, standard deviation is measured in years rather than years squared.

The standard deviation describes the typical scale of departures from the mean, but it is sensitive to extreme observations because squaring gives large deviations substantial influence.

Another spread measure is the mean absolute deviation, which uses absolute distances rather than squared distances:

MAD=1n∑i=1n∣xi−xˉ∣\text{MAD} = \frac{1}{n}\sum_{i=1}^{n}|x_i-\bar{x}|MAD=n1​∑i=1n​∣xi​−xˉ∣

This measure is less affected by large deviations than the standard deviation. Different measures of spread are useful in different settings.

Skewness and outliers

A distribution is right-skewed when it has a longer or more extended tail toward larger values. In many right-skewed distributions, the mean is greater than the median because a smaller number of large observations pull the mean upward. A left-skewed distribution has a longer tail toward smaller values, and the mean may be below the median.

The mean–median comparison is a useful clue, not a complete description of shape. A histogram or another visual display can show additional features such as multiple peaks, gaps, or clusters.

An outlier is an observation unusually distant from the rest of the data. In a common box-plot convention, points below Q1−1.5IQRQ_1-1.5\text{IQR}Q1​−1.5IQR or above Q3+1.5IQRQ_3+1.5\text{IQR}Q3​+1.5IQR are displayed separately. This is a rule for flagging potential outliers, not proof that a value is an error. An unusual observation may be a mistake, a rare but real case, or evidence that the data contain distinct groups.


6. Visualizing distributions and relationships

Visualizations help analysts identify structure that may be difficult to see in a list of values.

Histograms

A histogram groups numerical observations into intervals, called bins, and displays the count in each interval. Its shape can reveal the center, spread, skew, gaps, and possible clusters of a distribution.

The appearance of a histogram depends partly on the bin boundaries and bin width. Very different bin choices can make the same data look smoother, more jagged, or more clustered. A histogram should therefore be interpreted as a useful visual summary, not as an exact representation of an underlying population distribution.

Box plots

A box plot summarizes a numerical distribution using quartiles and whiskers:

  • The box extends from Q1Q_1Q1​ to Q3Q_3Q3​ and contains the middle half of the observations.

  • The line within the box marks the median.

  • Whiskers extend toward the non-outlying observations, according to the plotting convention.

  • Values beyond the whiskers may be shown as separate points.

Box plots are useful for comparing distributions across groups, such as ages by customer gender or usage by product type. They provide a compact comparison of location, spread, and possible outliers, though they do not show every detail of the distribution’s shape.

Cross-tabulations and bar plots

For categorical variables, a cross-tabulation displays counts for combinations of categories. For instance, a table can show how many people in each product group are men or women, or how product choices differ by relationship status.

Cross-tabulations describe the observed counts; they do not establish whether apparent differences are statistically meaningful. A later inferential method, such as a chi-square test, can assess whether a pattern is stronger than would be expected under a specified no-association model.

Bar plots display categorical counts visually. They are not substitutes for understanding what the categories mean or how the sample was obtained.

Pair plots and univariate analysis

A pair plot displays variables in a grid:

  • Diagonal panels commonly show each variable’s own distribution, often as a histogram.

  • Off-diagonal panels show pairs of variables, often as scatter plots.

Examining one variable at a time is called univariate analysis. Examining two variables together is called bivariate analysis. Studying several variables jointly is called multivariate analysis.

A pair plot can reveal potential relationships, but it is most informative for variables with meaningful numerical values. Categorical variables may be ignored or require different visual methods. For ordinal ratings, the fact that software stores values as numbers does not by itself justify treating the scale as continuous.

Heat maps

A heat map uses color to represent numerical values, such as correlations. It is helpful when many variables need to be compared because colors can make clusters of stronger or weaker relationships easier to spot. A heat map is a visual encoding of values, not a different statistical calculation.


7. From a sample to a population

A dataset often contains only a sample of the cases about which an analyst ultimately wants to make a decision. A company may have records from past customers but want to understand future customers. A study of a handful of stores may be used to reason about a much larger chain.

The population is the broader set of cases of interest. A sample is the subset actually observed. A parameter is a characteristic of the population, such as its true mean age or proportion of customers who buy a product. A sample statistic, such as the sample mean, is used to estimate a population parameter.

The data observed in one sample are not identical to data that would be observed in another sample. This variation from sample to sample is called sampling variability. Statistical inference aims to distinguish systematic features that may generalize from variation that arises because only a sample was observed.

A smooth curve fitted to a sample can be used as an estimate of an underlying distribution, but it is not the raw data and it is not automatically the true population distribution. Its purpose is to represent patterns that may persist across comparable samples while smoothing away some sample-specific irregularity.

Generalization requires a defensible basis for treating the observed sample and the target population as related. If a company studies only its highest-performing salespeople, the resulting pattern may not represent low-performing salespeople or the full workforce. Sound sampling should cover the range of relevant situations and groups.

A sample mean such as xˉ\bar{x}xˉ is not necessarily the exact population mean. In many applications, it is more informative to report an estimate together with uncertainty, such as an interval. The amount of uncertainty depends on factors including sample size, data variability, sampling design, and the desired level of confidence.


8. Covariance and correlation

When two numerical variables are observed together, their relationship can be summarized by covariance. For paired observations (xi,yi)(x_i,y_i)(xi​,yi​), the sample covariance is

sxy=1n−1∑i=1n(xi−xˉ)(yi−yˉ)s_{xy} = \frac{1}{n-1}\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})sxy​=n−11​∑i=1n​(xi​−xˉ)(yi​−yˉ​)

The product inside the sum is positive when both observations are above their means or both are below their means. It is negative when one is above its mean and the other is below.

  • Positive covariance: the variables tend to move in the same direction.

  • Negative covariance: the variables tend to move in opposite directions.

  • Covariance near zero: there may be little linear co-movement, but a nonlinear relationship may still exist.

The covariance of a variable with itself is its variance:

sxx=sx2s_{xx} = s_x^2sxx​=sx2​

Covariance depends on the units used to measure the variables. Changing from meters to millimeters changes its numerical value, making raw covariances difficult to compare across different measurement scales.

The correlation standardizes covariance by the standard deviations of the two variables:

rxy=sxysxsyr_{xy} = \frac{s_{xy}}{s_xs_y}rxy​=sx​sy​sxy​​

Correlation has no units and lies between −1-1−1 and 111.

  • A correlation near 111 indicates a strong positive linear relationship.

  • A correlation near −1-1−1 indicates a strong negative linear relationship.

  • A correlation near 000 indicates little linear association.

Correlation is symmetric: the correlation of XXX with YYY is the same as the correlation of YYY with XXX. It does not indicate which variable causes the other. Correlation does not establish causation.

A low correlation does not prove that two variables are unrelated. A curved or otherwise nonlinear relationship can have a low correlation because positive and negative patterns offset one another. For example, profit may rise as price increases over one range, then fall as price becomes high enough to reduce demand. A single linear correlation may not capture that shape.

Correlation matrices and heat maps summarize pairwise linear relationships among numerical variables. They are useful for exploring many variables, but interpretation still depends on context and on whether the relationship is linear.


9. Regression as a descriptive model

Linear regression expresses one variable, the response YYY, as a linear function of one or more explanatory variables. With two explanatory variables, a model can be written as

Yi=β0+β1X1i+β2X2i+εiY_i = \beta_0+\beta_1X_{1i}+\beta_2X_{2i}+\varepsilon_iYi​=β0​+β1​X1i​+β2​X2i​+εi​

Here, β0\beta_0β0​ is the intercept, β1\beta_1β1​ and β2\beta_2β2​ are coefficients, and εi\varepsilon_iεi​ represents the part of the observation not captured by the fitted relationship.

For example, treadmill miles might be described using planned weekly usage and self-rated fitness. A fitted equation could estimate the association of each explanatory variable with miles while holding the other included variable fixed.

A coefficient describes the fitted relationship in the variables’ chosen units. If the fitness coefficient is positive, the model associates a one-unit increase in fitness rating with an increase in predicted miles, with usage held constant. This is a description of the model, not proof that changing fitness rating causes miles to increase.

Least-squares fitting

The least-squares method chooses coefficients to minimize the sum of squared differences between observed outcomes and model predictions:

SSE=∑i=1n(yi−y^i)2\text{SSE} = \sum_{i=1}^{n}(y_i-\hat{y}_i)^2SSE=∑i=1n​(yi​−y^​i​)2

For a one-variable model, the predicted value is y^i=β0+β1xi\hat{y}_i=\beta_0+\beta_1x_iy^​i​=β0​+β1​xi​. The fitting procedure selects the line whose squared vertical deviations from the observed points are smallest.

Squaring prevents positive and negative deviations from canceling. It also gives larger errors more weight. Other fitting criteria are possible, such as minimizing absolute deviations, and different criteria can respond differently to outliers.

An intercept may not have a meaningful real-world interpretation if the model’s predictors cannot reasonably be zero. It can still be mathematically useful because it allows the fitted line or plane to shift to better match the data.

Different uses of a fitted regression

A regression equation may be used in different ways:

  • Description: summarize an observed relationship.

  • Prediction: estimate YYY for a case with given predictor values.

  • Prescription: consider how changing inputs might help achieve a target outcome, subject to constraints and assumptions.

These uses should not be confused. A model that describes a sample well may not predict new cases well. A predictive association does not automatically justify an intervention.

Regression coefficients are also estimates rather than perfectly known values. Inferential analysis assesses their uncertainty and may test hypotheses such as whether a population coefficient differs from zero. A coefficient’s observed value alone is not enough to establish that a relationship generalizes.

Regression can also produce nonsensical predictions when applied outside the range or context of the data. For example, an equation may assign a negative number of miles when given unrealistic inputs. A fitted formula must be evaluated for its assumptions, intended range, and practical meaning.


10. Probability: events, outcomes, and rules

Probability represents the chance or likelihood of an event. It is a number between 000 and 111: 000 represents impossibility and 111 represents certainty.

An experiment is a process whose outcome is observed. An outcome is one possible result, and the sample space is the set of all possible outcomes. An event is a set of outcomes of interest.

Some probabilities can be estimated from observed frequencies. Others require assumptions or a model, particularly when the event has not yet occurred or cannot be repeatedly observed under identical conditions. In applied work, data may come from:

  • Experimental studies, where the researcher designs or controls conditions, as in some A/B tests.

  • Observational studies, where the researcher records outcomes that arise without assigning the conditions.

Many business datasets are observational: the analyst observes purchases, failures, or employee departures without having designed the process that produced them.

Sample spaces must preserve relevant detail

Suppose three manufactured parts can each be either good or defective. A sample space that records only the number of defective parts has four outcomes: 000, 111, 222, or 333 defective. That may be adequate for some questions, but it loses information about which individual part was defective.

A more detailed sample space records each part’s status. For instance, GDDGDDGDD means the first part is good and the second and third are defective. There are 23=82^3=823=8 such outcomes.

The right sample space preserves enough detail to calculate the probabilities of the events being asked about.

Mutually exclusive events and addition

Two events are mutually exclusive if they cannot occur together. If AAA and BBB are mutually exclusive, then

P(A∪B)=P(A)+P(B)P(A\cup B)=P(A)+P(B)P(A∪B)=P(A)+P(B)

For general events, the overlap must be subtracted once:

P(A∪B)=P(A)+P(B)−P(A∩B)P(A\cup B)=P(A)+P(B)-P(A\cap B)P(A∪B)=P(A)+P(B)−P(A∩B)

Here, A∪BA\cup BA∪B means that AAA or BBB or both occur, while A∩BA\cap BA∩B means that both occur.

For example, drawing one card from a standard deck, the chance of a king or a queen is the sum of the two probabilities because no single card is both a king and a queen. The chance of a king or a diamond requires subtracting the king of diamonds once because it belongs to both events.

Independent events and multiplication

Events AAA and BBB are independent if knowing that one occurred does not change the probability of the other. For independent events,

P(A∩B)=P(A)P(B)P(A\cap B)=P(A)P(B)P(A∩B)=P(A)P(B)

For example, if two independent customers each have a 10%10\%10% chance of purchasing a product, the probability that both purchase is 0.1×0.1=0.010.1\times0.1=0.010.1×0.1=0.01.

Mutual exclusivity and independence are different concepts. Mutually exclusive events with nonzero probabilities are not independent: if one has occurred, the other cannot occur.

Conditional probability

The conditional probability of AAA given that BBB has occurred is

P(A∣B)=P(A∩B)P(B)P(A\mid B)=\frac{P(A\cap B)}{P(B)}P(A∣B)=P(B)P(A∩B)​

provided that P(B)>0P(B)>0P(B)>0. It asks: among cases in which BBB is known to have occurred, what proportion also have AAA?

The multiplication rule follows:

P(A∩B)=P(B)P(A∣B)P(A\cap B)=P(B)P(A\mid B)P(A∩B)=P(B)P(A∣B)

It can also be written as

P(A∩B)=P(A)P(B∣A)P(A\cap B)=P(A)P(B\mid A)P(A∩B)=P(A)P(B∣A)

If AAA and BBB are independent, then P(A∣B)=P(A)P(A\mid B)=P(A)P(A∣B)=P(A): knowing BBB has occurred gives no new information about AAA.


11. Bayes’ theorem and updating probabilities

Bayes’ theorem reverses a conditional probability. It relates the probability of evidence given a hypothesis to the probability of the hypothesis given that evidence:

P(A∣B)=P(B∣A)P(A)P(B)P(A\mid B)=\frac{P(B\mid A)P(A)}{P(B)}P(A∣B)=P(B)P(B∣A)P(A)​

The denominator can be expanded when AAA and its complement, AcA^cAc, are the only possibilities:

P(B)=P(B∣A)P(A)+P(B∣Ac)P(Ac)P(B)=P(B\mid A)P(A)+P(B\mid A^c)P(A^c)P(B)=P(B∣A)P(A)+P(B∣Ac)P(Ac)

Bayes’ theorem is useful when evidence is easier to model in one direction than the direction needed for a decision.

Medical test example and base rates

Suppose:

  • The prevalence of a condition is 1%1\%1%.

  • A test has 95%95\%95% sensitivity, meaning P(+∣condition)=0.95P(+\mid \text{condition})=0.95P(+∣condition)=0.95.

  • The test has 95%95\%95% specificity, meaning P(−∣no condition)=0.95P(-\mid \text{no condition})=0.95P(−∣no condition)=0.95.

  • Therefore, the false-positive rate is P(+∣no condition)=0.05P(+\mid \text{no condition})=0.05P(+∣no condition)=0.05.

The probability of having the condition given a positive result is

P(condition∣+)=0.95(0.01)0.95(0.01)+0.05(0.99)≈0.161P(\text{condition}\mid +) = \frac{0.95(0.01)} {0.95(0.01)+0.05(0.99)} \approx 0.161P(condition∣+)=0.95(0.01)+0.05(0.99)0.95(0.01)​≈0.161

Thus, a positive result corresponds to about a 16%16\%16% probability of the condition under these assumptions, not a 95%95\%95% probability.

The reason is the base rate: the condition is rare, so the much larger group without the condition can produce many false positives even when the test is fairly accurate. This is why a positive screening result may be followed by another test.

A second test reduces uncertainty only to the extent that its errors provide new evidence. If two tests have dependent errors, their results cannot simply be treated as independent confirmations.

Bayesian classification

Bayes’ theorem also explains a common strategy in classification. A spam filter may need to estimate

P(spam∣observed words)P(\text{spam}\mid \text{observed words})P(spam∣observed words)

It may be easier to estimate how often particular words appear in spam and non-spam messages, then combine those probabilities with the overall prevalence of spam. The general strategy is to use the probability of evidence under each possible class to update the probability of the class after observing the evidence.

This approach is useful for email filtering, medical classification, customer response modeling, and other tasks where evidence changes the relative plausibility of possible outcomes.


12. Probability distributions

A probability distribution assigns probabilities to possible values of a random variable. It describes the outcomes that may occur and how likely they are under a specified model.

For a discrete variable, probabilities are assigned to individual values. For a continuous variable, probabilities are represented over intervals.

Probability mass function and cumulative distribution function

For a discrete random variable XXX, a probability mass function gives

p(x)=P(X=x)p(x)=P(X=x)p(x)=P(X=x)

A cumulative distribution function, for discrete or continuous variables, gives

F(x)=P(X≤x)F(x)=P(X\leq x)F(x)=P(X≤x)

For a continuous variable, a probability density function f(x)f(x)f(x) describes how probability is distributed across values. The probability that XXX lies between aaa and bbb is the area under the density curve:

P(a≤X≤b)=∫abf(x) dxP(a\leq X\leq b)=\int_a^b f(x)\,dxP(a≤X≤b)=∫ab​f(x)dx

For a continuous distribution, the cumulative distribution function is the integral of the density function, and the density is the derivative of the cumulative distribution function where that derivative exists. The density at a single point is not itself the probability of that exact value; for a continuous variable, the probability of any single exact point is zero.


13. The binomial distribution

The binomial distribution models the number of successes in a fixed number of trials when:

  • The number of trials, nnn, is fixed.

  • Each trial has two relevant outcomes, success or failure.

  • The probability of success, ppp, is the same on every trial.

  • Trials are independent.

If XXX is the number of successes, then

P(X=x)=(nx)px(1−p)n−xP(X=x)=\binom{n}{x}p^x(1-p)^{n-x}P(X=x)=(xn​)px(1−p)n−x

Here, (nx)\binom{n}{x}(xn​) counts the number of ways to choose which xxx of the nnn trials are successes.

For example, if each of seven accounts has a 60%60\%60% chance of paying on time, the probability that exactly two pay on time is

P(X=2)=(72)(0.6)2(0.4)5≈0.077P(X=2)=\binom{7}{2}(0.6)^2(0.4)^5\approx0.077P(X=2)=(27​)(0.6)2(0.4)5≈0.077

The possible values of XXX are 0,1,…,70,1,\ldots,70,1,…,7. The expected number of successes is

E[X]=npE[X]=npE[X]=np

For the seven-account example, the expected count is 7(0.6)=4.27(0.6)=4.27(0.6)=4.2. This does not mean that exactly 4.24.24.2 accounts will pay. It means the distribution is centered at that expected value over repeated comparable situations.

The standard deviation of a binomial count is

np(1−p)\sqrt{np(1-p)}np(1−p)​

The binomial model applies to many settings, including defect counts in a fixed batch, purchases among a fixed number of prospects, and click-throughs among a fixed number of ad impressions. Its assumptions must be examined: outcomes may not be independent, and success probabilities may differ across trials.


14. The Poisson distribution

The Poisson distribution models a count of events in a specified interval when events occur at a stable average rate and are treated as independent. Unlike the binomial distribution, it does not require a stated fixed number of trials.

If XXX is the event count and λ\lambdaλ is the expected number of events in the interval, then

P(X=x)=e−λλxx!P(X=x)=\frac{e^{-\lambda}\lambda^x}{x!}P(X=x)=x!e−λλx​

The mean of a Poisson distribution is λ\lambdaλ, and its variance is also λ\lambdaλ.

Possible applications include modeling the number of customer arrivals per minute, the number of defects on a product, or the number of fraud cases in a period, when the assumptions are reasonable.

The time interval matters. If a bank averages six customer arrivals every two minutes, its average rate is three arrivals per minute. To find the probability of exactly four arrivals in one minute, the appropriate rate is λ=3\lambda=3λ=3, not λ=6\lambda=6λ=6:

P(X=4)=e−3344!≈0.168P(X=4)=\frac{e^{-3}3^4}{4!}\approx0.168P(X=4)=4!e−334​≈0.168

The Poisson distribution is suited to counts over a defined interval. If a maximum number of trials is known and each trial has a success probability, a binomial model may be more appropriate.


15. The normal distribution and standard deviations

The normal distribution is a symmetric, bell-shaped continuous distribution characterized by its mean μ\muμ and standard deviation σ\sigmaσ. Its standard form is important because many variables and sampling summaries can be approximated by it under suitable conditions.

For normally distributed data:

  • About 68%68\%68% of values fall within one standard deviation of the mean.

  • About 95%95\%95% fall within approximately two standard deviations.

  • About 99.7%99.7\%99.7% fall within approximately three standard deviations.

More precisely, roughly 95%95\%95% fall within 1.961.961.96 standard deviations of the mean. These proportions are properties of a normal model; they do not automatically apply to every dataset.

If adult heights were approximately normal with mean 555 feet 888 inches and standard deviation 222 inches, then about 68%68\%68% would be expected between 555 feet 666 inches and 555 feet 101010 inches. About 95%95\%95% would fall within approximately 444 inches of the mean.

Calculating normal probabilities

For a normal variable, probabilities can be found from the cumulative distribution function. A useful standardized value is the z-score:

z=x−μσz=\frac{x-\mu}{\sigma}z=σx−μ​

It measures how many standard deviations a value lies above or below the mean.

Suppose cereal-pack weights are modeled as normal with mean 295295295 grams and standard deviation 252525 grams.

For a weight below 280280280 grams,

z=280−29525=−0.6z=\frac{280-295}{25}=-0.6z=25280−295​=−0.6

The modeled probability is approximately P(Z<−0.6)≈0.274P(Z<-0.6)\approx0.274P(Z<−0.6)≈0.274. For a weight above 350350350 grams,

z=350−29525=2.2z=\frac{350-295}{25}=2.2z=25350−295​=2.2

The modeled probability is approximately P(Z>2.2)≈0.014P(Z>2.2)\approx0.014P(Z>2.2)≈0.014. For a weight between 260260260 and 340340340 grams, the probability is the cumulative probability below 340340340 minus the cumulative probability below 260260260, which is approximately 0.890.890.89.

These calculations depend on the assumption that the relevant weights follow the specified normal distribution. They are not equivalent to counting observations from a dataset.

Normal assumptions and their limits

The normal distribution is often used because it is mathematically convenient and because sums or averages of many contributions can sometimes be approximately normal. The central limit theorem explains why the distribution of sample averages often approaches a normal shape under suitable conditions, even when individual observations are not normally distributed.

However, normality is not universal. Strongly skewed data, heavy-tailed data, or quantities with a different scientific mechanism may be better represented by other distributions. Engineering reliability, finance, and other fields may use different distribution families depending on the process being modeled.

A model is an approximation of reality. Its usefulness depends on whether its assumptions are suitable for the question and whether its errors are acceptable for the decision. The distribution of raw observations and the distribution of a statistic, such as a sample mean, are related but are not necessarily the same.


16. Choosing a measure or model for a question

No single summary is best for every purpose.

  • The mean is useful when the overall arithmetic average matters and extreme observations should influence the result.

  • The median is useful when a typical middle case is more important or when extreme values would distort the mean.

  • The standard deviation summarizes spread around the mean but is sensitive to outliers.

  • The IQR summarizes the spread of the middle half and is more resistant to extremes.

  • Correlation summarizes linear association but does not reveal causation or all nonlinear patterns.

  • Regression summarizes or predicts a response from explanatory variables, subject to its assumptions and validation.

  • Probability distributions describe possible outcomes and support calculations about uncertainty, but they are only as appropriate as their modeling assumptions.

The central analytical task is to connect the measure to the purpose. A mattress designed for the maximum possible weight may be unnecessarily firm for many users; a design based only on the average may fail for heavier users. Likewise, a business may need to distinguish the income of a typical customer from average income across all customers.

Statistical summaries describe evidence, probability quantifies uncertainty, and prediction and prescription require additional assumptions about how the observed patterns will apply to future cases and decisions.

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent