IntroStat June2014

📚 IntroStat_June2014.pdf

Brief overview

This document provides a foundational introduction to statistical concepts and their applications. It covers essential techniques for data exploration, probability, statistical inference, and modeling relationships between variables, crucial for making informed decisions in uncertain environments.

Key points

  • Overview of statistical concepts, data exploration, and descriptive statistics.
  • Introduction to set theory and fundamental probability concepts.
  • Detailed exploration of various probability distributions.
  • Coverage of statistical inference, including hypothesis testing and confidence intervals.
  • Application of regression and correlation analysis for understanding variable relationships.

1. Introduction to statistics and data exploration (part 1)

1.1 Statistics and data exploration

  • Statistics: The science of decision-making in the face of uncertainty. It focuses on interpreting data to make sound decisions.
  • Data: Information used to assist in decision-making. It can come in various forms and amounts.
  • Goal of exploration: To quickly summarize and display data for an initial understanding. This involves visual displays, key numbers, and gaining insight into data potential.

Statistics helps make consistently sound decisions in uncertain situations.

1.2 Types of data

  • Qualitative data: Non-numerical data, often uses labels or names for categories.
  • Examples: Make of car, eye color, gender, profession.
  • Can be ordinal, like company size (small, medium, large).
  • Quantitative data: Always numerical data that can be ordered. It usually arises from counting or measuring.
  • Examples: Flying time, number of rooms, salary, cost of a building.

1.3 Visual displays for qualitative data

  • Pie chart: Uses segments of a circle to represent proportions of categories. Best arranged with decreasing relative frequencies.
  • Bar graph: Uses horizontal or vertical bars to show category frequencies or relative frequencies. Bars are not connected, and width is not relevant. Arranging bars by decreasing frequency improves comparison.

Pie charts and bar graphs are effective for visualizing qualitative data proportions.

1.4 Example: MBA student degrees

  • A table lists MBA students' first degrees (Arts, Commerce, Engineering, Medicine, Science, Other) and GMAT scores.
  • Qualitative data: First degree category.
  • Visualizing the data shows engineers are the largest proportion of MBA students.

Table 1.1: MBA Student First Degree Distribution

First degreeFrequencyRelative frequency
Engineering280.35
Science160.20
Arts160.20
Commerce100.12
Medicine50.06
Other60.07
Total811.00
10### 1.3.2 Example: Johannesburg Stock Exchange All-Share Index
  • Table 1.2 breaks down the All-Share Index by major sector and number of shares.
  • Tasks:
  • Construct a bar chart for the number of shares per sector.
  • Construct a bar chart for the relative weightings (percentages) of each sector and compare to the first chart 12.

Table 1.2: Composition of the All Share Index (partial)

Major sectorSubsidiary IndexNo. of sharesPercentage weighting
CoalCoal20.82
DiamondsDiamonds18.27
All-GoldGold — Rand and others51.39
All-GoldGold — Evander20.89
Mining financialMining houses316.79
FinancialBanks & financial services52.80
IndustrialIndustrial holdings69.94
IndustrialBeverages & hotels23.43
13

1.5 Display and summarize quantitative data

  • Statistical tools extract information from data that isn't obvious 8.
  • Initial steps include visual displays, summarizing with key numbers, and gaining insight.
  • Quantitative data needs specific displays like histograms and stem-and-leaf plots.

Quantitative data exploration uses tools beyond simple counting and averaging.

1.6 Stem-and-leaf plots

  • A method to display quantitative data, similar to a histogram but shows individual data values.
  • Each data value is split into a "stem" (leading digits) and a "leaf" (trailing digit).
  • Leaves are listed in order next to their corresponding stem.

Stem-and-leaf plots give a quick visual summary while retaining original data points.

1.7 Histograms

  • A visual representation of the distribution of quantitative data.
  • Data is grouped into bins (intervals), and bars represent the frequency of data within each bin.
  • Bars in a histogram are connected, indicating a continuous range of values 11.

Histograms reveal the shape, center, and spread of quantitative data distributions.

Table 1: Distribution Shapes

ShapeDescription
SymmetricLeft and right sides are mirror images.
SkewedHas a tail extending more to one side.
Right-skewTail extends to the right (higher values).
Left-skewTail extends to the left (lower values).
  • Key numbers provide a concise summary of data 9.
  • Common statistics include measures of location (like the median) and spread.

1.8 Measures of location

  • Median: The middle value in a dataset when ordered. If there's an even number of data points, it's the average of the two middle values.
  • Quartiles: Divide the data into four equal parts.
  • First quartile (Q1Q1): The median of the lower half of the data.
  • Third quartile (Q3Q3): The median of the upper half of the data.

1.9 Measures of spread

  • Describe the variability or dispersion of data points.

1.10 The five-number summary

  • A set of five values that describe the main features of a quantitative dataset.
  • Minimum value (smallest observation).
  • First quartile (Q1Q1).
  • Median.
  • Third quartile (Q3Q3).
  • Maximum value (largest observation).

The five-number summary provides a quick overview of a dataset's range and distribution.

1.11 Box-and-whisker plots

  • A visual display of the five-number summary.
  • Shows the median, quartiles, and the range of the data.
  • Can help identify outliers, which are unusually extreme values 7.

Box-and-whisker plots are useful for comparing distributions across different groups.

🔑 Important: Statistics is about making data-based decisions, especially when uncertainty is present.

1.12 What is a histogram?

  • Histograms are visual displays for quantitative data.
  • Unlike bar charts, histogram bars are adjacent with no gaps.
  • Bars represent intervals on a number line, not named categories.
  • These intervals (or bins) must have equal width.

🔑 Important: Histograms show the shape of data distribution.

1.13 Constructing a histogram

Follow these steps to create a histogram:

  1. Determine sample size and range:
  • Find the number of observations (nn).
  • Identify the smallest (xminx_{min}) and largest (xmaxx_{max}) values.
  1. Choose class intervals:
  • Intervals should cover the range from xminx_{min} to xmaxx_{max}.
  • The length (LL) of intervals should be sensible.
  • Guideline 1 (Sturge): L≈xmax−xmin1+1.44log⁡enL \approx \frac{x_{max} - x_{min}}{1 + 1.44 \log_e n}.
  • Guideline 2 (GENSTAT): L≈xmax−xminnL \approx \frac{x_{max} - x_{min}}{\sqrt{n}}.
  • Use convenient widths like multiples of 2, 5, or 10.
  • Ensure all intervals have the same width; unequal widths distort the visual message.
  1. Count frequencies:
  • Tally the number of observations falling into each class interval.
  • This creates a frequency distribution.
  1. Plot the histogram:
  • Use suitable scales for the x-axis (data values) and y-axis (frequency or relative frequency).

🔑 Important: Avoid making intervals too narrow (spikey) or too wide (blurred).

Histogram example: GMAT scores

  • Sample size (nn) = 81.
  • Range: xminx_{min} = 450, xmaxx_{max} = 750 14.
  • Chosen interval width (LL) = 50.
  • Intervals: 450-499, 500-549, etc..
Class intervalFrequency
450–4991
500–54921
550–59925
600–64919
650–69910
700–7494
750–7991
Total81

15

Histogram example: Stock market risk

  • Sample size (nn) = 75.
  • Range: xminx_{min} = 8, xmaxx_{max} = 28.
  • Chosen interval width (LL) = 2.
  • Intervals: 8-9, 10-11, etc..

| 8–9 | 4 | | 10–11 | 10 | | 12–13 | 16 | | 14–15 | 7 | | 16–17 | 5 | | 18–19 | 4 | | 20–21 | 6 | | 22–23 | 12 | | 24–25 | 5 | | 26–27 | 4 | | 28–29 | 2 | | Total | 75 |## 1.3 Interpreting histogram shapes

  • A histogram's shape reveals patterns in the data 16.
  • Skewed to the right: The tail stretches to the right, meaning higher values are less frequent.
  • Symmetric distribution: The left and right sides are mirror images.
  • Bimodal distribution: The histogram has two distinct peaks, indicating two common groups or values within the data.

🔑 Important: A bimodal distribution suggests two underlying groups in the data, which may require further investigation for explanation.

Example: GMAT score interpretation

  • The GMAT score histogram is skewed to the right.
  • This indicates a tail of lower scores.
  • The data might be truncated due to an MBA program's minimum score requirement of 500.
  • A score of 450 might be an error or due to exceptional performance in other selection criteria.

Example: Stock market risk interpretation

  • The stock market risk histogram is bimodal.
  • It has peaks around 12-13 and 22-23 18.
  • Further analysis showed "gold shares" caused the right peak (higher risk).
  • "Industrial shares" caused the left peak (lower risk).
  • This implies gold shares are generally more volatile than industrial shares.

🔑 Important: Histograms can reveal patterns, like bimodality, that are not obvious from raw data lists.

🔑 Important: Understanding the context of the data is crucial for interpreting histogram shapes like skewness and bimodality 17 20.

2. Introduction to statistics and data exploration (part 2)

2.1 Stem-and-leaf plots

Stem-and-leaf plots offer a visual display similar to histograms. They preserve original data values, making them useful for data storage.

To construct a stem-and-leaf plot:

  • Split each data point into a "stem" and a "leaf." Typically, the tens digit forms the stem and the units digit forms the leaf 21.
  • List stems in ascending order.
  • Write leaves on the appropriate stem as you iterate through the data.
  • Sort the leaves for each stem from smallest to largest.
  • Add a cumulative count column to track the number of leaves.

A stem-and-leaf plot is essentially a histogram turned sideways. It displays data within intervals of 10 units and retains all original values 22.

📝 Example: For football scores like 63, the stem is 6 and the leaf is 3. This is placed next to the stem '6'.

Stem-and-leaf plots can be adapted for data with common trailing digits. For instance, if all numbers end in zero, the hundreds can be stems and tens can be leaves.

Stems can also be split into two or five parts to provide more detail, using mnemonic labels like "·" (0-4) and "⋆" (5-9) for finer intervals 23 24.

2.2 Five-number data summaries

A five-number summary reduces a dataset to a few key numbers. These numbers provide a grasp of the data's important features.

  • Rank: In a sorted dataset of size nn, the smallest number has rank 1, the second smallest has rank 2, and so on, up to rank nn for the largest number. These are denoted as x,x,…,x(n)x_{ }, x_{ }, \dots, x_{(n)}2.
  • Half-ranks: A number with a half-rank is the average of two adjacent observations: x(r+1/2)=x(r)+x(r+1)2x_{(r+1/2)} = \frac{x_{(r)} + x_{(r+1)}}{2}.

Key components of the five-number summary:

  • Median (x(m)x_{(m)}): The number with rank (n+1)/2(n+1)/2. If nn is odd, it's the middle number. If nn is even, it's the average of the two middle numbers 25.
  • Lower Quartile (x(l)x_{(l)}): The number with rank l=(⌊m⌋+1)/2l = (\lfloor m \rfloor + 1)/2, where mm is the median's rank. It marks the end of the bottom 25% of data.
  • Upper Quartile (x(u)x_{(u)}): The number with rank u=n−l+1u = n - l + 1. It marks the end of the top 25% of data.
  • Extremes: The smallest value (xx_{ }) and the largest value (x(n)x_{(n)}).

The five-number summary is presented as (x,x(l),x(m),x(u),x(n))(x_{ }, x_{(l)}, x_{(m)}, x_{(u)}, x_{(n)})26.

🔑 Important: The median indicates the midpoint where half the data is below and half is above. The quartiles define the central 50% of the data.

2.3 Box-and-whisker plots

Box-and-whisker plots graphically display the five-number summary. They are particularly useful for comparing multiple datasets 27.

Construction steps:

  1. Draw a vertical axis covering the data's full range.
  2. Create a "box" extending from the lower quartile (x(l)x_{(l)}) to the upper quartile (x(u)x_{(u)}).
  3. Draw a line within the box at the median (x(m)x_{(m)}).
  4. Extend "whiskers" from the box to the minimum (xx_{ }) and maximum (x(n)x_{(n)}) values.

When comparing datasets, plots should be side-by-side on the same scale. The whiskers show the spread, and the box shows the central 50% 28.

📝 Example: A box-and-whisker plot for football points (29, 50, 55, 63, 79) would have a box from 50 to 63, a line at 55, and whiskers extending to 29 and 79.

Outliers and strays

Outlying values are significantly different from the main body of data. Identifying them helps detect potential errors or noteworthy observations 29.

  • Outliers: Values greater than x(m)+6(x(u)−x(m))x_{(m)} + 6(x_{(u)} - x_{(m)}) or less than x(m)−6(x(m)−x(l))x_{(m)} - 6(x_{(m)} - x_{(l)}).
  • Strays: Values not outliers but greater than x(m)+3(x(u)−x(m))x_{(m)} + 3(x_{(u)} - x_{(m)}) or less than x(m)−3(x(m)−x(l))x_{(m)} - 3(x_{(m)} - x_{(l)}).
  • Fences: The largest and smallest observations that are not strays. Whiskers on a box-plot extend to the fences, not the extremes, to highlight outliers 30.

🔑 Important: Outlier detection rules help identify extreme values that might require further investigation.

2.4 Measures of location and spread

Statistics that summarize data can be categorized as measures of location or measures of spread.

Measures of location

These statistics describe the "middle" or typical value of a dataset.

  • Sample median (x(m)x_{(m)}): Locates the middle by having half the observations below and half above it. Data must be sorted to find it 33.
  • Sample mean (xˉ\bar{x}): Calculated by summing all values and dividing by the sample size (nn). It represents the balancing point of the data. xˉ=1n∑i=1nxi\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i 34.

🔑 Important: The median is robust (not easily affected by outliers), while the mean is sensitive to outliers. The mean is preferred for symmetric distributions and is mathematically easier to work with 35.

Measures of spread

These statistics quantify the variability or dispersion within a dataset.

  • Range (R): The difference between the maximum and minimum values (R=x(n)−xR = x_{(n)} - x_{ }). It is sensitive to outliers 1.
  • Interquartile Range (I): The difference between the upper and lower quartiles (I=x(u)−x(l)I = x_{(u)} - x_{(l)}). It measures the spread of the central 50% and is robust to outliers.
  • Sample variance (s2s^2): The average of the squared differences from the mean. s2=1n−1∑i=1n(xi−xˉ)2s^2 = \frac{1}{n-1}\sum_{i=1}^{n} (x_i - \bar{x})^2. It is measured in squared units.
  • Sample standard deviation (s): The square root of the sample variance (s=s2s = \sqrt{s^2}). It is measured in the same units as the original data, making it more intuitive than variance 36.

🔑 Important: The standard deviation, like the mean, is sensitive to outliers. The interval (xˉ−s,xˉ+s)(\bar{x}-s, \bar{x}+s) typically contains about two-thirds of the data for symmetric distributions.

2.5 Summary statistics for quantitative data

  • Calculations for quantitative data involve summary statistics. These include measures of location and spread.
  • Measures of location describe the center of the data. Examples are the sample mean (xˉ\bar{x}) and the median (xmx_m).
  • Measures of spread describe how dispersed the data is. Common examples are the standard deviation (ss), interquartile range (II), and range (RR).

Calculation Example: GMAT Scores by Faculty.

To calculate the sample mean (xˉ\bar{x}) and sample variance (s2s^2) for a category:

  • Sum all observations: ∑i=1nxi\sum_{i=1}^n x_i.
  • Sum the squares of all observations: ∑i=1nxi2\sum_{i=1}^n x_i^2.
  • Sample mean: xˉ=∑xin\bar{x} = \frac{\sum x_i}{n}.
  • Sample variance: s2=1n−1(∑xi2−(∑xi)2n)s^2 = \frac{1}{n-1} \left( \sum x_i^2 - \frac{(\sum x_i)^2}{n} \right).
  • Sample standard deviation: s=s2s = \sqrt{s^2}.

📝 Example: For "Engineering" GMAT scores, the sum of scores is 16,850, and the sum of squared scores is 10,254,100.

  • Sample mean: xˉ=16,850/28=601.8\bar{x} = 16,850 / 28 = 601.8.
  • Sample variance: s2=127(10,254,100−(16,850)2/28)=4,222.6s^2 = \frac{1}{27} (10,254,100 - (16,850)^2 / 28) = 4,222.6.
  • Sample standard deviation: s=4,222.6=65.0s = \sqrt{4,222.6} = 65.0.

Comparison of Summary Statistics

Categoryxˉ\bar{x} (mean)xmx_m (median)ss (std dev)II (IQR)RR (range)
Engineering601.860065.095250
Science583.158548.575160
Arts555.653562.875210
Commerce567.055545.760140
Medicine638.064053.1105120
Other581.758580.1100220
  • Measures of location (mean, median) indicate the typical score. Medicine students had the highest mean and median GMAT scores.
  • The difference between the mean and median can suggest skewness. For arts students, a larger gap (mean 555.6 vs. median 535) indicated right-skewed data.
  • Measures of spread (standard deviation, IQR, range) show data variability. The "Other" category had the largest standard deviation, possibly due to its diverse student composition 39.

🔑 Important: Summary statistics provide a snapshot of data, but visual exploration (like box plots) reveals distributions, skewness, and outliers.

2.6 Updating summary statistics

  • Summary statistics can be updated efficiently when a new data point is added. This avoids recalculating everything from scratch.

Updating the Mean

When a new observation (xn+1x_{n+1}) is added to a sample of size nn with mean xˉ\bar{x}, the updated mean (xˉ⋆\bar{x}^\star) is calculated as: xˉ⋆=nxˉ+xn+1n+1\bar{x}^\star = \frac{n\bar{x} + x_{n+1}}{n+1}.

Updating the Standard Deviation

The updated standard deviation (s⋆s^\star) can be found using the previous sample variance (s2s^2), means, and the new observation: s⋆=1n[(n−1)s2+n(xˉ−xˉ⋆)2+(xn+1−xˉ⋆)2]s^\star = \sqrt{\frac{1}{n} \left[ (n-1)s^2 + n(\bar{x} - \bar{x}^\star)^2 + (x_{n+1} - \bar{x}^\star)^2 \right]}.

📝 Example: A sample of nine numbers has a mean of 4.8 and a standard deviation of 3.0. A tenth observation of 6.8 is added.

  • Updated mean: xˉ⋆=9×4.8+6.89+1=43.2+6.810=5.0\bar{x}^\star = \frac{9 \times 4.8 + 6.8}{9+1} = \frac{43.2 + 6.8}{10} = 5.0.
  • Updated standard deviation calculation requires the previous sample variance (s2=3.02=9.0s^2 = 3.0^2 = 9.0).
  • s⋆=19[(9−1)(9.0)+9(4.8−5.0)2+(6.8−5.0)2]s^\star = \sqrt{\frac{1}{9} \left[ (9-1)(9.0) + 9(4.8 - 5.0)^2 + (6.8 - 5.0)^2 \right]}
  • s⋆=19[72+9(−0.2)2+(1.8)2]=19[72+0.36+3.24]=75.69≈8.4≈2.9s^\star = \sqrt{\frac{1}{9} \left[ 72 + 9(-0.2)^2 + (1.8)^2 \right]} = \sqrt{\frac{1}{9} \left[ 72 + 0.36 + 3.24 \right]} = \sqrt{\frac{75.6}{9}} \approx \sqrt{8.4} \approx 2.9.

2.7 Exploratory data analysis (EDA)

  • Exploratory data analysis (EDA) is a process of getting a feel for a sample of data.
  • EDA techniques help understand data before complex statistical methods are applied.

Why EDA is Crucial

  • Outliers can heavily influence summary statistics like the mean and standard deviation.
  • Skewness can distort measures of central tendency and spread.
  • EDA helps visually check assumptions for statistical models.

🔑 Important: EDA techniques, like those described in this chapter, are integral to modern statistical software and should be used before performing more complex analyses 40.

3. Introduction to statistics and data exploration (part 3)

3.1 Exploratory data analysis with plots

  • Bar graphs: used for qualitative data, showing frequencies or percentages of categories.
  • The bar graph for sectors of the All-Share Index shows a large weighting for mining financial, despite fewer shares 41.

📝 Example: A bar graph can visually represent the number of shares in different sectors like Coal, Diamonds, or Industrial, making it easy to compare their sizes.

  • Histograms: used for quantitative data, grouping values into class intervals to show the distribution's shape.
  • The histogram for examination marks shows a left-skewed distribution, with most students scoring lower marks.
  • A histogram of car sales displays a distribution heavily skewed to the right, with many days having zero sales.

📝 Example: For car sales data, a histogram might show bars for 0, 1, 2, etc., cars sold, with a very tall bar at zero and progressively shorter bars for higher numbers.

  • Stem-and-leaf plots: visualize quantitative data by separating digits into stems and leaves, preserving original values 42.
  • They show the distribution's shape, identify outliers, and allow for direct calculation of summary statistics.

📝 Example: For waiting times, a stem-and-leaf plot might have stems like 1, 2, 3, and leaves like 8, 9 for 18, 19 minutes.

3.2 Summary statistics

  • Measures of central tendency describe the center of a dataset.
  • Median (xmx_m): the middle value when data is sorted; less affected by outliers than the mean.
  • Mean (xˉ\bar{x}): the average value, calculated by summing all values and dividing by the count.

🔑 Important: The median is more robust to outliers than the mean.

  • Measures of spread describe the data's variability.
  • Range (RR): the difference between the maximum and minimum values 46.
  • Interquartile range (IQR or II): the difference between the upper and lower quartiles, indicating the spread of the middle 50% of data.
  • Standard deviation (ss): measures the average distance of data points from the mean.

🔑 Important: Range is highly sensitive to outliers, while IQR is more resistant.

3.2.1 The five-number summary

  • The five-number summary provides a concise overview of a dataset's distribution.
  • It includes the minimum, lower quartile (Q1), median (Q2), upper quartile (Q3), and maximum44 45.
  • This summary is often visualized using box-and-whisker plots49.
StatisticDescription
MinimumThe smallest value in the dataset.
Lower QuartileThe 25th percentile of the data.
MedianThe 50th percentile of the data.
Upper QuartileThe 75th percentile of the data.
MaximumThe largest value in the dataset.

3.2.2 Box-and-whisker plots

  • Box-and-whisker plots visually represent the five-number summary.
  • The "box" spans the interquartile range (IQR), with a line inside marking the median.
  • "Whiskers" extend from the box to the minimum and maximum values (or to a certain limit if outliers are present) 48.

🔑 Important: Side-by-side box plots are excellent for comparing distributions of multiple datasets.

3.3 Data transformations

  • Sometimes, data needs transformation to better reveal patterns or achieve a more symmetric distribution.
  • Taking the logarithm of data can compress large values and spread out small values.
  • This transformation is useful when dealing with data that is highly skewed, like annual river runoffs 50.

📝 Example: Applying a logarithmic transformation to river runoff data can make the distribution more symmetric, improving the interpretability of summary statistics and plots.

3.4 Effects of linear transformations

  • Adding a constant bb to each data point shifts the mean by bb but does not change the variance or standard deviation.
  • Multiplying each data point by a constant cc scales the mean by cc and scales the variance by c2c^2.
  • A combined linear transformation yi=c⋅xi+by_i = c \cdot x_i + b results in a new mean of c⋅xˉ+bc \cdot \bar{x} + b and a new variance of c2⋅s2c^2 \cdot s^2 51.

🔑 Important: Understanding how linear transformations affect mean and variance is crucial for data manipulation and interpretation.

📝 Example: If the mean exam score is 70 and standard deviation is 10, adding 5 points to every score will make the new mean 75, but the standard deviation remains 10. Multiplying scores by 1.1 (10% increase) would make the new mean 77 and new standard deviation 11.

🔑 Important: Data exploration helps identify outliers, understand data spread, and choose appropriate statistical methods.

4. Set theory and basic probability concepts (part 1)

4.1 Sets and their operations

  • A set is a collection of distinct objects.
  • Sets are defined by listing elements or by a rule.
  • A = {e, f, g} (listing)
  • B=x∣1≤x≤10B = {x | 1 ≤ x ≤ 10} (rule)
  • An object e is an element of set A if e ∈ A.
  • The order of elements in a set does not matter.
  • Duplicate elements are ignored: {a, b, c, a} is the same as {a, b, c}.

📝 Example: If Z = {(x, y) | x ∈ {1, 2, 3, 4}, y = x^2}, then Z = {(1, 1), (2, 4), (3, 9), (4, 16)}.

4.2 Subsets

  • Set G is a subset of set H (G ⊂ H) if every element of G is also in H.
  • This is analogous to ≤≤ for numbers.
  • Any set is a subset of itself (G ⊂ G).

📝 Example: If G = {1, 3, 5} and H = {1, 3, 5, 9}, then G ⊂ H 54.

4.3 Intersection

  • The intersection of two sets (L ∩ M) contains elements present in both sets.
  • P=x∣0≤x≤10P = {x | 0 ≤ x ≤ 10} and Q = {x | 5 < x < 20}.
  • P∩Q=x∣5<x≤10P ∩ Q = {x | 5 < x ≤ 10}.
  • 5 is not in P ∩ Q, but 10 is.

4.4 Mutually exclusive sets

  • Mutually exclusive sets (or disjoint sets) are sets whose intersection is the empty set.
  • The empty set (∅ or {}) has no members.
  • Example: {a, b, c} and {d, e, f} are mutually exclusive, their intersection is ∅.

4.5 Universal set and sample space

  • The universal set (S) contains all objects under consideration in a given problem.
  • In statistics, S is called the sample space.
  • Example: For traffic light colors, S = {red, amber, green}.

4.6 Union

  • The union of two sets (A ∪ B) contains elements that belong to either set A or set B (or both).
  • A = {1, 2, 3} and B = {2, 3, 4, 5}.
  • A ∪ B = {1, 2, 3, 4, 5} 55.

4.7 Complement

  • The complement of a set A (written A) is the set of elements in the sample space S that are not in A.
  • S = {1, 2, 3, 4, 5, 6} and A = {1, 3, 5}.
  • A = {2, 4, 6}.

📝 Example: If S=x∣0≤x≤1S = {x | 0 ≤ x ≤ 1} and D = {x | 0 < x < 1}, then D = {0, 1} 56.

4.8 Venn diagrams

  • Venn diagrams visually represent sets using circles within a rectangle (the sample space).
  • Intersection (∩) is shown by overlapping areas.
  • Union (∪) is shown by combining areas.
  • Mutually exclusive sets have no overlapping areas.
  • Venn diagrams are useful for up to three sets.

4.9 Pairwise mutually exclusive and exhaustive sets

  • A collection of sets (A1, A2,..., An) is pairwise mutually exclusive if Ai ∩ Aj = ∅ for any i ≠ j.
  • The collection is exhaustive if their union covers the entire sample space (A1 ∪ A2 ∪... ∪ An = S).
  • When both conditions are met, the sets partition the sample space without overlap.

4.10 Basic probability concepts

  • A random experiment is a procedure with an unpredictable outcome but a known set of possible outcomes.
  • The sample space (S) is the set of all possible outcomes of a random experiment.
  • A trial is one performance of the random experiment.

📝 Example: Tossing a coin: S = {heads, tails}. Dialing a random phone number and asking about TV watching: S = {yes, no, won't say, number engaged, no reply} 63.

4.11 Events

  • An event is any subset of the sample space S.
  • The impossible event is the empty set (∅).
  • The certain event is the sample space itself (S).
  • An elementary event is an event with exactly one member.
  • Events A and B are mutually exclusive if A ∩ B = ∅.

🔑 Important: The sample space must contain the most detailed possible outcomes. For example, "one up & one down" is not detailed enough if it can be represented as "UD" or "DU" 64.

4.12 Kolmogorov's axioms of probability

  • Andrey Kolmogorov established the theoretical foundation for probability theory in 1933.
  • For any event A in sample space S, the probability Pr(A) is a real number with these properties:
  1. 0≤Pr(A)≤10 ≤ Pr(A) ≤ 1 for all A ⊂ S.
  2. Pr(S) = 1 (the certain event has probability 1).
  3. If A ∩ B = ∅ (mutually exclusive events), then Pr(A ∪ B) = Pr(A) + Pr(B).
  • A consequence is Pr(∅) = 0 (the impossible event has probability 0).

🔑 Important: Probability is a function that maps a set (event) to a number between 0 and 1.

4.13 Relative frequencies

  • The relative frequency of an event A in n trials is r/n, where r is the number of times A occurred.
  • Probability can be viewed as the relative frequency of an event as the number of trials approaches infinity: Pr(A)=lim(r/n)Pr(A) = lim (r/n) as n→∞n → ∞ 66.

🔑 Important: As the number of trials increases, relative frequencies tend to converge towards the true probability.

4.14 Useful theorems

  • Theorem 1 (Complement Rule): For any event A, Pr(A) = 1 - Pr(A).
  • Theorem 2: For any events A and B, Pr(A) = Pr(A ∩ B) + Pr(A ∩ B). This also implies Pr(A ∩ B) = Pr(A) - Pr(A ∩ B).
  • Theorem 3 (Addition Rule): For any events A and B, Pr(A ∪ B) = Pr(A) + Pr(B) - Pr(A ∩ B).
  • Theorem 4: If B ⊂ A, then Pr(B)≤Pr(A)Pr(B) ≤ Pr(A).
  • Theorem 5 (General Addition Rule): If A1, A2,..., An are pairwise mutually exclusive, then Pr(A1 ∪ A2 ∪... ∪ An) = Pr(A1) + Pr(A2) +... + Pr(An).

🔑 Important: These theorems provide rules for calculating probabilities of combined events.

🔑 Important: Understanding set theory operations like union, intersection, and complement is fundamental to defining and calculating probabilities of various events. Kolmogorov's axioms provide the mathematical bedrock for probability theory 68.

4.15 Probability axioms and calculations

  • Probability of a union: For any number of events A1,A2,...,AnA_1, A_2,..., A_n, the probability of their union is the sum of their individual probabilities, minus the sum of probabilities of pairwise intersections, plus the sum of probabilities of triple intersections, and so on. Pr(⋃i=1nAi)=∑iPr(Ai)−∑i<jPr(Ai∩Aj)+∑i<j<kPr(Ai∩Aj∩Ak)−⋯+(−1)n−1Pr(A1∩⋯∩An)\text{Pr}\left(\bigcup_{i=1}^{n} A_i\right) = \sum_{i} \text{Pr}(A_i) - \sum_{i<j} \text{Pr}(A_i \cap A_j) + \sum_{i<j<k} \text{Pr}(A_i \cap A_j \cap A_k) - \dots + (-1)^{n-1}\text{Pr}(A_1 \cap \dots \cap A_n).

  • Complementary event probability: The probability of an event not occurring is one minus the probability of it occurring. Pr(Aˉ)=1−Pr(A)\text{Pr}(\bar{A}) = 1 - \text{Pr}(A).

  • Intersection probability derivation: The probability of the intersection of two events can be found using their individual probabilities and the probability of their union. Pr(A∩B)=Pr(A)+Pr(B)−Pr(A∪B)\text{Pr}(A \cap B) = \text{Pr}(A) + \text{Pr}(B) - \text{Pr}(A \cup B).

  • Union probability formula: The probability of the union of two events is the sum of their individual probabilities minus the probability of their intersection. Pr(A∪B)=Pr(A)+Pr(B)−Pr(A∩B)\text{Pr}(A \cup B) = \text{Pr}(A) + \text{Pr}(B) - \text{Pr}(A \cap B).

📝 Example: Given Pr(A) = 0.5, Pr(B) = 0.6, and Pr(A ∩ B) = 0.3.

  • Pr(B) = 1 - 0.6 = 0.4
  • Pr(A ∩ B) = 0.5 - 0.3 = 0.2
  • Pr(A ∪ B) = 0.5 + 0.6 - 0.3 = 0.8 .

🔑 Important: The sum of probabilities of all elementary events that make up a sample space must equal 1.

4.16 Equally probable elementary events

  • Calculating probability: If all elementary events in a sample space are equally likely, the probability of an event is the ratio of favorable elementary events to the total number of elementary events. Pr(A)=number of elementary events in Anumber of elementary events in S=n(A)n(S)=n(A)N\text{Pr}(A) = \frac{\text{number of elementary events in A}}{\text{number of elementary events in S}} = \frac{n(A)}{n(S)} = \frac{n(A)}{N}.

  • Probability of elementary event: When there are NN equally probable elementary events in a sample space SS, each event has a probability of 1/N1/N 69.

4.17 Steps to compute probabilities

  1. Determine the sample space SS and its total number of elementary events, N=n(S)N = n(S).
  2. Identify the event AA, which is a subset of SS, and count its elementary events, n(A)n(A).
  3. Calculate the probability as Pr(A)=n(A)/N\text{Pr}(A) = n(A)/N.

🔑 Important: This method is applicable when all elementary events in the sample space have an equal chance of occurring 70.

4.18 Permutations and combinations for counting

  • Permutations: The number of different ways to arrange nn distinguishable objects in order is n!n! (n factorial). n!=n×(n−1)×⋯×3×2×1n! = n \times (n-1) \times \dots \times 3 \times 2 \times 1.

  • Permutations of n objects taken r at a time: The number of ways to choose and arrange rr objects from a set of nn distinguishable objects is given by the formula (n)r(n)_r. (n)r=n!(n−r)!(n)_r = \frac{n!}{(n-r)!}.

🔑 Important: Permutations are used when the order of selection matters.

ConceptFormula/Definition
Factorial of nn objectsn!n!
Permutations of nn objects taken rr(n)r=n!(n−r)!(n)_r = \frac{n!}{(n-r)!}

📝 Example: If 10 people are present and a camera can only take pictures of 3 at a time, the number of different pictures possible (where rearrangement counts as different) is calculated using permutations of 10 objects taken 3 at a time: 3=10!(10−3)!=10×9×8=720 _3 = \frac{10!}{(10-3)!} = 10 \times 9 \times 8 = 720 10.

🔑 Important: Understanding permutations and combinations is crucial for calculating probabilities in scenarios with equally probable outcomes, especially when listing all elementary events is impractical. 71 72.

5. Set theory and basic probability concepts (part 2)

5.1 Counting principles

This section covers rules for counting arrangements and selections of objects. These are fundamental for calculating probabilities.

  • Permutations: Order matters.
  • Combinations: Order does not matter.

The choice between permutations and combinations depends on whether the arrangement of selected items is significant.

5.2 Permutations and combinations without repetition

  • Permutations of n objects taken r at a time: The number of ways to order rr items chosen from nn distinct items, without replacement. P(n,r)=n!(n−r)!P(n, r) = \frac{n!}{(n-r)!}.
  • Combinations of n objects taken r at a time: The number of ways to choose a set of rr items from nn distinct items, without replacement. This is also known as the binomial coefficient. (nr)=n!r!(n−r)!\binom{n}{r} = \frac{n!}{r!(n-r)!}.

The number of rr-element subsets from a set of nn elements is (nr)\binom{n}{r}.

  • Example: Forming a 9-person team from 15 people involves combinations. (159)=5005\binom{15}{9} = 5005.
  • Example: Dealing a bridge hand (13 cards from 52) uses combinations. (5213)=635,013,559,600\binom{52}{13} = 635,013,559,600 73.

5.3 Permutations and combinations with repetition

  • Permutations with repetition: The number of ways to arrange rr items chosen from nn types of objects, where repetition is allowed. nrn^r.
  • Example: Four-digit numbers can be formed using 10 digits (0-9) with repetition. 104=10,00010^4 = 10,000 74.
  • Combinations with repetition: The number of ways to select rr items from nn types of objects, where repetition is allowed and order doesn't matter. (n+r−1r)\binom{n+r-1}{r}.
  • Example: Buying three tins of jam from 10 types, with repetition allowed. (10+3−13)=(123)=220\binom{10+3-1}{3} = \binom{12}{3} = 220 75.

5.4 Extended counting rules

These rules handle more complex arrangements and selections.

  • Rule 6: Arrangements of nn items with n1n_1 of one kind and n2n_2 of another (n1+n2=nn_1 + n_2 = n). n!n1!n2!=(nn1)=(nn2)\frac{n!}{n_1! n_2!} = \binom{n}{n_1} = \binom{n}{n_2}.
  • Multinomial coefficient: Used for partitioning a set into kk distinct subsets.
\dots n_k!}$$ where $\sum_{i=1}^{k} n_i = n$. * <span style="color: #ff9f29; font-weight: 700;">Rule 7:</span> Number of ways to choose $k$ combinations of sizes $n_1, n_2, \dots, n_k$ from $n$ items. $$\binom{n}{n_1, n_2, \dots, n_k}$$. * <span style="color: #ff9f29; font-weight: 700;">Rule 8:</span> Number of distinguishable arrangements of $n$ items of $k$ types ($n_1, \dots, n_k$). $$\binom{n}{n_1, n_2, \dots, n_k}$$ [76](#page=76). * <span style="color: #ff9f29; font-weight: 700;">Example:</span> Arranging 6 cushions (4 yellow, 2 red) on a couch. $$\binom{6}{4, 2} = \frac{6!}{4!2!} = 15$$. * <span style="color: #ff9f29; font-weight: 700;">Example:</span> Splitting a committee of 12 into subcommittees of 3, 4, and 5 members. $$\binom{12}{3, 4, 5} = \frac{12!}{3!4!5!} = 27,720$$ [77](#page=77). ## 5.5 Conditional probability Conditional probability updates the probability of an event based on new information. * <span style="color: #ff9f29; font-weight: 700;">Definition:</span> The conditional probability of event B given event A has occurred is: $$P(B|A) = \frac{P(A \cap B)}{P(A)}$$ This is valid only if $P(A) \neq 0$. * <span style="color: #ff9f29; font-weight: 700;">Intuition:</span> When event A occurs, the sample space effectively reduces to A. The probability of B is then the proportion of A that also includes B. * <span style="color: #ff9f29; font-weight: 700;">Example:</span> The probability of drawing the King of Clubs given that the card is a club. $$P(\text{King of Clubs} | \text{Club}) = \frac{P(\text{King of Clubs} \cap \text{Club})}{P(\text{Club})} = \frac{1/52}{13/52} = \frac{1}{13}$$ [81](#page=81). ## 5.6 Bayes' Theorem Bayes' theorem relates conditional probabilities $P(A|B)$ and $P(B|A)$. * <span style="color: #ff9f29; font-weight: 700;">Theorem:</span> For two events A and B: $$P(A|B) = \frac{P(B|A) P(A)}{P(B|A) P(A) + P(B|\bar{A}) P(\bar{A})}$$ (where $\bar{A}$ denotes the complement of event A). * <span style="color: #ff9f29; font-weight: 700;">Application:</span> It allows updating beliefs (probabilities) when new evidence emerges. * <span style="color: #ff9f29; font-weight: 700;">Example:</span> A manufacturer finds a defective tube. What is the probability it was made in-house? Let D = defective, C = made in-house. $P(D|C) = 0.06$, $P(D|\bar{C}) = 0.08$, $P(C) = 0.8$. $$P(C|D) = \frac{P(D|C) P(C)}{P(D|C) P(C) + P(D|\bar{C}) P(\bar{C})} = \frac{0.06 \times 0.8}{0.06 \times 0.8 + 0.08 \times 0.2} = 0.75$$ [83](#page=83). > Bayes' Theorem allows revising probabilities based on new data. ## 5.7 Independent events Two events are independent if the occurrence of one does not affect the probability of the other. * <span style="color: #ff9f29; font-weight: 700;">Definition:</span> Events A and B are independent if: $$P(A \cap B) = P(A) \times P(B)$$. * <span style="color: #ff9f29; font-weight: 700;">Intuition:</span> The probability of both events happening is simply the product of their individual probabilities. * <span style="color: #ff9f29; font-weight: 700;">Relationship to conditional probability:</span> If A and B are independent, then $P(B|A) = P(B)$ and $P(A|B) = P(A)$ [85](#page=85). * <span style="color: #ff9f29; font-weight: 700;">Key Distinction:</span> * <span style="color: #ff9f29; font-weight: 700;">Mutually exclusive events</span> cannot happen at the same time (e.g., heads and tails on one coin toss). * <span style="color: #ff9f29; font-weight: 700;">Independent events</span> do not influence each other's likelihood. Independent events are never mutually exclusive (unless one probability is 0). * <span style="color: #ff9f29; font-weight: 700;">Example:</span> The probability that a microchip is manufactured perfectly (A) and installed correctly (B). If $P(A) = 0.98$ and $P(B) = 0.93$, and they are independent: $$P(A \cap B) = 0.98 \times 0.93 = 0.9114$$ [86](#page=86). > Independence means $P(A \cap B) = P(A)P(B)$, while mutual exclusivity means $P(A \cap B) = 0$. > **🔑 Important:** Understanding counting rules is crucial for calculating event probabilities, especially for complex scenarios like committee selections or arrangements. Conditional probability and independence are key to updating and interpreting these probabilities. ## 5.8 Defining sample spaces and events * A <span style="color: #ff9f29; font-weight: 700;">sample space</span> (S) is the set of all possible outcomes of a random experiment. * An <span style="color: #ff9f29; font-weight: 700;">event</span> is a subset of the sample space, representing a specific outcome or set of outcomes. > The sample space is the universe of possibilities for an experiment. | Event Type | Description | Example Notation | |:----------------- |:----------------------------------------------- |:----------------------- | | Union (A ∪ B) | At least one of the events occurs. | Either A or B or both. | | Intersection (A ∩ B) | Both events A and B occur. | Only A and B together. | | Complement (A') | Event A does not occur. | Not A. | | Disjoint events (A ∩ B = ∅) | Events that cannot occur at the same time. | Mutually exclusive. | * The probability of the union of two events A and B is given by: $$ \text{Pr}(A \cup B) = \text{Pr}(A) + \text{Pr}(B) - \text{Pr}(A \cap B) $$. * If events are disjoint, their intersection has a probability of zero: $$ \text{Pr}(A \cup B) = \text{Pr}(A) + \text{Pr}(B) \quad \text{if } A \cap B = \emptyset $$. * The probability of any event cannot exceed 1. For any events A and B: $$ \text{Pr}(A \cap B) \le \text{Pr}(A) \le \text{Pr}(A \cup B) $$. > For any events A and B, $Pr(A) + Pr(B) = 0.8$ does not imply anything about their intersection. ## 5.9 Calculating probabilities * Probabilities can be calculated based on given data, using formulas for unions and intersections. * For example, if $\text{Pr}(A) = 0.3$, $\text{Pr}(B) = 0.4$, and $\text{Pr}(A \cap B) = 0.2$: * Probability of A or B: $\text{Pr}(A \cup B) = 0.3 + 0.4 - 0.2 = 0.5$. * Probability of A not B: $\text{Pr}(A \setminus B) = \text{Pr}(A) - \text{Pr}(A \cap B) = 0.3 - 0.2 = 0.1$. * Probability of neither A nor B: $\text{Pr}((A \cup B)') = 1 - \text{Pr}(A \cup B) = 1 - 0.5 = 0.5$. * Probability of exactly one of A or B: $\text{Pr}(A \setminus B) + \text{Pr}(B \setminus A) = 0.1 + (0.4 - 0.2) = 0.3$. > Probabilities must be non-negative and cannot exceed 1. Assigning negative probabilities like Pr(C) = -0.1 is impossible. * If events are mutually exclusive, the probability of the conditional event is zero: $$ \text{Pr}(A|B) = 0 \quad \text{if } A \cap B = \emptyset $$. ## 5.10 Conditional probability * Conditional probability, $\text{Pr}(A|B)$, is the probability of event A occurring given that event B has already occurred. * The formula is: $$ \text{Pr}(A|B) = \frac{\text{Pr}(A \cap B)}{\text{Pr}(B)} $$. * Bayes' theorem can be used to reverse conditional probabilities. For example, to find $\text{Pr}(\text{trick coin | tails})$: $$ \text{Pr}(\text{trick coin | tails}) = \frac{\text{Pr}(\text{tails | trick coin}) \times \text{Pr}(\text{trick coin})}{\text{Pr}(\text{tails})} $$. > Pr(passing economics | failed statistics) can be calculated if Pr(failed statistics) and Pr(passing economics ∩ failed statistics) are known. ## 5.11 Permutations and combinations * <span style="color: #ff9f29; font-weight: 700;">Permutations</span> are used to count arrangements where order matters. The number of permutations of $n$ items taken $r$ at a time is $P(n, r) = \frac{n!}{(n-r)!}$. * <span style="color: #ff9f29; font-weight: 700;">Combinations</span> are used to count selections where order does not matter. The number of combinations of $n$ items taken $r$ at a time is $C(n, r) = \binom{n}{r} = \frac{n!}{r!(n-r)!}$. > Order matters for permutations, not for combinations. | Scenario | Calculation Type | Formula | |:--------------------------------------------- |:--------------------- |:---------------------------------------- | | Arranging all 8 items | Permutation (n=r) | $8!$ | | Selecting 3 items from 25 where order matters | Permutation | $P(25, 3) = \frac{25!}{(25-3)!}$ | | Selecting 3 items from 25 where order doesn't | Combination | $C(25, 3) = \binom{25}{3}$ | | Picking 7 items with replacement (order matters) | Power Rule | $7^3$ | | Picking 7 items without replacement (order matters) | Permutation | $P(7, 3) = \frac{7!}{(7-3)!}$ | | Picking 7 items without replacement (order doesn't) | Combination | $C(7, 3) = \binom{7}{3}$ | | Picking 7 items with replacement (order doesn't) | Combination with Rep. | $C(7+3-1, 3) = \binom{9}{3}$ | [88](#page=88)> A six-digit telephone number with no repeated digits, not starting with zero, has a probability of $\frac{P(9,5)}{10^6}$. ## 5.12 More complex probability calculations * Problems can involve multiple stages or conditions, requiring careful application of probability rules. * Examples include calculating the probability of specific card hands or outcomes from sequential events. * Probability of a bridge hand with 3 spades, 4 diamonds, 1 heart, and 5 clubs: $$ \frac{\binom{13}{3} \binom{13}{4} \binom{13}{1} \binom{13}{5}}{\binom{52}{13}} $$. > Calculating probabilities for complex scenarios often involves breaking down the problem into smaller, manageable steps using combinations and conditional probabilities [90](#page=90). > **🔑 Important:** Understanding the difference between permutations and combinations, and knowing when to apply each, is crucial for solving many probability problems. > **🔑 Important:** Always check if assigned probabilities are valid (between 0 and 1) and if unions of events are possible without exceeding a probability of 1. # 6. Probability distributions (part 1) ## 6.1 Random variables A <span style="color: #ff9f29; font-weight: 700;">random variable</span> is a numerical variable whose value depends on the outcome of a random experiment. It can be thought of as a function mapping the sample space of an experiment to the real numbers [97](#page=97). - Statisticians use capital letters near the end of the alphabet, like X, to denote random variables. - Small letters (x, a, b) represent specific values a random variable can take. - Events concerning random variables are subsets of the real line, such as $X = 1$ or $5 \leq X \leq 10$. > The particular value a random variable takes on is determined by the random experiment's result. ## 6.2 Examples of random variables Here are a few scenarios illustrating how random variables are assigned numerical values: * <span style="color: #ff9f29; font-weight: 700;">Rolling a die:</span> The outcome of each face (1 to 6) is the random variable's value. * <span style="color: #ff9f29; font-weight: 700;">Tossing a coin 3 times:</span> The random variable can be the count of heads (0, 1, 2, or 3). * <span style="color: #ff9f29; font-weight: 700;">Drawing two coins:</span> The random variable is the total monetary value of the two coins drawn [98](#page=98). * <span style="color: #ff9f29; font-weight: 700;">Snooker player's shot:</span> The value of the ball pocketed (1 for red, 2-7 for colors) is the random variable. * <span style="color: #ff9f29; font-weight: 700;">Car salesperson's commission:</span> The total commission earned based on car models sold (E, B, or Lost) is the random variable. ## 6.3 Discrete vs. Continuous random variables Random variables are classified into two main types, each requiring different mathematical treatments: * <span style="color: #ff9f29; font-weight: 700;">Discrete random variables:</span> Take on isolated values, usually integers. * Examples: Number of customers, number of occupied tables, number of clients visited. * <span style="color: #ff9f29; font-weight: 700;">Continuous random variables:</span> Can be measured to any degree of accuracy. Their possible values typically form an interval. * Examples: Distance traveled, proportion of gold, volume of milk, waiting time [99](#page=99). > The distinction between discrete and continuous is critical for choosing the correct mathematical approach. ## 6.4 Probability mass functions (PMFs) A <span style="color: #ff9f29; font-weight: 700;">probability mass function</span> (PMF), denoted by $p(x)$, describes discrete random variables. It assigns probabilities to each possible value the variable can take. A function $p(x)$ is a PMF if it meets these conditions: * <span style="color: #ff9f29; font-weight: 700;">PMF1:</span> $p(x)$ is defined for all $x$, and non-zero only for a finite or countably infinite set of points. * <span style="color: #ff9f29; font-weight: 700;">PMF2:</span> All $p(x)$ values are between 0 and 1, inclusive ($0 \le p(x) \le 1$). * <span style="color: #ff9f29; font-weight: 700;">PMF3:</span> The sum of all $p(x)$ values equals 1 ($\sum p(x) = 1$). <span style="color: #ff9f29; font-weight: 700;">Calculating probabilities with PMFs:</span> The probability of an event $a \le X \le b$ is found by summing the PMF values for all $x$ in that range: $$ \Pr[a \le X \le b = \sum_{x=a}^{b} p(x) $$. * For integer values, $\Pr[a < X < b = \sum_{x=a+1}^{b-1} p(x)$. ## 6.5 Examples of PMFs | Scenario | Random Variable X (Value) | Probability Mass Function $p(x)$ | Notes | |:------------------------- |:----------------------------------------- |:------------------------------------------------------------------- |:---------------------------------------------------------------------- | | Unbiased die roll | Number on the upturned face (1-6) | $p(x) = 1/6$ for $x \in \{1, 2, 3, 4, 5, 6\}$ | PMF1, PMF2, PMF3 are satisfied [100](#page=100). | | Horse race odds (9-1) | Win or Lose for Susan’s Dream | $p = 9/10$, $p[1](#page=1) = 1/10$ | $p(x)$ non-zero at two points [101](#page=101). | | Geometric distribution | Number of trials until first success (1, 2, 3,...) | $p(x) = (1/2)^x$ for $x \in \{1, 2, 3, \ldots\}$ | Sum of infinite geometric series is 1. | | Binomial-like distribution | $x$ successes in 3 trials (0, 1, 2, 3) | $p(x) = \binom{3}{x} 0.5^3$ for $x \in \{0, 1, 2, 3\}$ | Valid PMF; represents 3 coin flips [103](#page=103). | | Specific discrete function | Values $x=1, 2, 3, 4, 5$ | $p(x) = x/15$ for $x \in \{1, 2, 3, 4, 5\}$ | Checked for PMF conditions; $\sum p(x) = 1$ [102](#page=102). | > PMFs are like a blueprint for how probabilities are distributed across the possible outcomes of a discrete random variable. ## 6.6 Probability density functions (PDFs) A <span style="color: #ff9f29; font-weight: 700;">probability density function</span> (PDF), denoted by $f(x)$, describes continuous random variables. Instead of assigning probabilities to specific points (which is zero for continuous variables), PDFs define the relative likelihood of a variable falling within a certain range. A function $f(x)$ is a PDF if it meets these conditions: * <span style="color: #ff9f29; font-weight: 700;">PDF1:</span> $f(x)$ is defined for all $x$. * <span style="color: #ff9f29; font-weight: 700;">PDF2:</span> All $f(x)$ values are non-negative ($0 \le f(x) < \infty$). * <span style="color: #ff9f29; font-weight: 700;">PDF3:</span> The total area under the curve of $f(x)$ equals 1 ($\int_{-\infty}^{\infty} f(x) dx = 1$). <span style="color: #ff9f29; font-weight: 700;">Calculating probabilities with PDFs:</span> Probabilities for continuous random variables are found by integrating the PDF over the specified interval. The area under the curve represents the probability: $$ \Pr[c \le X \le d = \int_{c}^{d} f(x) dx $$ [105](#page=105). > For continuous variables, probabilities are represented by areas under the curve, not by points. > **🔑 Important:** The core difference between PMFs and PDFs is that PMFs sum probabilities for discrete outcomes, while PDFs integrate to find probabilities over continuous intervals. ## 6.7 Probability density functions A <span style="color: #ff9f29; font-weight: 700;">probability density function</span> (PDF), denoted as $f(x)$, describes the likelihood of a continuous random variable taking on a given value. For a function to be a valid PDF, it must meet three conditions: * <span style="color: #ff9f29; font-weight: 700;">PDF1</span>: $f(x)$ must be defined for all possible values of the random variable $X$. * <span style="color: #ff9f29; font-weight: 700;">PDF2</span>: $f(x)$ must always be non-negative ($f(x) \ge 0$). * <span style="color: #ff9f29; font-weight: 700;">PDF3</span>: The total area under the curve of $f(x)$ must equal 1. This is expressed mathematically as $\int_{-\infty}^{\infty} f(x) dx = 1$. > The total probability must always sum to 1. Unlike discrete random variables, the value of $f(x)$ at a specific point does not represent the probability of $X$ equalling that exact value. Instead, probabilities for continuous variables are calculated by integrating the PDF over an interval. > For continuous random variables, $Pr(c \le X \le d) = Pr(c < X \le d) = Pr(c \le X < d) = Pr(c < X < d) = \int_{c}^{d} f(x) dx$. The probability of a continuous random variable taking on any single exact value is always zero. Here's a comparison of different PDF examples and their properties: | Example Name | PDF Formula | Range | Check for PDF3 (Integral = 1) | |:------------- |:---------------------------------------- |:------------ |:--------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Example 20A | $f(x) = 4$ | $0 \le x \le 0.25$ | $\int_{0}^{0.25} 4 \, dx = [4x]_{0}^{0.25} = 4(0.25) - 4= 1$ | | Example 21B | $f(x) = 20x^3(1-x)$ | $0 \le x \le 1$ | $\int_{0}^{1} (20x^3 - 20x^4) \, dx = [5x^4 - 4x^5]_{0}^{1} = (5^4 - 4[1](#page=1)^5) - = 5 - 4 = 1$ | | Example 22B | $f(x) = \frac{1}{2500}(10-x)^3$ | $0 \le x \le 10$ | $\int_{0}^{10} \frac{1}{2500}(10-x)^3 \, dx = \frac{1}{2500} [-\frac{1}{4}(10-x)^4]_{0}^{10} = \frac{1}{2500} [0 - (-\frac{1}{4}[10](#page=10)^4)] = \frac{10000}{10000} = 1$ | | Example 23B | $f(x) = 6x(1-x)$ | $0 \le x \le 1$ | $\int_{0}^{1} 6(x-x^2) \, dx = 6 [\frac{1}{2}x^2 - \frac{1}{3}x^3]_{0}^{1} = 6 (\frac{1}{2} - \frac{1}{3}) = 6(\frac{1}{6}) = 1$ | | Example 24B | $f(x) = ke^{-x/2}$ | $0 \le x < \infty$ | $\int_{0}^{\infty} ke^{-x/2} \, dx = k [-2e^{-x/2}]_{0}^{\infty} = k (0 - (-2)) = 2k = 1 \implies k = 1/2$ | [106](#page=106)## 6.2 Using PDFs for probability calculations Probability calculations with PDFs involve integrating the function over the specified range. > The key is to integrate $f(x)$ between the lower and upper bounds of the event of interest. Here are examples of calculating probabilities: > **📝 Example:** For $f(x) = 20x^3(1-x)$ on $0 \le x \le 1$: > * Probability of between 30% and 50% survival: > $Pr[0.3 < X < 0.5 = \int_{0.3}^{0.5} 20x^3(1-x) \, dx = [5x^4 - 4x^5]_{0.3}^{0.5} \approx 0.157$. > * Probability of less than 10% survival: > $Pr[X < 0.1 = \int_{0}^{0.1} 20x^3(1-x) \, dx = [5x^4 - 4x^5]_{0}^{0.1} \approx 0.00046$. We can also determine required parameters or tank sizes using PDFs. > **📝 Example:** For $f(x) = \frac{1}{2500}(10-x)^3$ on $0 \le x \le 10$: > * Probability of sales between 3000 and 5000 litres: > $Pr[3 \le X \le 5 = \int_{3}^{5} \frac{1}{2500}(10-x)^3 \, dx \approx 0.1776$ [107](#page=107). > * Probability of sales less than 2000 litres: > $Pr[0 \le X \le 2 = \int_{0}^{2} \frac{1}{2500}(10-x)^3 \, dx \approx 0.5904$. > * Probability of exceeding 7000 litres: > $Pr[X \ge 7 = \int_{7}^{10} \frac{1}{2500}(10-x)^3 \, dx \approx 0.0081$. > * To be 98% certain of meeting demand, we need a tank of size $c$ such that $Pr[0 \le X \le c = 0.98$. This results in $c \approx 6.24$, so a 6240 litre tank is needed. > **📝 Example:** For $f(x) = 6x(1-x)$ on $0 \le x \le 1$: > * Probability $0 \le X \le 0.2$: > $Pr[0 \le X \le 0.2 = \int_{0}^{0.2} 6x(1-x) \, dx = 0.104$. > * Probability $0.4 \le X \le 0.6$: > $Pr[0.4 \le X \le 0.6 = \int_{0.4}^{0.6} 6x(1-x) \, dx = 0.296$. > **🔑 Important:** The shape of a PDF can vary widely; the only constraints are non-negativity and an area under the curve of 1 [109](#page=109). > **🔑 Important:** For continuous random variables, the probability of the variable equalling a single exact value is zero. Probabilities are always calculated over intervals [108](#page=108) [110](#page=110). # 7. Probability distributions (part 2) ## 7.1 The binomial distribution * <span style="color: #ff9f29; font-weight: 700;">Scenario:</span> Used for experiments with a fixed number of independent trials, each having two outcomes (success/failure), and a constant probability of success. * <span style="color: #ff9f29; font-weight: 700;">Random Variable:</span> Counts the number of successes in 'n' trials. * <span style="color: #ff9f29; font-weight: 700;">Parameters:</span> * `n`: The number of trials. * `p`: The probability of success in a single trial. * <span style="color: #ff9f29; font-weight: 700;">Notation:</span> $X \sim B(n, p)$ ### Binomial probability mass function (PMF) * The probability of observing exactly 'x' successes in 'n' trials is: $$ p(x) = \binom{n}{x} p^x (1 - p)^{n-x} \quad \text{for } x = 0, 1, \dots, n $$ * $\binom{n}{x}$ represents the number of ways to choose 'x' successes from 'n' trials. * `p^x` is the probability of 'x' successes. * `(1-p)^(n-x)` is the probability of `n-x` failures. > The binomial distribution describes the count of successes in a fixed series of independent yes/no events. * <span style="color: #ff9f29; font-weight: 700;">Example:</span> A salesperson makes 6 calls. Each client buys with a 0.2 probability, independently. The number of clients who buy follows a $B(6, 0.2)$ distribution [120](#page=120). * The probability of exactly 2 clients buying is $\binom{6}{2} (0.2)^2 (0.8)^4 = 0.2458$ [121](#page=121). ### Binomial distribution properties * It is a valid PMF because: * `p(x)` is always non-negative. * The sum of all probabilities equals 1, due to the binomial theorem: $\sum_{x=0}^{n} \binom{n}{x} p^x (1 - p)^{n-x} = (p + (1-p))^n = 1^n = 1$. * <span style="color: #ff9f29; font-weight: 700;">Shape:</span> The distribution's shape depends on `n` and `p`. * When `p = 0.5`, it's symmetric [122](#page=122). * As `p` moves away from 0.5, the distribution becomes skewed [123](#page=123). #### Binomial process conditions: * Fixed number of trials (`n`). * Each trial has two outcomes (success/failure). * Independent trials. * Constant probability of success (`p`) [119](#page=119). ## 7.2 The Poisson distribution * <span style="color: #ff9f29; font-weight: 700;">Scenario:</span> Models the number of events occurring in a fixed interval of time or space, given a constant average rate, when events occur "at random." * <span style="color: #ff9f29; font-weight: 700;">Random Variable:</span> Counts the number of events in a specified interval. * <span style="color: #ff9f29; font-weight: 700;">Parameter:</span> * `λ` (lambda): The average rate of events per interval. * <span style="color: #ff9f29; font-weight: 700;">Notation:</span> $X \sim P(\lambda)$. ### Poisson probability mass function (PMF) * The probability of observing exactly 'x' events in an interval is: $$ p(x) = \frac{e^{-\lambda} \lambda^x}{x!} \quad \text{for } x = 0, 1, 2, \dots $$ * `e` is the base of the natural logarithm. * The time period for the rate `λ` must match the interval for counting events. > The Poisson distribution counts random events in a fixed period or space, using the average rate. * <span style="color: #ff9f29; font-weight: 700;">Example:</span> Truck breakdowns average 2.4 per day. The number of breakdowns on a given day follows $P(2.4)$. * The probability of no breakdowns is $p = \frac{e^{-2.4} (2.4)^0}{0!} = 0.0907$ . ### Poisson distribution properties * It is a valid PMF. The sum of probabilities is 1, based on the Taylor series expansion of $e^\lambda$ [126](#page=126). * <span style="color: #ff9f29; font-weight: 700;">Relationship to Binomial:</span> The Poisson distribution can be seen as a limiting case of the binomial distribution when `n` is very large and `p` is very small, such that $n \times p \approx \lambda$ [127](#page=127). #### Poisson process conditions: * Events occur randomly in time or space. * Average rate of occurrence (`λ`) is constant [124](#page=124). * The interval for counting events matches the interval for the rate `λ` [125](#page=125). ## 7.3 The exponential distribution * <span style="color: #ff9f29; font-weight: 700;">Scenario:</span> Models the time or distance *between* events that occur in a Poisson process. * <span style="color: #ff9f29; font-weight: 700;">Random Variable:</span> The time (or distance) between consecutive events. * <span style="color: #ff9f29; font-weight: 700;">Parameter:</span> * `λ` (lambda): The average rate of events (same `λ` as in the Poisson distribution). * <span style="color: #ff9f29; font-weight: 700;">Notation:</span> $X \sim E(\lambda)$. ### Exponential probability density function (PDF) * The probability density function for the time 'x' between events is: $$ f(x) = \lambda e^{-\lambda x} \quad \text{for } x \ge 0 $$ * This distribution is continuous. > The exponential distribution measures the waiting time between random events, using the event rate. * <span style="color: #ff9f29; font-weight: 700;">Example:</span> Computer breakdowns occur at an average rate of 1.5 per week ($\lambda = 1.5$). The time between breakdowns follows $E(1.5)$. * The probability of no breakdowns for 2 weeks (meaning the time between breakdowns is > 2 weeks) is: $$ P(X > 2) = \int_{2}^{\infty} 1.5 e^{-1.5x} dx = [-e^{-1.5x}]_{2}^{\infty} = 0 - (-e^{-3}) = e^{-3} \approx 0.0498 $$. ### Exponential distribution properties * It is a valid PDF. * `f(x)` is non-negative for $x \ge 0$. * The integral over its support is 1: $\int_{0}^{\infty} \lambda e^{-\lambda x} dx = 1$ [129](#page=129). * <span style="color: #ff9f29; font-weight: 700;">Memoryless Property:</span> The probability of an event occurring in the future does not depend on how much time has already passed. $P(X > t+s | X > t) = P(X > s)$. #### Exponential process conditions: * Events occur according to a Poisson process. * The random variable is the time or distance *between* these events [128](#page=128). ## 7.4 The normal distribution * Often called the Gaussian distribution. * This distribution is continuous. * It is characterized by its mean ($\mu$) and standard deviation ($\sigma$). * The probability density function is bell-shaped and symmetric around the mean. * It is fundamental in statistics and arises from the Central Limit Theorem. ### Normal probability density function (PDF) * The PDF is given by: $$ f(x) = \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2} \quad \text{for } -\infty < x < \infty $$ * `μ`: The mean of the distribution, which is also the peak of the curve. * `σ`: The standard deviation, which measures the spread of the distribution. * `π` (pi) is approximately 3.14159. > The normal distribution is a symmetric, bell-shaped curve essential for modeling many natural phenomena. * The standard normal distribution has $\mu = 0$ and $\sigma = 1$, denoted as $Z$. ### Normal distribution properties * It is a valid PDF, integrating to 1. * <span style="color: #ff9f29; font-weight: 700;">Symmetry:</span> The curve is symmetric about its mean ($\mu$). * <span style="color: #ff9f29; font-weight: 700;">Empirical Rule (68-95-99.7 Rule):</span> * Approximately 68% of the data falls within one standard deviation of the mean ($\mu \pm \sigma$). * Approximately 95% falls within two standard deviations ($\mu \pm 2\sigma$). * Approximately 99.7% falls within three standard deviations ($\mu \pm 3\sigma$). #### Key concepts: * <span style="color: #ff9f29; font-weight: 700;">Parameters:</span> Mean ($\mu$) and standard deviation ($\sigma$). * <span style="color: #ff9f29; font-weight: 700;">Shape:</span> Bell-shaped and symmetric [130](#page=130). > **🔑 Important:** The normal distribution is crucial because many natural phenomena and sums of random variables tend to follow it, even if the individual components do not. > The binomial, Poisson, exponential, and normal distributions are foundational models for various probability and statistical problems. # 8. Probability distributions (part 3) ## 8.1 The Normal Distribution The <span style="color: #ff9f29; font-weight: 700;">normal distribution</span> is a fundamental continuous probability distribution in statistics. It is often approximated for phenomena that are sums of many independent random variables, such as exam scores or tree heights. The probability density function (PDF) for the normal distribution is: $$f(x) = \frac{1}{\sqrt{2\pi\sigma^2}} e^{-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2}$$ where: * `µ` (mu) is the mean, determining the location of the distribution's center. * `σ` (sigma) is the standard deviation, indicating the spread of the distribution. * `σ²` is the variance. The normal distribution is characterized by its bell shape. The peak is at the mean `µ`, and the distribution becomes flatter as `σ` increases. ## 8.2 Standard Normal Distribution * <span style="color: #ff9f29; font-weight: 700;">Notation:</span> `X ∼ N(µ, σ²)` means X follows a normal distribution with mean `µ` and variance `σ²`. * <span style="color: #ff9f29; font-weight: 700;">Standard Normal Distribution:</span> This is a special case where `µ = 0` and `σ = 1`, denoted as `Z ∼ N(0, 1)`. Its PDF is $f(z) = \frac{1}{\sqrt{2\pi}} e^{-\frac{1}{2}z^2}$. * <span style="color: #ff9f29; font-weight: 700;">Key Property:</span> Probabilities for any normal distribution can be calculated using tables for the standard normal distribution. This is because the proportion of the area between the mean and a certain number of standard deviations away is constant. * <span style="color: #ff9f29; font-weight: 700;">Transformation:</span> A value `x` from a normal distribution `N(µ, σ²)` can be transformed into a z-score for the standard normal distribution using the formula: $z = \frac{x - \mu}{\sigma}$ [134](#page=134). ## 8.3 Using Normal Distribution Tables Probabilities for the normal distribution are found using tables of the standard normal distribution. Since the normal distribution is symmetric, tables typically provide areas between 0 and a given z-score. * <span style="color: #ff9f29; font-weight: 700;">Area between mean and `x`:</span> $Pr[µ ≤ X ≤ x]$ is equivalent to $Pr[0 ≤ Z ≤ (x-µ)/σ]$. * <span style="color: #ff9f29; font-weight: 700;">Area for `X < a`:</span> `Pr[X < a]` is equivalent to `Pr[Z < (a-µ)/σ]`. For negative z-scores, use symmetry: `Pr[Z < -z = Pr[Z > z = 0.5 - Pr[0 < Z < z]`. * <span style="color: #ff9f29; font-weight: 700;">Area between `a` and `b`:</span> $Pr[a ≤ X ≤ b]$ is equivalent to $Pr[(a-µ)/σ ≤ Z ≤ (b-µ)/σ]$. > The area within 1 standard deviation of the mean is ~68%. > The area within 2 standard deviations of the mean is ~95%. > The area within 3 standard deviations of the mean is ~99.7%. ## 8.4 Calculations with Normal Distributions | Boundary Value (x) | z-score ($z = \frac{x - \mu}{\sigma}$) | Area from Table (Pr[0 < Z < |z|]) | Proportion | |:----------------- |:----------------------------------- |:---------------------------------- |:--------- | | S (80 cm) | -2.4 | 0.4918 | 0.1505% | | M (87 cm) | -1.0 | 0.3413 | 0.4967% | | L (94 cm) | 0.4 | 0.1554 | 0.3087% | | XL (101 cm) | 1.8 | 0.4641 | 0.0352% | | (108 cm) | 3.2 | 0.4993 | N/A | * <span style="color: #ff9f29; font-weight: 700;">T-shirt Sizes Example:</span> To find the proportion of customers fitting each size, z-scores are calculated for the boundaries. The areas under the standard normal curve between these z-scores give the proportions for each size. * S: Pr(Z < -2.4) = 0.5 - 0.4918 = 0.0082 (Oops, there's a calculation mismatch in source: 0.4918 - 0.3413 = 0.1505 from source. ). * M: Pr(-1.0 < Z < 0.4) = Pr(0 < Z < 1.0) + Pr(0 < Z < 0.4) = 0.3413 + 0.1554 = 0.4967. * L: Pr(0.4 < Z < 1.8) = Pr(0 < Z < 1.8) - Pr(0 < Z < 0.4) = 0.4641 - 0.1554 = 0.3087. * XL: Pr(Z > 1.8) = 0.5 - 0.4641 = 0.0359 (Oops, source says 0.4993 - 0.4641 = 0.0352. ) [136](#page=136). ## 8.5 Percentage Points * <span style="color: #ff9f29; font-weight: 700;">Definition:</span> The `p%` point of the standard normal distribution, denoted `z(p)`, is the value of `z` such that `Pr[Z > z = p`. * <span style="color: #ff9f29; font-weight: 700;">Finding `z(p)`:</span> Look up the probability `p` (or `0.5 - p` for lower tail probabilities) in the body of the standard normal table to find the corresponding z-score. > Example: To find the 10% point (`z(0.10)`), look for 0.40 (since 0.50 - 0.10 = 0.40) in the table. This corresponds to `z = 1.28` [140](#page=140). ## 8.6 Operations with Normal Distributions ## 8.7 Sums and Differences of Independent Normal Variables If independent random variables `Xi` are normally distributed, their sum or difference is also normally distributed. * <span style="color: #ff9f29; font-weight: 700;">Sum:</span> If $X_i \sim N(\mu_i, \sigma_i^2)$ are independent, then $Y = \sum_{i=1}^{n} X_i \sim N(\sum \mu_i, \sum \sigma_i^2)$. The new mean is the sum of means, and the new variance is the sum of variances. * <span style="color: #ff9f29; font-weight: 700;">Difference:</span> If $X_1 \sim N(\mu_1, \sigma_1^2)$ and $X_2 \sim N(\mu_2, \sigma_2^2)$ are independent, then $Z = X_1 - X_2 \sim N(\mu_1 - \mu_2, \sigma_1^2 + \sigma_2^2)$. The mean is the difference of means, but the variance is still the sum of variances. > **🔑 Important:** Always add variances, never subtract them, when combining independent normal random variables. ## 8.8 Multiplying a Normal Variable by a Constant If $X \sim N(\mu, \sigma^2)$, then for constants `a` and `b`, the variable $Y = aX + b$ is also normally distributed: $Y \sim N(a\mu + b, a^2\sigma^2)$. * <span style="color: #ff9f29; font-weight: 700;">Transformation:</span> This rule is used to convert values between different units (e.g., inches to centimeters) or scales (e.g., Celsius to Fahrenheit). > **📝 Example:** Converting heights from inches to centimeters. If heights `X` in inches are `N(67, 16)`, then heights `Y` in centimeters (where $Y = 2.54X$) are `N(2.54 \times 67, 2.54^2 \times 16) = N(170.2, 103.2)`. ## 8.9 Key Properties and Applications | Concept | Description | Page Reference | |:---------------------- |:---------------------------------------------------------------------------------------------------------------------------------------- |:------------- | | Bell Shape | Symmetric, unimodal, and bell-shaped curve. || | Parameters | Mean (`µ`) for location, variance (`σ²`) or standard deviation (`σ`) for spread. || | Central Limit Theorem | States that the sum of a large number of random increments tends to follow a normal distribution. || | Standardization | Transforming any normal variable to a standard normal variable ($Z = \frac{X - \mu}{\sigma}$) for table lookups. || | Symmetry | The normal distribution is symmetric about its mean. This simplifies probability calculations. | [135](#page=135) | | Area under curve | Represents probability; the total area under the PDF is 1. Areas within standard deviations from the mean are constant across all normal distributions. | [133](#page=133) | | Sums/Differences | Independent normal variables combine to form new normal variables; variances always add. | [137](#page=137) | | Scaling | Multiplying a normal variable by a constant `a` scales its mean by `a` and its variance by `a²`. | [139](#page=139) | > **🔑 Important:** The normal distribution is central to statistics due to the Central Limit Theorem and its use in approximating other distributions and modeling real-world phenomena [131](#page=131) [132](#page=132). ## 8.10 Mean, variance, and standard deviation of random variables The <span style="color: #ff9f29; font-weight: 700;">mean</span> ($\mu$ or $E[X]$) and <span style="color: #ff9f29; font-weight: 700;">variance</span> ($\sigma^2$ or $Var[X]$) of a random variable ($X$) are analogous to sample statistics but use different formulas. The <span style="color: #ff9f29; font-weight: 700;">standard deviation</span> ($\sigma$) is the square root of the variance. ## 8.11 Discrete random variables For a discrete random variable with probability mass function $p(x)$: * <span style="color: #ff9f29; font-weight: 700;">Mean ($\mu$):</span> Sum of each value multiplied by its probability. $$ \mu = E[X = \sum_{x} x p(x) $$ * <span style="color: #ff9f29; font-weight: 700;">Variance ($\sigma^2$):</span> Sum of the squared differences from the mean, weighted by probability. $$ \sigma^2 = Var[X = \sum_{x} (x - \mu)^2 p(x) $$ * <span style="color: #ff9f29; font-weight: 700;">Alternative variance formula:</span> $$ \sigma^2 = Var[X = \left( \sum_{x} x^2 p(x) \right) - \mu^2 $$. ## 8.12 Continuous random variables For a continuous random variable with probability density function $f(x)$ over an interval $(a, b)$: * <span style="color: #ff9f29; font-weight: 700;">Mean ($\mu$):</span> Integral of each value multiplied by its probability density. $$ \mu = E[X = \int_{a}^{b} x f(x) dx $$ * <span style="color: #ff9f29; font-weight: 700;">Variance ($\sigma^2$):</span> Integral of the squared differences from the mean, weighted by probability density. $$ \sigma^2 = Var[X = \int_{a}^{b} (x - \mu)^2 f(x) dx $$ $$ \sigma^2 = Var[X = \int_{a}^{b} x^2 f(x) dx - \mu^2 $$. ## 8.13 Linear transformations and coefficient of variation * <span style="color: #ff9f29; font-weight: 700;">Linear transformation of $Y = aX + b$</span>: * Mean: $E[Y = a\mu + b$ * Variance: $Var(Y) = a^2\sigma^2$ * <span style="color: #ff9f29; font-weight: 700;">Coefficient of Variation (CV)</span>: Ratio of standard deviation to the mean. Sensible only if the lower limit of $X$ is zero. $$ CV = \frac{\sigma}{\mu} $$ Often expressed as a percentage. ## 8.14 Properties of random variables and distributions The provided pages focus on definitions and formulas for mean and variance. While the chapter overview mentions normal approximations to binomial and Poisson distributions, the specific details for these approximations are not within pages 145-150. The exercises on pages 145-147 touch upon applying binomial, Poisson, and normal distributions to solve practical problems [145](#page=145) [146](#page=146) [147](#page=147). > **🔑 Important:** Understanding the formulas for mean and variance is crucial, as these are fundamental properties that describe the center and spread of any probability distribution [149](#page=149) [150](#page=150). # 9. Probability distributions (part 4) ## 9.1 Distribution functions and medians The <span style="color: #ff9f29; font-weight: 700;">distribution function</span>, denoted $F(x)$, gives the probability that a random variable $X$ is less than or equal to $x$. - For a continuous random variable: $F(x) = \int_{-\infty}^{x} f(t) dt$. - For a discrete random variable: $F(x) = \sum_{t \leq x} p(t)$. The derivative of the distribution function of a continuous random variable is its probability density function: $F'(x) = f(x)$. For discrete variables, $F(x)$ is a step function [155](#page=155). ### Calculating distribution functions > **📝 Example:** For an exponential distribution with parameter $\lambda$, the distribution function is $F(x) = 1 - e^{-\lambda x}$ for $x \geq 0$. > **📝 Example:** For a binomial distribution $X \sim B(3, 0.2)$, the distribution function $F(x)$ is a step function with values like $F = 0.512$ and $F = 0.896$ [1](#page=1) [156](#page=156). ### The median of a random variable The <span style="color: #ff9f29; font-weight: 700;">median</span> ($x_m$) of a random variable is the value where $F(x_m) = 0.5$. > **🔑 Important:** The mean and median coincide only for symmetric distributions. * <span style="color: #ff9f29; font-weight: 700;">Continuous variables:</span> The median is found by solving $\int_{-\infty}^{x_m} f(x) dx = 0.5$. * <span style="color: #ff9f29; font-weight: 700;">Discrete variables:</span> The median is the lowest value of $x$ for which $F(x) \geq 0.5$ [158](#page=158). > **📝 Example:** The median of an exponential distribution is $x_m = 0.6931/\lambda$. ## 9.2 Approximating discrete distributions with the normal distribution The normal distribution can approximate binomial and Poisson distributions under certain conditions. This allows calculating probabilities for discrete variables using continuous normal distribution tables. ### Conditions for normal approximation * <span style="color: #ff9f29; font-weight: 700;">Binomial distribution:</span> If $X \sim B(n, p)$, use $N(np, np(1-p))$ when $np > 5$ and $n(1-p) > 5$, and $0.1 < p < 0.9$. * <span style="color: #ff9f29; font-weight: 700;">Poisson distribution:</span> If $X \sim P(\lambda)$, use $N(\lambda, \lambda)$ when $\lambda > 10$. The approximating normal distribution shares the same mean and variance as the discrete distribution. ### Applying the approximation To approximate probabilities for a discrete variable $X$ using a continuous normal variable $Y$: > **PROCEDURE FOR USING THE APPROXIMATIONS** > If the random variable X has a binomial or Poisson distribution and satisfies the conditions for being approximated by a normally distributed random variable Y, then > $\text{Pr}[a \leq X \leq b = \text{Pr}[a - 0.5 < Y < b + 0.5]$. This "continuity correction" adjusts the interval for the continuous distribution. > **📝 Example:** For $X \sim B(20, 0.5)$, approximating with $Y \sim N(10, 5)$, the probability $\text{Pr}[X = 15]$ is approximated by $\text{Pr}[14.5 < Y < 15.5]$ [160](#page=160). > **📝 Example:** For $X \sim P $, approximating with $Y \sim N(25, 25)$, the probability $\text{Pr}[X \geq 30]$ is approximated by $\text{Pr}[Y > 29.5]$ [25](#page=25) [161](#page=161). > **🔑 Important:** Normal approximation simplifies calculations for binomial and Poisson distributions, especially for large $n$ or $\lambda$ [159](#page=159). # 10. Advanced probability distributions and concepts ## 10.1 Negative binomial and geometric distributions The <span style="color: #ff9f29; font-weight: 700;">negative binomial distribution</span> models situations with independent trials, each having a "success" or "failure" outcome with a fixed probability of success, $p$. Instead of fixing the number of trials, we fix the number of successes, $r$. The random variable $X$ counts the number of failures observed *before* reaching the $r$-th success. - <span style="color: #ff9f29; font-weight: 700;">Probability Mass Function (PMF):</span> $$ p(x) = \binom{x+r-1}{x} p^r q^x, \quad x = 0, 1, 2, \dots $$ where $q = 1-p$. This formula counts $x$ failures and $r$ successes, with the $r$-th success occurring on the $(x+r)$-th trial. - <span style="color: #ff9f29; font-weight: 700;">Geometric Distribution:</span> A special case of the negative binomial distribution where $r=1$. It models the number of failures before the first success. - <span style="color: #ff9f29; font-weight: 700;">PMF:</span> $p(x) = pq^x$, for $x = 0, 1, 2, \dots$. > **🔑 Important:** The negative binomial name comes from a mathematical theorem, not from negative outcomes; there's nothing inherently negative about the distribution itself [170](#page=170). ## 10.2 Hypergeometric distribution The <span style="color: #ff9f29; font-weight: 700;">hypergeometric distribution</span> is used when sampling *without replacement* from a finite population. Unlike the binomial distribution, the probability of success changes with each draw. - <span style="color: #ff9f29; font-weight: 700;">Scenario:</span> A population of size $N$ has $M$ defective items. A sample of size $n$ is drawn. $X$ is the number of defective items in the sample. - <span style="color: #ff9f29; font-weight: 700;">Probability Mass Function (PMF):</span> $$ p(x) = \frac{\binom{M}{x}\binom{N-M}{n-x}}{\binom{N}{n}}, \quad x = 0, 1, \dots, n $$ This formula represents choosing $x$ defectives from $M$ and $n-x$ non-defectives from $N-M$. - <span style="color: #ff9f29; font-weight: 700;">Binomial Approximation:</span> If the sample size $n$ is small compared to the population size $N$ (specifically, $n/N < 0.1$), the binomial distribution can approximate the hypergeometric distribution with $p = M/N$. > **📝 Example:** A fisherman caught 10 lobsters, 3 of which were undersized. If 4 lobsters are randomly sampled, the probability of finding no undersized lobsters is $\frac{\binom{3}{0}\binom{7}{4}}{\binom{10}{4}} = 0.1667$ [173](#page=173). ## 10.3 Uniform distribution The <span style="color: #ff9f29; font-weight: 700;">uniform distribution</span> is the simplest continuous distribution. It models situations where all values within a given interval $(a, b)$ are equally likely. - <span style="color: #ff9f29; font-weight: 700;">Probability Density Function (PDF):</span> $$ f(x) = \frac{1}{b-a}, \quad a \le x \le b $$ and $f(x) = 0$ otherwise [174](#page=174). - <span style="color: #ff9f29; font-weight: 700;">Properties:</span> - <span style="color: #ff9f29; font-weight: 700;">Mean:</span> $E[X = \frac{1}{2}(b+a)$. - <span style="color: #ff9f29; font-weight: 700;">Variance:</span> $\text{Var}[X = \frac{(b-a)^2}{12}$. - <span style="color: #ff9f29; font-weight: 700;">Distribution Function (CDF):</span> $F(x) = \frac{x-a}{b-a}$ for $a \le x \le b$. > **📝 Example:** If a tub of margarine's mass is uniformly distributed between 495g and 510g, the probability it weighs less than 500g is $\frac{500-495}{510-495} = \frac{5}{15} = \frac{1}{3}$ [175](#page=175). ## 10.4 Distribution functions, medians, skewness, and approximations Beyond basic distributions, understanding their characteristics is crucial. - <span style="color: #ff9f29; font-weight: 700;">Distribution Function (CDF):</span> For any random variable, $F(x) = P(X \le x)$, it describes the probability that the variable takes on a value less than or equal to $x$[168](#page=168). - <span style="color: #ff9f29; font-weight: 700;">Median ($x_m$):</span> The value where $F(x_m) = 0.5$. For symmetric distributions, the median equals the mean[167](#page=167). - <span style="color: #ff9f29; font-weight: 700;">Skewness:</span> Measures the asymmetry of a distribution. Symmetric distributions have zero skewness. - <span style="color: #ff9f29; font-weight: 700;">Normal Approximation to Binomial/Poisson:</span> - For a binomial distribution $B(n, p)$ with large $n$, if $np > 5$ and $n(1-p) > 5$, it can be approximated by a normal distribution $N(np, np(1-p))$. - For a Poisson distribution $P(\lambda)$ with large $\lambda$ (typically $\lambda > 10$), it can be approximated by a normal distribution $N(\lambda, \lambda)$ [164](#page=164). > **🔑 Important:** Using approximations for large $n$ or $\lambda$ simplifies calculations for binomial and Poisson distributions, making it easier to find probabilities for events in their tails [165](#page=165) [166](#page=166). > **🔑 Important:** For symmetric distributions, the mean, median, and mode coincide [163](#page=163). # 11. Statistical inference: Means, variances, and hypothesis testing (part 1) ## 11.1 Population parameters and sample statistics * Population mean ($\mu$) and variance ($\sigma^2$) describe entire groups. These are fixed, but often impossible to calculate directly. * A <span style="color: #ff9f29; font-weight: 700;">statistic</span> is a value calculated from a random sample. * The sample mean ($\bar{x}$ or $X$) is a common statistic used to estimate $\mu$ [181](#page=181). ## 11.2 Sampling distributions * The sample mean ($X$) is a <span style="color: #ff9f29; font-weight: 700;">random variable</span> because its value varies with the sample. * The probability distribution of a statistic is called its <span style="color: #ff9f29; font-weight: 700;">sampling distribution</span>. ## 11.3 Distribution of the sample mean * If the population is normally distributed with mean $\mu$ and variance $\sigma^2$, then the sample mean $X$ follows a normal distribution: $X \sim N(\mu, \sigma^2/n)$ [182](#page=182). * The <span style="color: #ff9f29; font-weight: 700;">Central Limit Theorem</span> states that for a large sample size ($n \ge 30$), the sampling distribution of $X$ is approximately normal, regardless of the population distribution: $X \approx N(\mu, \sigma^2/n)$. * This theorem implies that the sample mean is likely to be close to the population mean, making it a good estimator [183](#page=183). > The sample mean's distribution is approximately normal if the sample size is large, regardless of the population's shape. ## 11.4 Confidence intervals for the population mean * A <span style="color: #ff9f29; font-weight: 700;">point estimate</span> (like the sample mean $\bar{x}$) is a single value estimate. This is often insufficient due to its variability. * A <span style="color: #ff9f29; font-weight: 700;">confidence interval</span> provides a range of plausible values for the population mean ($\mu$). * A 95% confidence interval means there's a 0.95 probability that the method used will produce an interval containing the true $\mu$ [184](#page=184). ## 11.5 Constructing a confidence interval ( $\sigma^2$ known) * For large samples or normally distributed populations, we use the Z-distribution: $Z = (X - \mu) / (\sigma / \sqrt{n}) \sim N(0, 1)$. * The formula for a confidence interval for $\mu$ when $\sigma^2$ is known is: $(\bar{x} - z^* \frac{\sigma}{\sqrt{n}}, \bar{x} + z^* \frac{\sigma}{\sqrt{n}})$. * $z^*$ is the critical value from the standard normal distribution corresponding to the desired confidence level [185](#page=185) [186](#page=186). | Confidence Level | $z^*$ Value | |:--------------- |:---------- | | 90% | 1.64 | | 95% | 1.96 | | 98% | 2.33 | | 99% | 2.58 | > Wider intervals offer higher confidence but less precision. ## 11.6 Determining sample size * To achieve a desired accuracy (margin of error $L$) at a certain confidence level, the required sample size ($n$) is calculated as: $n = (z^* \sigma / L)^2$. * Always round the sample size up to the next integer [187](#page=187). > Increasing sample size narrows the confidence interval, improving precision without changing the confidence level. ## 11.7 Hypothesis testing for the mean ( $\sigma^2$ known) * <span style="color: #ff9f29; font-weight: 700;">Hypothesis testing</span> is a formal procedure to examine claims about population parameters using sample data. * The process involves assuming a claim is true (the null hypothesis) and then determining how likely the observed sample data is under that assumption. ## 11.8 The basic approach * Assume the manufacturer's claim (e.g., $\mu = 100$ hours) is true. * Calculate how extreme the observed sample mean ($\bar{x}$) is compared to the claimed mean ($\mu$), often using a test statistic like $Z$. * If the observed result is very unlikely under the assumed claim (low probability), we reject the claim [188](#page=188). > If a claimed mean leads to a very improbable sample mean, reject the claim. > **🔑 Important:** Statistical inference allows us to draw conclusions about populations using sample data, balancing uncertainty with decision-making. ## 11.9 Hypothesis testing framework Hypothesis testing is a method to determine if sample data provides enough evidence to reject a claim about a population parameter. This process involves setting up competing hypotheses and using statistical tests to make a decision. - <span style="color: #ff9f29; font-weight: 700;">Null hypothesis (H0)</span>: A statement about the population parameter, often a claim to be disproven. - <span style="color: #ff9f29; font-weight: 700;">Alternative hypothesis (H1)</span>: A statement accepted if H0 is rejected. > The null hypothesis is what we assume to be true until evidence suggests otherwise. ## 11.10 Steps for hypothesis testing 1. <span style="color: #ff9f29; font-weight: 700;">Set up null hypothesis (H0)</span>: State the claim about the population parameter, usually an equality. 2. <span style="color: #ff9f29; font-weight: 700;">Specify alternative hypothesis (H1)</span>: State what you will accept if H0 is rejected. 3. <span style="color: #ff9f29; font-weight: 700;">Choose a significance level (α)</span>: This is the probability of rejecting H0 when it is actually true. Common levels are 0.05 (5%) or 0.01 (1%). 4. <span style="color: #ff9f29; font-weight: 700;">Determine the rejection region</span>: Identify the range of test statistic values that lead to rejecting H0. This depends on H1's form (one-sided or two-sided) and α. 5. <span style="color: #ff9f29; font-weight: 700;">Calculate the test statistic</span>: Compute the value from sample data using an appropriate formula. 6. <span style="color: #ff9f29; font-weight: 700;">State conclusions</span>: Decide whether the test statistic falls into the rejection region. If so, reject H0 and accept H1. > Hypothesis testing requires defining hypotheses and significance level *before* analyzing data. ## 11.11 One-sided vs. two-sided alternatives - <span style="color: #ff9f29; font-weight: 700;">One-sided alternative</span>: Used when there's a specific direction of change suspected (e.g., H1: µ < 100 or H1: µ > 100). The rejection region is in one tail of the distribution. - <span style="color: #ff9f29; font-weight: 700;">Two-sided alternative</span>: Used when any significant difference from the hypothesized value is of interest (e.g., H1: µ ≠ 100). The rejection region is split between both tails of the distribution. > Always use a two-sided alternative unless there's a strong theoretical reason for a one-sided test. ## 11.12 Type I and Type II errors * <span style="color: #ff9f29; font-weight: 700;">Type I Error</span>: Rejecting a true null hypothesis. Its probability is the significance level (α). * <span style="color: #ff9f29; font-weight: 700;">Type II Error</span>: Accepting a false null hypothesis. Its probability is difficult to control and depends on how far H0 is from the true situation. | Decision | H0 True | H0 False | |:----------------- |:----------- |:----------- | | Do not reject H0 | Correct | Type II Error | | Reject H0 | Type I Error | Correct | ## 11.13 Test statistic for population mean (known population variance) When the population variance ($\sigma^2$) is known, the test statistic for a population mean ($\mu$) follows a standard normal distribution ($Z \sim N(0,1)$). $$ Z = \frac{\bar{X} - \mu_0}{\sigma / \sqrt{n}} $$ Where: * $\bar{X}$ is the sample mean. * $\mu_0$ is the hypothesized population mean (from H0). * $\sigma$ is the population standard deviation. * $n$ is the sample size. > This formula essentially standardizes the difference between the sample mean and the hypothesized population mean. ## 11.14 Example: Testing a single population mean A sample of 50 individuals had a mean score of 95.5. The population mean is claimed to be 100, with a population standard deviation of 12. Test this claim at a 5% significance level, with an alternative hypothesis of H1: µ < 100. 1. H0: $\mu = 100$ 2. H1: $\mu < 100$ 3. Significance level: $\alpha = 0.05$ 4. Rejection region: For a one-sided test (lower tail) at $\alpha = 0.05$, reject H0 if $Z < -1.64$. 5. Test statistic: $Z = \frac{95.5 - 100}{12 / \sqrt{50}} = -2.65$. 6. Conclusion: Since $-2.65 < -1.64$, we reject H0. The evidence suggests the true mean is less than 100 [189](#page=189). ## 11.15 Example: Two-sided mean test A farmer suspects a new fertilizer may alter tomato yield. The old fertilizer gave an average yield of 2.5 tons/ha with a standard deviation of 0.53 tons/ha. The new fertilizer yielded 2.65 tons/ha over 35 plots. Test if the new fertilizer significantly changes yield at a 5% level. 1. H0: $\mu = 2.5$ 2. H1: $\mu \neq 2.5$ (two-sided) 4. Rejection region: For a two-sided test at $\alpha = 0.05$, reject H0 if $|Z| > 1.96$. 5. Test statistic: $Z = \frac{2.65 - 2.5}{0.53 / \sqrt{35}} = 1.67$. 6. Conclusion: Since $1.67$ is not greater than $1.96$ (nor less than -1.96), we do not reject H0. The new fertilizer's effect is not statistically significant [191](#page=191). > A decision to fire a typist (Example 7B) involved a one-sided test (H1: µ < 30) at a stricter 1% significance level. The calculated Z-value of -1.92 was not less than the critical value of -2.33, so H0 was not rejected [190](#page=190). ## 11.16 Comparing two sample means (known population variances) When comparing the means of two independent populations with known variances, the distribution of the difference between sample means ($\bar{X}_1 - \bar{X}_2$) follows a normal distribution. $$ \bar{X}_1 - \bar{X}_2 \sim N(\mu_1 - \mu_2, \sigma_1^2/n_1 + \sigma_2^2/n_2) $$ The test statistic for the difference in means is: $$ Z = \frac{(\bar{X}_1 - \bar{X}_2) - (\mu_1 - \mu_2)_0}{\sqrt{\sigma_1^2/n_1 + \sigma_2^2/n_2}} $$ * $\bar{X}_1, \bar{X}_2$ are sample means. * $n_1, n_2$ are sample sizes. * $\sigma_1, \sigma_2$ are population standard deviations. * $(\mu_1 - \mu_2)_0$ is the hypothesized difference in population means (often 0 for H0: $\mu_1 = \mu_2$). > This test helps determine if there's a significant difference between the average values of two groups. ## 11.17 Example: Comparing athlete's times An athlete's average 8km time last year was 30.42 minutes ($n_1=49, \sigma_1=0.78$ min). This year, the average is 30.26 minutes ($n_2=35, \sigma_2=0.65$ min). Test for a reduction in time at a 5% significance level. 1. H0: $\mu_1 = \mu_2$ (or $\mu_1 - \mu_2 = 0$) 2. H1: $\mu_1 > \mu_2$ (or $\mu_1 - \mu_2 > 0$) 4. Rejection region: For a one-sided test (greater than) at $\alpha = 0.05$, reject H0 if $Z > 1.64$. 5. Test statistic: $Z = \frac{(30.42 - 30.26) - 0}{\sqrt{0.78^2/49 + 0.65^2/35}} = 1.02$. 6. Conclusion: Since $1.02$ is not greater than $1.64$, we do not reject H0. There is no statistically significant reduction in the athlete's time [193](#page=193). ## 11.18 Example: Comparing driver routes Two drivers' route times were recorded: | Driver | Number of Observations ($n$) | Average Time ($\bar{X}$) | Standard Deviation ($\sigma$) | |:----- |:--------------------------- |:----------------------- |:---------------------------- | | 1 | 38 | 20.3 minutes | 3.7 minutes | | 2 | 43 | 22.5 minutes | 4.1 minutes | Test which route is quicker at a 5% significance level. 1. H0: $\mu_1 - \mu_2 = 0$ 2. H1: $\mu_1 - \mu_2 \neq 0$ (two-sided) 5. Test statistic: Calculation would proceed using the Z-formula for two means. 6. Conclusion: A comparison based on the calculated Z-value would determine if one driver's route is significantly quicker [194](#page=194). > 🔑 **Important:** The Z-test for comparing two means assumes known population variances, which is often unrealistic in practice. Later topics will cover scenarios with unknown variances. # 12. Statistical inference: Means, variances, and hypothesis testing (part 2) ## 12.1 Hypothesis testing using the z-statistic Hypothesis testing involves setting up a null hypothesis ($H_0$) and an alternative hypothesis ($H_1$). The significance level ($\alpha$) determines the threshold for rejecting $H_0$. > The six-point plan provides a structured approach to hypothesis testing. ## 12.2 The six-point plan for hypothesis testing This classical approach involves: * Defining the null and alternative hypotheses. * Setting the significance level ($\alpha$). * Determining the rejection region for the test statistic. * Calculating the observed test statistic from the data. * Drawing a conclusion based on whether the test statistic falls within the rejection region. ## 12.3 The p-value approach An alternative method uses a p-value. * The p-value is the probability of observing a test statistic as extreme as, or more extreme than, the one calculated from the data, assuming $H_0$ is true. * A small p-value indicates evidence against $H_0$. * Conventionally, $H_0$ is rejected if the p-value is less than $\alpha$, often set at 0.05. > A small p-value suggests the observed data are unlikely if the null hypothesis were true. ## 12.4 Calculating p-values The calculation of the p-value depends on the alternative hypothesis. * <span style="color: #ff9f29; font-weight: 700;">Upper tail test ($H_1$: parameter > value):</span> $p\text{-value} = P(Z \ge \text{test statistic } | H_0 \text{ is true})$ * <span style="color: #ff9f29; font-weight: 700;">Lower tail test ($H_1$: parameter < value):</span> $p\text{-value} = P(Z \le \text{test statistic } | H_0 \text{ is true})$ * <span style="color: #ff9f29; font-weight: 700;">Two-tailed test ($H_1$: parameter $\ne$ value):</span> The area in the tail corresponding to the test statistic is calculated and multiplied by 2. > The p-value quantifies the strength of evidence against the null hypothesis. ## 12.5 Z-tests for means The z-test is used to test hypotheses about population means when the population standard deviation ($\sigma$) is known or when the sample size is large. * <span style="color: #ff9f29; font-weight: 700;">Test statistic:</span> $z = \frac{\bar{X} - \mu_0}{\sigma/\sqrt{n}}$ * $\bar{X}$: sample mean * $\mu_0$: hypothesized population mean * $\sigma$: population standard deviation * $n$: sample size | Scenario | Null Hypothesis ($H_0$) | Alternative Hypothesis ($H_1$) | Rejection Region (e.g., $\alpha = 0.05$) | |:------------------------------------------- |:---------------------- |:----------------------------- |:--------------------------------------- | | Testing for a difference between two means | $\mu_1 - \mu_2 = 0$ | $\mu_1 - \mu_2 \ne 0$ | $|z| > 1.96$ | | Testing for a reduced mean | $\mu = \mu_0$ | $\mu < \mu_0$ | $z < -1.64$ | | Testing for an increased mean | $\mu = \mu_0$ | $\mu > \mu_0$ | $z > 1.64$ | ## 12.6 Z-tests for proportions The z-test can also be used for testing hypotheses about population proportions. This relies on the normal approximation to the binomial distribution. * <span style="color: #ff9f29; font-weight: 700;">Conditions for approximation:</span> For a binomial distribution $B(n, p)$, the normal approximation $N(np, npq)$ is valid if $np > 5$ and $n(1-p) > 5$, and $0.1 < p < 0.9$. * <span style="color: #ff9f29; font-weight: 700;">Test statistic:</span> $z = \frac{X - np}{\sqrt{npq}}$ * $X$: observed number of successes * $n$: number of trials * $p$: hypothesized proportion from $H_0$ * $q = 1-p$ ## 12.7 Normal approximation to the Poisson distribution The normal distribution can approximate the Poisson distribution when $\lambda > 10$. * <span style="color: #ff9f29; font-weight: 700;">Test statistic:</span> $z = \frac{X - \lambda}{\sqrt{\lambda}}$ * $X$: observed Poisson count * $\lambda$: hypothesized mean rate from $H_0$ > Use the z-test when population standard deviation is known or sample size is large. ## 12.8 Confidence intervals for means Confidence intervals provide a range of plausible values for a population parameter. For a population mean ($\mu$) with known population standard deviation ($\sigma$), a confidence interval is given by: $\qquad \bar{X} \pm z_{\alpha/2} \frac{\sigma}{\sqrt{n}}$ * $z_{\alpha/2}$ is the critical value from the standard normal distribution for a given confidence level (e.g., 1.96 for 95% confidence). > Confidence intervals quantify the uncertainty in estimating a population parameter. ## 12.9 Key concepts in hypothesis testing * <span style="color: #ff9f29; font-weight: 700;">Null hypothesis ($H_0$):</span> A statement about a population parameter that is assumed to be true until evidence suggests otherwise. * <span style="color: #ff9f29; font-weight: 700;">Alternative hypothesis ($H_1$):</span> A statement that contradicts the null hypothesis. * <span style="color: #ff9f29; font-weight: 700;">Significance level ($\alpha$):</span> The probability of rejecting the null hypothesis when it is actually true (Type I error). * <span style="color: #ff9f29; font-weight: 700;">Test statistic:</span> A value calculated from sample data used to decide whether to reject $H_0$. * <span style="color: #ff9f29; font-weight: 700;">Rejection region:</span> The set of values for the test statistic that leads to rejection of $H_0$. * <span style="color: #ff9f29; font-weight: 700;">p-value:</span> The probability of obtaining results at least as extreme as the observed results, assuming $H_0$ is true. > Understanding these concepts is crucial for correctly interpreting statistical tests. > **🔑 Important:** Always formulate hypotheses *before* examining the data to avoid bias. ## 12.10 Comparing two means When comparing the means of two independent samples ($\bar{X}_1$ and $\bar{X}_2$), a test statistic for the difference ($\mu_1 - \mu_2$) can be calculated. If population variances ($\sigma_1^2$, $\sigma_2^2$) are known, the test statistic is: $z = \frac{(\bar{X}_1 - \bar{X}_2) - (\mu_1 - \mu_2)_0}{\sqrt{\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2}}}$ * $(\mu_1 - \mu_2)_0$ is the hypothesized difference in population means, often 0. A confidence interval for the difference between two means ($\mu_1 - \mu_2$) with known variances is: $(\bar{X}_1 - \bar{X}_2) \pm z_{\alpha/2} \sqrt{\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2}}$ > The z-test for two means assumes independent samples and known population variances. > **📝 Example:** To test if Course A or Course B leads to faster reading speeds, we compare the average speeds from samples of students from each course using a z-test if population standard deviations are known. ## 12.11 Hypothesis testing for parameters of binomial and Poisson distributions * <span style="color: #ff9f29; font-weight: 700;">Binomial:</span> When $np > 5$ and $n(1-p) > 5$, the binomial distribution can be approximated by a normal distribution to test hypotheses about the proportion $p$. * <span style="color: #ff9f29; font-weight: 700;">Poisson:</span> When $\lambda > 10$, the Poisson distribution can be approximated by a normal distribution to test hypotheses about the rate parameter $\lambda$. > These approximations allow us to use z-tests for non-normal distributions under specific conditions. > **🔑 Important:** These tests are for parameters ($p$, $\lambda$) of distributions, not directly for population means ($\mu$). ## 12.12 Introduction to the t-distribution (pages 205-207) When the population standard deviation ($\sigma$) is unknown and must be estimated by the sample standard deviation ($s$), the t-distribution is used instead of the z-distribution, especially for small sample sizes. * <span style="color: #ff9f29; font-weight: 700;">Origin:</span> Developed by W.S. Gosset ("Student") to handle small samples. * <span style="color: #ff9f29; font-weight: 700;">Shape:</span> Similar to the normal distribution but with heavier tails, meaning more extreme values are possible. The shape depends on the sample size. * <span style="color: #ff9f29; font-weight: 700;">Degrees of freedom (df):</span> The t-distribution's shape is determined by its degrees of freedom. For a sample of size $n$, the degrees of freedom for estimating the population variance is $n-1$. > The t-distribution accounts for the extra uncertainty introduced by estimating $\sigma$ with $s$. * <span style="color: #ff9f29; font-weight: 700;">Notation:</span> $t_{n-1}$ denotes a t-distribution with $n-1$ degrees of freedom. * <span style="color: #ff9f29; font-weight: 700;">Relationship to normal:</span> As the sample size ($n$) increases, the t-distribution approaches the standard normal distribution. > For sample sizes over 30, the t-distribution is a close approximation of the normal distribution. --- [195](#page=195). > **🔑 Important:** The t-distribution is essential for hypothesis testing and confidence intervals when the population standard deviation is unknown, particularly with small samples. ## 12.13 Confidence intervals for the mean when variance is unknown When the population variance ($\sigma^2$) is unknown and estimated by the sample variance ($s^2$), confidence intervals for the population mean ($\mu$) are calculated using the t-distribution. This is applicable when the sample is drawn from a normal distribution. * The confidence interval is given by: $$ \left( \bar{X} - t^{\ast}_{n-1} \frac{s}{\sqrt{n}}, \bar{X} + t^{\ast}_{n-1} \frac{s}{\sqrt{n}} \right) $$ where: * $\bar{X}$ is the sample mean. * $s$ is the sample standard deviation. * $n$ is the sample size. * $t^{\ast}_{n-1}$ are the critical values from the t-distribution with $n-1$ degrees of freedom. * To determine the correct $t^{\ast}$ value: * For a 95% confidence interval, use the column headed 0.025 in the t-tables. * For a 99% confidence interval, use the column headed 0.005. > **🔑 Important:** The t-distribution is used because the population standard deviation is unknown and estimated from the sample, introducing extra uncertainty. * <span style="color: #ff9f29; font-weight: 700;">Example:</span> A sample of 25 loaves of bread had a mean mass of 696 g and a standard deviation of 7 g. The 99% confidence interval for the mean mass is calculated using $t_{0.005, 24} = 2.797$. * The interval is $(696 - 2.797 \times 7/\sqrt{25}, 696 + 2.797 \times 7/\sqrt{25})$, which is (692.08 g, 699.92 g). ## 12.14 Hypothesis testing for the mean when variance is unknown Hypothesis tests for the population mean ($\mu$) when the population variance is unknown also utilize the t-distribution. The procedure follows a standard six-point plan. * <span style="color: #ff9f29; font-weight: 700;">Hypothesis Testing Steps:</span> 1. <span style="color: #ff9f29; font-weight: 700;">Null Hypothesis ($H_0$):</span> States no change or no effect (e.g., $\mu = \mu_0$). 2. <span style="color: #ff9f29; font-weight: 700;">Alternative Hypothesis ($H_1$):</span> States the suspected change or effect (e.g., $\mu > \mu_0$, $\mu < \mu_0$, or $\mu \neq \mu_0$). 3. <span style="color: #ff9f29; font-weight: 700;">Significance Level ($\alpha$):</span> The probability of rejecting $H_0$ when it is true. 4. <span style="color: #ff9f29; font-weight: 700;">Rejection Region:</span> Determined by the alternative hypothesis and the t-distribution with $n-1$ degrees of freedom. For a one-sided test, it's a single tail; for a two-sided test, it's both tails. 5. <span style="color: #ff9f29; font-weight: 700;">Test Statistic Calculation:</span> $t = \frac{\bar{X} - \mu_0}{s/\sqrt{n}}$. 6. <span style="color: #ff9f29; font-weight: 700;">Decision:</span> Reject $H_0$ if the test statistic falls into the rejection region; otherwise, fail to reject $H_0$. * <span style="color: #ff9f29; font-weight: 700;">Example:</span> A poultry farmer tests if an enriched diet increases turkey mass. * $H_0: \mu = 4.5$ kg, $H_1: \mu > 4.5$ kg, $\alpha = 0.05$. * Degrees of freedom = $20 - 1 = 19$. Critical value $t_{0.05, 19} = 1.729$. * Sample data: $\bar{X} = 4.8$ kg, $s = 0.5$ kg, $n = 20$. * Test statistic: $t = \frac{4.8 - 4.5}{0.5/\sqrt{20}} = 2.68$. * Since $2.68 > 1.729$, $H_0$ is rejected, indicating the diet is effective [209](#page=209). * <span style="color: #ff9f29; font-weight: 700;">Example:</span> A manufacturer claims an average battery life of 36 months. * $H_0: \mu = 36$ months, $H_1: \mu < 36$ months, $\alpha = 0.05$. * Degrees of freedom = $6 - 1 = 5$. Critical value $-t_{0.05, 5} = -2.015$. * Sample data: $\bar{X} = 30$ months, $s = 4$ months, $n = 6$. * Test statistic: $t = \frac{30 - 36}{4/\sqrt{6}} = -3.67$. * Since $-3.67 < -2.015$, $H_0$ is rejected, suggesting the true mean life is less than 36 months [210](#page=210). ## 12.15 Paired t-tests for dependent samples A paired t-test is used when comparing the means of two related groups. This occurs when the same subjects are measured twice (e.g., before and after an intervention) or when subjects are matched in pairs. The test is performed on the differences between the paired observations. * <span style="color: #ff9f29; font-weight: 700;">Procedure:</span> * Calculate the difference ($d$) for each pair: $d = \text{Before} - \text{After}$. * Calculate the mean ($\bar{d}$) and standard deviation ($s_d$) of these differences. * Perform a one-sample t-test on the differences, where $H_0: \mu_d = 0$. * <span style="color: #ff9f29; font-weight: 700;">Example:</span> A medicine is tested for dizziness reduction. * 10 patients' dizzy spells before and after medication were recorded. * The differences ($d$) were calculated, yielding $\bar{d} = -1.5$ and $s_d = 3.57$, $n=10$. * $H_0: \mu_d = 0$, $H_1: \mu_d > 0$, $\alpha = 0.05$. * Critical value $t_{0.05, 9} = 1.833$. * Test statistic: $t = \frac{-1.5 - 0}{3.57/\sqrt{10}} = -1.33$. * Since $-1.33 < 1.833$, $H_0$ is not rejected, indicating the medication is not effective at reducing dizzy spells [211](#page=211). * <span style="color: #ff9f29; font-weight: 700;">Confidence intervals for the mean difference:</span> * The 95% confidence interval for $\mu_d$ is: $$ \left( \bar{d} - t_{0.025, n-1} \frac{s_d}{\sqrt{n}}, \bar{d} + t_{0.025, n-1} \frac{s_d}{\sqrt{n}} \right) $$ * <span style="color: #ff9f29; font-weight: 700;">Example:</span> For the dizziness study, the 95% confidence interval for the mean difference is $(-1.5 - 2.626 \times 3.57/\sqrt{10}, -1.5 + 2.626 \times 3.57/\sqrt{10})$, which is (-4.05, 1.05). The interval contains zero, further supporting the non-rejection of $H_0$. ## 12.16 Comparing two independent sample means When comparing the means of two independent samples, if the population variances are unknown, an assumption of equal population variances is often made to use a pooled variance estimate, leading to a t-test. Without this assumption, a more complex test statistic is needed that does not necessarily follow a t-distribution. * <span style="color: #ff9f29; font-weight: 700;">General Approach for Independent Samples (equal variances assumed):</span> * Calculate sample means ($\bar{X}_1, \bar{X}_2$) and sample variances ($s_1^2, s_2^2$) for each group. * Calculate a pooled standard deviation. * The test statistic follows a t-distribution with $(n_1 + n_2 - 2)$ degrees of freedom. * <span style="color: #ff9f29; font-weight: 700;">Example:</span> Comparing yields of two wheat varieties. * Variety 1: $\bar{x}_1 = 1.60$, $s_1 = 0.42$, $n_1 = 6$. * Variety 2: $\bar{x}_2 = 1.90$, $s_2 = 0.27$, $n_2 = 5$. * The text indicates this scenario requires a specific procedure for independent samples with estimated variances. The example begins to detail the hypothesis testing steps, but the full calculation and conclusion are not provided in this excerpt [214](#page=214). > **🔑 Important:** The decision to assume equal variances significantly impacts the degrees of freedom and the calculation of the test statistic when comparing two independent sample means. > **🔑 Important:** The t-distribution is central to inference about means when population variance is unknown, used for both confidence intervals and hypothesis testing, and is adapted for paired and independent samples. # 13. Statistical inference: Means, variances, and hypothesis testing (part 3) ## 13.1 Two-sample t-tests for means The two-sample t-test compares the means of two independent groups. It requires assuming that the population variances are equal, which is tested first using the F-distribution. If this assumption holds, the sample variances are pooled to estimate a common population variance. ### 13.1.1 Pooled variance t-test When population variances ($\sigma^2_1$, $\sigma^2_2$) are assumed equal, we pool the sample variances ($s^2_1$, $s^2_2$). This provides a joint estimate of the variance ($s^2$). * <span style="color: #ff9f29; font-weight: 700;">Pooled variance formula:</span> $$s^2 = \frac{(n_1 - 1)s^2_1 + (n_2 - 1)s^2_2}{n_1 + n_2 - 2}$$ * $n_1, n_2$: Sample sizes. * $s^2_1, s^2_2$: Sample variances. * <span style="color: #ff9f29; font-weight: 700;">Degrees of freedom for pooled variance:</span> $df = n_1 + n_2 - 2$. * <span style="color: #ff9f29; font-weight: 700;">Test statistic:</span> $$t_{n_1+n_2-2} = \frac{\bar{X}_1 - \bar{X}_2 - (\mu_1 - \mu_2)}{s\sqrt{\frac{1}{n_1} + \frac{1}{n_2}}}$$ * $\bar{X}_1, \bar{X}_2$: Sample means. * $(\mu_1 - \mu_2)$: Difference in population means under the null hypothesis. * $s$: Pooled sample standard deviation ($\sqrt{s^2}$). > **Decision Rule:** Reject $H_0$ if the calculated t-statistic falls into the rejection region defined by the significance level and degrees of freedom [215](#page=215). ### 13.1.2 Example: Comparing promotions A marketing specialist compared two promotions. Sample data showed: * Promotion 1 (Free gift): $n_1=8$, $\bar{X}_1=\text{R490}$, $s_1=\text{R104}$. * Promotion 2 (Discount): $n_2=9$, $\bar{X}_2=\text{R420}$, $s_2=\text{R92}$. Testing at a 5% significance level, the null hypothesis ($H_0: \mu_1 = \mu_2$) was not rejected. The observed t-statistic (1.47) was less than the critical value (2.131) for 15 degrees of freedom. This means no significant difference in promotion effectiveness was detected [216](#page=216). ## 13.2 F-test for equality of variances The F-test is used to compare the variances of two populations. It checks the assumption of equal variances required for the pooled variance t-test. * <span style="color: #ff9f29; font-weight: 700;">Null hypothesis:</span> $H_0: \sigma^2_1 = \sigma^2_2$. * <span style="color: #ff9f29; font-weight: 700;">Alternative hypothesis:</span> $H_1: \sigma^2_1 \neq \sigma^2_2$ (two-sided) or a one-sided alternative. The test statistic is the ratio of the two sample variances. To simplify table lookups, the larger sample variance is conventionally placed in the numerator. * <span style="color: #ff9f29; font-weight: 700;">Test statistic:</span> $F = \frac{s^2_{\text{larger}}}{s^2_{\text{smaller}}}$. The F-distribution has two sets of degrees of freedom: one for the numerator ($df_{\text{num}}$) and one for the denominator ($df_{\text{den}}$). ### 13.2.1 F-distribution characteristics * The F-distribution is positively skewed. * Its shape depends on both $df_{\text{num}}$ and $df_{\text{den}}$. * Tables typically provide upper percentage points. ### 13.2.2 Using the F-test When testing $H_0: \sigma^2_1 = \sigma^2_2$, we calculate $F = s^2_1/s^2_2$ with $df_1 = n_1 - 1$ and $df_2 = n_2 - 1$. If $H_1$ is $\sigma^2_1 \neq \sigma^2_2$, we look for $F$ values in the upper and lower tails. * <span style="color: #ff9f29; font-weight: 700;">Trick for lower tail:</span> If $s^2_2 > s^2_1$, use $F = s^2_2/s^2_1$ with degrees of freedom $n_2 - 1$ and $n_1 - 1$. This uses the property $1/F_{v_1, v_2} = F_{v_2, v_1}$ [219](#page=219). > **Decision Rule:** Reject $H_0$ if the calculated F-statistic is in the rejection region. For a two-sided test at 5%, this means $F$ is too large or too small relative to the critical values [217](#page=217). ### 13.2.3 Example: Testing variance assumption In a previous example, $s_1 = 0.42$ and $s_2 = 0.27$, with sample sizes $n_1=6$ and $n_2=5$. To test $H_0: \sigma^2_1 = \sigma^2_2$ at 5%, we calculated $F = s^2_1/s^2_2 = 0.42^2 / 0.27^2 = 2.42$. This value, with $F_{5,4}$ degrees of freedom, was less than the critical value of 9.36, so $H_0$ was not rejected. The assumption of equal variances was deemed reasonable [218](#page=218). ### 13.2.4 Example: Suspected higher variability Suspecting one machine (Machine 2) is less consistent than another (Machine 1), sample variances were $s^2_1 = 2.1$ ml$^2$ and $s^2_2 = 5.9$ ml$^2$. Sample sizes were $n_1=15$ and $n_2=25$. Testing $H_0: \sigma^2_1 = \sigma^2_2$ against $H_1: \sigma^2_1 < \sigma^2_2$ at 5%: * We compute $F = s^2_2/s^2_1 = 5.9/2.1 = 2.81$. * Degrees of freedom are $F_{24,14}$. * The critical value $F_{(0.05), 24, 14}$ is 2.35. * Since $2.81 > 2.35$, $H_0$ is rejected, concluding Machine 2 has significantly larger variance. ## 13.3 Approximate t-test for unequal variances (Welch's t-test) When the F-test rejects the null hypothesis of equal variances, a modified t-test is used. This test, often called Welch's t-test, does not pool variances and adjusts the degrees of freedom. * <span style="color: #ff9f29; font-weight: 700;">Test statistic:</span> $$t^{\ast} = \frac{(\bar{X}_1 - \bar{X}_2) - (\mu_1 - \mu_2)}{\sqrt{\frac{s^2_1}{n_1} + \frac{s^2_2}{n_2}}}$$ * <span style="color: #ff9f29; font-weight: 700;">Adjusted degrees of freedom ($n^{\ast}$):</span> A complex formula estimates these degrees of freedom, which are then rounded to the nearest integer. $$n^{\ast} = \frac{\left(\frac{s^2_1}{n_1} + \frac{s^2_2}{n_2}\right)^2}{\frac{\left(\frac{s^2_1}{n_1}\right)^2}{n_1 + 1} + \frac{\left(\frac{s^2_2}{n_2}\right)^2}{n_2 + 1}} - 2$$ ### 13.3.1 Example: Comparing manager ages For senior managers of two corporations, sample data were: * Corp 1: $\bar{X}_1 = 47.80$, $s_1 = 6.86$, $n_1 = 10$. * Corp 2: $\bar{X}_2 = 45.00$, $s_2 = 3.20$, $n_2 = 10$. First, an F-test ($F_{9,9}=4.60$) indicated unequal variances ($P < 0.05$). Thus, the approximate t-test was used. * The test statistic $t^{\ast} = 1.17$. * The adjusted degrees of freedom $n^{\ast} \approx 14$. * With $df=14$, the t-statistic was not significant, so $H_0: \mu_1 = \mu_2$ was accepted. No difference in mean age was found [221](#page=221). ## 13.4 Decision tree for hypothesis testing on means A flowchart helps determine the appropriate test for means. Key factors include whether population variance is known or estimated, and the number of samples. > **Key Decision Points:** > * Is population variance known? (Use Z-test if yes, proceed if no). > * Is there one sample or two? > * For two samples with unknown variance: Test for equal variances first using F-test. > * If variances are equal: Pool variances and use standard t-test. > * If variances are unequal: Use approximate t-test (Welch's) [223](#page=223). * <span style="color: #ff9f29; font-weight: 700;">Assumptions:</span> All t-tests assume samples come from normal distributions. For small samples, non-normality invalidates these tests [222](#page=222). * <span style="color: #ff9f29; font-weight: 700;">Large samples:</span> For $n>30$, the Central Limit Theorem often allows using normal distribution even if the population is not normal. For large degrees of freedom ($>100$), the t-distribution is very close to the normal distribution [224](#page=224). > **🔑 Important:** The F-test for variances should precede any two-sample t-test when population variances are unknown. This ensures the correct t-test (pooled or approximate) is applied [220](#page=220). # 14. Chi-squared distribution and its applications ## 14.1 The chi-squared distribution and goodness of fit The chi-squared ($\chi^2$) distribution is fundamental for numerous hypothesis tests. It's essential for assessing how well data fits a theoretical distribution, analyzing categorical data in contingency tables, and testing hypotheses about population variance. The primary use of the $\chi^2$ distribution is in <span style="color: #ff9f29; font-weight: 700;">goodness-of-fit tests</span>. These tests determine if a sample comes from a population with a specific distribution, such as Poisson or Normal [233](#page=233). To perform a goodness-of-fit test: * <span style="color: #ff9f29; font-weight: 700;">Hypotheses</span>: State the null hypothesis ($H_0$) that data fits a specific distribution and the alternative hypothesis ($H_1$) that it does not. * <span style="color: #ff9f29; font-weight: 700;">Significance level</span>: Choose a level (e.g., 5%). * <span style="color: #ff9f29; font-weight: 700;">Expected frequencies ($E_i$)</span>: Calculate these based on the hypothesized distribution and sample size. If the distribution parameter (like $\lambda$ for Poisson) is unknown, estimate it from the data [234](#page=234). * <span style="color: #ff9f29; font-weight: 700;">Test statistic ($D^2$)</span>: Use the formula $D^2 = \sum \frac{(O_i - E_i)^2}{E_i}$, where $O_i$ are observed frequencies. A shortcut formula is $D^2 = \sum \frac{O_i^2}{E_i} - n$. * <span style="color: #ff9f29; font-weight: 700;">Degrees of freedom</span>: Calculated as $k - d - 1$, where $k$ is the number of cells (categories) and $d$ is the number of parameters estimated from the data. * <span style="color: #ff9f29; font-weight: 700;">Decision</span>: Reject $H_0$ if $D^2$ exceeds the critical value from the $\chi^2$ distribution table for the given degrees of freedom and significance level > **🔑 Important**: Expected frequencies should generally be at least 5. If not, combine adjacent cells to meet this condition, adjusting the degrees of freedom accordingly ## 14.2 Example: Testing for Poisson distribution Misprints per page were observed: | Number of misprints (x) | Observed pages ($O_i$) | Theoretical probability $p(x)$ | Theoretical frequency ($E_i$) | |:---------------------- |:--------------------- |:----------------------------- |:---------------------------- | | 0 | 43 | 0.3012 | 60.24 | | 1 | 69 | 0.3614 | 72.28 | | 2 | 53 | 0.2169 | 43.38 | | 3 | 21 | 0.0867 | 17.34 | | 4 | 8 | 0.0260 | 5.20 | | 5 or more | 6 | 0.0078 | 1.56 | If $H_0$ assumes $\lambda = 1.2$, the degrees of freedom are $k-1 = 6-1 = 5$. The calculated $D^2$ is 15.78, which exceeds the critical value (11.071 for $\chi^2_5$ at 5%), leading to rejection of $H_0$ [236](#page=236). If $\lambda$ is estimated from the data (mean misprints = 1.5), $d=1$. After combining categories, $k=5$, so degrees of freedom are $5-1-1=3$. The calculated $D^2$ is 1.01, which is less than the critical value (7.815 for $\chi^2_3$ at 5%), so $H_0$ is not rejected. The Poisson distribution with $\lambda=1.5$ fits the data well [237](#page=237). ## 14.3 Example: Testing for Normal distribution To test if IQ scores fit a normal distribution with estimated mean $\mu$ and standard deviation $\sigma$: * $k=4$ cells, $d=2$ parameters estimated ($\mu, \sigma$). Degrees of freedom = $4-2-1=1$. * Calculate expected frequencies using the normal distribution probabilities for each interval. * Calculate $D^2 = \sum \frac{O_i^2}{E_i} - n$ [238](#page=238). * Reject $H_0$ if $D^2 > \chi^2_{1, 0.05}$ (3.841). > **📝 Example:** For IQ data, $O_i$: {18, 87, 104, 21}. Estimated $E_i$: {22.7, 86.8, 92.7, 27.8}. $D^2 = 4.01$. Since $4.01 > 3.841$, we reject $H_0$ that the data follows a normal distribution [240](#page=240). ## 14.4 Tests of association in contingency tables Contingency tables are used to analyze the relationship between two categorical variables. The $\chi^2$ test of association determines if these variables are independent or associated. Steps for a test of association: * <span style="color: #ff9f29; font-weight: 700;">Hypotheses</span>: $H_0$: The two variables are independent. $H_1$: The two variables are associated. * <span style="color: #ff9f29; font-weight: 700;">Significance level</span>: Choose a level (e.g., 5%) [241](#page=241). * <span style="color: #ff9f29; font-weight: 700;">Expected frequencies ($E_{ij}$)</span>: Calculate for each cell in an $r \times c$ table using the formula: $$E_{ij} = \frac{(\text{row total}_i) \times (\text{column total}_j)}{\text{grand total}}$$ This assumes independence [242](#page=242). * <span style="color: #ff9f29; font-weight: 700;">Test statistic ($D^2$)</span>: Use the same formula as in goodness-of-fit: $D^2 = \sum \frac{(O_{ij} - E_{ij})^2}{E_{ij}}$ or $D^2 = \sum \frac{O_{ij}^2}{E_{ij}} - n$. * <span style="color: #ff9f29; font-weight: 700;">Degrees of freedom</span>: For an $r \times c$ table, degrees of freedom = $(r-1)(c-1)$. * <span style="color: #ff9f29; font-weight: 700;">Decision</span>: Reject $H_0$ if $D^2$ is greater than the critical value from the $\chi^2$ distribution. > **🔑 Important**: Tests of association are almost always one-sided, rejecting $H_0$ when the calculated $D^2$ is "too large," indicating a significant difference between observed and expected frequencies. ## 14.5 Example: Company size vs. performance A 3x4 contingency table relates company size (Small, Medium, Large) to performance (<0%, 0-20%, 20-40%, >40%). | Performance | Small ($O_{ij}$) | Expected ($E_{ij}$) | Medium ($O_{ij}$) | Expected ($E_{ij}$) | Large ($O_{ij}$) | Expected ($E_{ij}$) | |:---------- |:--------------- |:------------------ |:---------------- |:------------------ |:--------------- |:------------------ | | < 0% | 66 | 77.0 | 24 | 29.3 | 55 | 38.7 | | 0–20% | 90 | 85.0 | 33 | 32.4 | 37 | 42.7 | | 20–40% | 28 | 29.2 | 17 | 11.1 | 10 | 14.7 | | > 40% | 39 | 31.9 | 11 | 12.1 | 10 | 16.0 | Degrees of freedom = $(3-1)(4-1) = 6$. The critical value for $\chi^2_6$ at 5% is 12.592. The calculated $D^2 = 19.09$. Since $19.09 > 12.592$, we reject $H_0$ and conclude there is an association between company size and performance [243](#page=243). ## 14.6 Tests and confidence intervals for the variance The $\chi^2$ distribution is also used for hypothesis testing and constructing confidence intervals for the population variance ($\sigma^2$) when the population is normally distributed. ## 14.7 Hypothesis Testing for Variance * <span style="color: #ff9f29; font-weight: 700;">Hypotheses</span>: State $H_0: \sigma^2 = \sigma_0^2$ and $H_1: \sigma^2 > \sigma_0^2$, $\sigma^2 < \sigma_0^2$, or $\sigma^2 \neq \sigma_0^2$. * <span style="color: #ff9f29; font-weight: 700;">Test statistic</span>: The statistic used is $\frac{(n-1)s^2}{\sigma_0^2}$, which follows a $\chi^2$ distribution with $n-1$ degrees of freedom, where $s^2$ is the sample variance and $n$ is the sample size. * <span style="color: #ff9f29; font-weight: 700;">Decision</span>: Compare the test statistic to critical values from the $\chi^2$ distribution table. ## 14.8 Confidence Intervals for Variance A $(1-\alpha) \times 100\%$ confidence interval for $\sigma^2$ is given by: $$ \left( \frac{(n-1)s^2}{\chi^2_{\alpha/2, n-1}}, \frac{(n-1)s^2}{\chi^2_{1-\alpha/2, n-1}} \right) $$ where $\chi^2_{\alpha/2, n-1}$ and $\chi^2_{1-\alpha/2, n-1}$ are the critical values from the $\chi^2$ distribution with $n-1$ degrees of freedom [230](#page=230). > **🔑 Important**: If the population standard deviation ($\sigma$) is unknown, the t-distribution is used for means, but the $\chi^2$ distribution is still used for variances, requiring estimation of $\sigma^2$ from the sample variance $s^2$ [231](#page=231). > **🔑 Important**: The $\chi^2$ distribution is skewed, especially with low degrees of freedom. Its shape depends heavily on the degrees of freedom [235](#page=235) [239](#page=239). > **🔑 Important**: The chi-squared distribution is a cornerstone for analyzing categorical data and assessing model fit, bridging goodness-of-fit tests and contingency table analysis. ## 14.9 Introduction to chi-squared tests The chi-squared ($\chi^2$) distribution is used for several types of statistical tests. These tests assess how well observed data fits expected patterns or relationships. The distribution helps determine if observed differences are due to chance or a real effect. ## 14.10 Chi-squared goodness-of-fit test This test determines if observed data from a sample matches a known or hypothesized theoretical distribution. The null hypothesis ($H_0$) states the data fits the distribution, while the alternative ($H_1$) states it does not. The test statistic measures the discrepancy between observed and expected frequencies. > The chi-squared statistic is calculated as $\sum \frac{(O_i - E_i)^2}{E_i}$. - <span style="color: #ff9f29; font-weight: 700;">Observed frequency ($O_i$)</span>: The actual count of data in a category. - <span style="color: #ff9f29; font-weight: 700;">Expected frequency ($E_i$)</span>: The count predicted by the theoretical distribution. The degrees of freedom for this test depend on the number of categories ($k$) and any parameters estimated from the data. If $k$ categories are used and $p$ parameters are estimated, the degrees of freedom are $k - 1 - p$. This test is used for continuous and discrete distributions. ## 14.11 Chi-squared test of independence for contingency tables This test examines if there is a statistically significant association between two categorical variables. It uses a contingency table to display observed frequencies. The null hypothesis ($H_0$) assumes the two variables are independent, while the alternative ($H_1$) assumes they are dependent. - <span style="color: #ff9f29; font-weight: 700;">Contingency table</span>: A table showing the frequency distribution of two or more categorical variables. - <span style="color: #ff9f29; font-weight: 700;">Independence</span>: The occurrence of one variable does not affect the occurrence of the other. - <span style="color: #ff9f29; font-weight: 700;">Dependence</span>: The occurrence of one variable influences the occurrence of the other. Expected frequencies are calculated assuming independence. The formula for expected frequency in a cell is $\frac{\text{row total} \times \text{column total}}{\text{grand total}}$. The degrees of freedom for a contingency table with $r$ rows and $c$ columns is $(r-1)(c-1)$. > The chi-squared test for independence helps reveal relationships between categorical data. ### Example: Film processing machines A company tested three film processing machines (A, B, C). They classified films as satisfactory or unsatisfactory. The observed counts were: | | A | B | C | Total | |:---------- |:-- |:- |:- |:---- | | Satisfactory| 93 | 24 | 8 | 125 | | Unsatisfactory | 101 | 6 | 18 | 125 | | Total | 194 | 30 | 26 | 250 | The calculated $\chi^2$ statistic was 14.98 with 2 degrees of freedom. This indicated a significant dependence between the classification and the machine used. Machine B produced more satisfactory results, while machine C produced more unsatisfactory ones [244](#page=244). ### Example: Investment preference and risk perception An investment company surveyed clients about their risk perception (averse, neutral, lover) and preferred investment type (fixed deposits, bonds, unit trusts, options/futures). The results showed a significant dependence between these variables, with $\chi^2 = 29.97$ and 6 degrees of freedom [245](#page=245) [249](#page=249). ## 14.12 Chi-squared confidence intervals and tests for population variance When samples are drawn from a normally distributed population, a transformation of the sample variance ($s^2$) follows a chi-squared distribution. This relationship allows for confidence intervals and hypothesis tests for the population variance ($\sigma^2$). The distribution is given by: $$ \frac{(n-1)s^2}{\sigma^2} \sim \chi^2_{n-1} $$ where $n$ is the sample size and $s^2$ is the sample variance. ### Confidence intervals for population variance A confidence interval for $\sigma^2$ is calculated using the sample variance and critical values from the chi-squared distribution. - <span style="color: #ff9f29; font-weight: 700;">Formula</span>: $ (\frac{(n-1)s^2}{\chi^2_{\alpha/2, n-1}}, \frac{(n-1)s^2}{\chi^2_{1-\alpha/2, n-1}}) $ - $\chi^2_{\alpha/2, n-1}$ is the upper critical value. - $\chi^2_{1-\alpha/2, n-1}$ is the lower critical value. The confidence interval for the population standard deviation ($\sigma$) is found by taking the square root of the interval for $\sigma^2$. > The confidence interval for variance is not centered on the sample variance point estimate. #### Example: Milk bottle variability A dairy sampled 25 bottles and found a standard deviation of 3.71 ml. A 95% confidence interval for the population standard deviation ($\sigma$) was calculated to be (2.90 ml, 5.16 ml) [246](#page=246). ### Hypothesis tests for population variance Hypothesis tests for $\sigma^2$ use the same chi-squared distribution. The test statistic is calculated as $(n-1)s^2/\sigma_0^2$, where $\sigma_0^2$ is the hypothesized population variance. #### Example: Dairy specification adherence The dairy also tested if the population standard deviation exceeded 2.5 ml. The test statistic was 52.85, which was greater than the critical value of 42.980 at the 1% significance level. This led to rejecting the null hypothesis and concluding the specification was not met. #### Example: Security return variability A portfolio manager required a security's standard deviation of return not to exceed 10% per month. A sample of 18 monthly returns showed a sample standard deviation of 14.2%. A 90% confidence interval for $\sigma$ was (11.1%, 19.9%). The hypothesis test showed $\sigma$ exceeded 10% (test statistic 34.28), meaning the security was too risky [247](#page=247) [248](#page=248). > **🔑 Important:** The chi-squared distribution is fundamental for testing categorical data associations and for making inferences about population variances. | Test Type | Purpose | Null Hypothesis ($H_0$) | Test Statistic Formula | Degrees of Freedom | |:---------------------------- |:---------------------------------------------------------- |:--------------------------------------------------------- |:-------------------------------------------------------- |:----------------------------- | | Goodness-of-fit | Data fits a theoretical distribution | Data fits the specified distribution | $\sum \frac{(O_i - E_i)^2}{E_i}$ | $k - 1 - p$ (k=categories, p=parameters) | | Test of Independence | Association between two categorical variables | Variables are independent | $\sum \frac{(O_i - E_i)^2}{E_i}$ | $(r-1)(c-1)$ (r=rows, c=columns) | | Test/Confidence Interval for Variance | Inference about population variance ($\sigma^2$) | $\sigma^2 = \sigma_0^2$ (or $\sigma^2 \le \sigma_0^2$, etc.) | $\frac{(n-1)s^2}{\sigma_0^2}$ | $n-1$ | # 15. Proportions and sample surveys ## 15.1 Estimating population proportions * Statisticians often estimate the proportion of a population with a specific characteristic, like in opinion polls or market research. * Ideally, data is collected from the entire population. However, time and cost constraints usually make this impractical. * Estimating proportions from sample data is the usual challenge. * A sample can represent the population if it is similar or equivalent to the unsampled portion [257](#page=257). * <span style="color: #ff9f29; font-weight: 700;">Randomness</span> is key to avoiding bias. Each element should have an equal chance of selection. * A <span style="color: #ff9f29; font-weight: 700;">random sample</span>, when sufficiently large, is highly likely to be representative of the population. > Key rules for studying populations: use random selection, ensure a moderate sample size, and make the sample large enough for study objectives [258](#page=258). ## 15.2 Confidence intervals for proportions * <span style="color: #ff9f29; font-weight: 700;">Population proportion</span> is denoted by $\pi$, and <span style="color: #ff9f29; font-weight: 700;">sample proportion</span> by $P$. * The sample proportion $P$ varies between samples and is a random variable. * For large sample sizes ($n$), the sampling distribution of $P$ approximates a normal distribution: $P \sim N\left(\pi, \frac{\pi(1-\pi)}{n}\right)$. * Since $\pi$ is unknown, we approximate the variance using $P$: $P \sim N\left(\pi, \frac{P(1-P)}{n}\right)$. * Confidence intervals for $\pi$ are typically calculated as $P \pm z \sqrt{\frac{P(1-P)}{n}}$. * A 95% confidence interval uses $z=1.96$, and a 99% interval uses $z=2.58$ [259](#page=259). > Confidence intervals provide a range within which the true population proportion is likely to lie, with a specified level of confidence. <span style="color: #ff9f29; font-weight: 700;">Confidence interval calculation</span> | Level | $z$-value | Formula | |:---- |:-------- |:------------------------------------------------ | | 95% | 1.96 | $P \pm 1.96 \sqrt{\frac{P(1-P)}{n}}$ | | 99% | 2.58 | $P \pm 2.58 \sqrt{\frac{P(1-P)}{n}}$ | * The quantity added/subtracted to the point estimate is the <span style="color: #ff9f29; font-weight: 700;">reliability margin</span> ($L$), often expressed as a percentage. * A smaller reliability margin indicates a more precise estimate. * Precision increases with larger sample sizes ($n$). > Example: A sample of 1000 voters found 500 for a candidate. The 95% CI for $\pi$ is $0.50 \pm 1.96 \sqrt{\frac{0.5(0.5)}{1000}} = (0.469, 0.531)$. The reliability margin is 3.1% [260](#page=260). ## 15.3 Finite populations * When sampling without replacement from a finite population ($N$), the random error is reduced. * The sampling distribution of $P$ is still approximately normal, but with a reduced variance: $P \sim N\left(\pi, \frac{P(1-P)(N-n)}{n(N-1)}\right)$. * Confidence intervals are adjusted using this reduced variance formula [261](#page=261). > Example: A lecturer samples 100 scripts from 823 students, finding 27 failures ($P=0.27$). The 95% CI for the failure rate is $(0.188, 0.352)$, with an 8.2% reliability margin. ## 15.4 Sample size determination * To determine the required sample size ($n$), four questions are posed: 1. Population size ($N$) 2. Confidence level (e.g., 95% or 99%) 3. Acceptable margin of error ($L\%$) 4. A rough estimate of the population proportion ($P$). * For infinite or very large populations: $n = \left(\frac{100}{L}\right)^2 \times z^2 \times P(1-P)$. * If no estimate for $\pi$ is available, use $P=0.5$. This yields the largest possible sample size required for a given margin of error [262](#page=262). * Using an existing estimate for $\pi$ (substituted for $P$) will result in a smaller required sample size. > The function $P(1-P)$ is maximized when $P=0.5$. * For finite populations ($N$): $n = \frac{N}{1 + \frac{(N-1)}{1.96^2 P(1-P)}\left(\frac{L}{100}\right)^2}$. * The required sample size for finite populations is always smaller than for infinite populations. > Example: For an infinite population, 95% confidence, 3% margin of error, and $P=0.5$, the sample size is $n = (\frac{100}{3})^2 \times 1.96^2 \times 0.5 \times 0.5 \approx 1068$ [263](#page=263). ## 15.5 Testing a population proportion * Hypothesis tests for proportions are similar to those for means. * The null hypothesis ($H_0$) states a specific proportion, e.g., $H_0: \pi = \pi_0$. * The alternative hypothesis ($H_1$) reflects the suspicion, e.g., $H_1: \pi < \pi_0$, $H_1: \pi > \pi_0$, or $H_1: \pi \neq \pi_0$. * The test statistic for large samples is approximately normal: $Z = \frac{P - \pi_0}{\sqrt{\frac{\pi_0(1-\pi_0)}{n}}}$ [264](#page=264). * For finite populations, the adjusted variance is used: $Z = \frac{P - \pi_0}{\sqrt{\frac{\pi_0(1-\pi_0)(N-n)}{n(N-1)}}}$ [265](#page=265). > Example: A researcher suspects a suburb's new car proportion ($\pi$) is less than the national average of 0.271. A sample of 155 cars yields $P=0.239$. With $H_0: \pi = 0.271$ and $H_1: \pi < 0.271$, the test statistic $z = \frac{0.239 - 0.271}{\sqrt{\frac{0.271(1-0.271)}{155}}} = -0.896$. At a 5% significance level ($z < -1.64$), $H_0$ is not rejected [264-265] > **🔑 Important:** When testing proportions, use the appropriate $z$-statistic for infinite or finite populations based on whether the sample size is a significant fraction of the population size. ## 15.6 Testing for differences between proportions When comparing proportions from two independent samples, we often use a z-test. The null hypothesis is typically that the population proportions are equal. * <span style="color: #ff9f29; font-weight: 700;">Null Hypothesis ($H_0$)</span>: The population proportions are equal ($\pi_1 = \pi_2$). * <span style="color: #ff9f29; font-weight: 700;">Alternative Hypothesis ($H_1$)</span>: The population proportions are not equal ($\pi_1 \neq \pi_2$), or one is less than the other ($\pi_1 < \pi_2$), or one is greater than the other ($\pi_1 > \pi_2$). The test statistic is calculated using sample proportions and a pooled estimate of the population proportion. * <span style="color: #ff9f29; font-weight: 700;">Pooled estimate ($P$)</span>: This is a weighted average of sample proportions, calculated as $P = \frac{Y_1 + Y_2}{n_1 + n_2}$, where $Y_i$ is the number of successes and $n_i$ is the sample size for group $i$. * <span style="color: #ff9f29; font-weight: 700;">Test Statistic ($Z$)</span>: $$ Z = \frac{P_1 - P_2}{\sqrt{P(1 - P) \left(\frac{1}{n_1} + \frac{1}{n_2}\right)}} $$ where $P_1$ and $P_2$ are the sample proportions. The null hypothesis is rejected if the calculated test statistic falls into the rejection region, determined by the significance level and the alternative hypothesis (e.g., $|Z| > 1.96$ for a two-tailed test at 5% significance). > **📝 Example:** Comparing voter support in two suburbs. > > - Suburb 1: 175 out of 318 voters support a candidate ($P_1 = 0.550$). > - Suburb 2: 143 out of 307 voters support a candidate ($P_2 = 0.466$). > - Pooled estimate $P = (175 + 143) / (318 + 307) = 0.509$. > - Test statistic $z = \frac{0.550 - 0.466}{\sqrt{0.509 \times 0.491 \times (\frac{1}{318} + \frac{1}{307})}} \approx 2.10$. > - Since $2.10 > 1.96$ (at 5% significance), we reject $H_0$ and conclude there's a significant difference in support. * <span style="color: #ff9f29; font-weight: 700;">Two-tailed test</span>: Used when $H_1: \pi_1 \neq \pi_2$. Reject $H_0$ if $|Z|$ exceeds the critical value (e.g., 1.96 for 5% significance) [266](#page=266). * <span style="color: #ff9f29; font-weight: 700;">One-tailed test</span>: Used when $H_1: \pi_1 < \pi_2$ or $H_1: \pi_1 > \pi_2$. Reject $H_0$ if $Z$ is less than or greater than the critical value, respectively. This test is mathematically equivalent to a test of association in a $2 \times 2$ contingency table [267](#page=267). ## 15.7 Probability sampling methods Probability sampling ensures each unit has an equal chance of selection, allowing for estimation of sampling error. | Method | Description | Advantages | Disadvantages | |:------------------------- |:------------------------------------------------------------------------------------------------------------------------------------------- |:----------------------------------------------------------------------- |:--------------------------------------------------------------- | | Simple Random Sampling | Every unit has an equal chance of selection; uses random number tables or computer generators. | All statistical methods applicable; unbiased. | Can be less efficient for large, dispersed populations. | | Stratified Sampling | Population divided into groups (strata) based on characteristics; random samples drawn from each stratum. | More precise estimates; narrower confidence intervals; cost savings. | Requires prior knowledge of population characteristics. | | Cluster Sampling | Population divided into subgroups (clusters); a random sample of clusters is selected, and all units within selected clusters are sampled. | Cost-effective, especially for geographically dispersed populations. | Wider confidence intervals than simple random sampling. | | Multi-stage Sampling | Involves multiple stages of random sampling, often within clusters. Example: selecting towns, then suburbs, then blocks, then houses. | Convenient for large-scale surveys. | Can be complex to analyze; error estimates can be challenging. | | Two-phase Sampling | Two samples taken at different times; first sample helps determine size and stratification for the second, main sample. | Efficient allocation of resources. | Requires data collection at two distinct points in time. | | Sequential Sampling | A series of random samples taken to continuously monitor changes or gather more information. | Allows for ongoing monitoring; adaptive sampling. | Can be complex; decisions may depend on accumulating data. | | Systematic Sampling | Select a random start point and then every k-th unit. | Easy to implement; can be efficient. | Risk of large errors if sampling interval coincides with a cycle. | Non-response is a significant issue in probability sampling, as non-responders may hold different views than responders[269](#page=269). > **🔑 Important:** Each unit being sampled must have an equal chance of selection for probability sampling methods to be valid. ## 15.8 Non-probability sampling methods Non-probability sampling methods do not offer a basis for estimating sampling error. | Method | Description | Potential Issues | |:---------------- |:---------------------------------------------------------------------------------------------------------------- |:-------------------------------------------------------- | | Judgement Sampling | Units are selected based on the sampler's expertise or opinion about representativeness. | Unintentional bias; credibility depends on expert's reputation. | | Quota Sampling | Interviewers are given quotas for specific types of people to interview; they select individuals subjectively. | Subjective selection; no randomness; no check on error size. | Quota sampling, unlike probability sampling, does not allow for consistent avoidance of interviewer bias. ## 15.9 Designing sample surveys Effective survey design involves careful planning and execution to ensure reliable results. * <span style="color: #ff9f29; font-weight: 700;">Pilot survey</span>: A small-scale preliminary study to test questionnaires, identify problems, and refine procedures. This prevents major errors in the main survey, saving time and money. * <span style="color: #ff9f29; font-weight: 700;">Questionnaire design</span>: Questions should be clear, concise, and directly address desired information. Consider the target audience and possible answers. Involve subject matter experts. * <span style="color: #ff9f29; font-weight: 700;">Data capture</span>: Plan for data entry compatibility with computer systems. * <span style="color: #ff9f29; font-weight: 700;">Analysis planning</span>: Discuss data processing and analysis, especially computer use, with the analyst beforehand. > **🔑 Important:** A pilot survey is crucial to identify and fix issues *before* the main survey, saving resources and ensuring data quality [270](#page=270). > **🔑 Important:** The most critical aspect of designing sample surveys is ensuring that every element of the target population has a known, non-zero probability of being selected [268](#page=268). # 16. Regression and correlation analysis (part 1) ## 16.1 Introduction to regression and correlation * Regression analysis aims to describe the relationship between two or more variables. * It helps answer if a relationship exists between variables and how to predict values. * Correlation analysis determines the strength and direction of a linear relationship. * Regression analysis then uses this relationship to predict values of one variable based on another. ## 16.2 Scatter plots * A scatter plot (or scattergram) graphically displays the relationship between two variables. * It plots pairs of observations as points on a two-dimensional plane. * The x-axis represents the explanatory variable, and the y-axis represents the dependent variable. * A distinct trend in the scatter plot indicates a relationship between variables. * A haphazard scattering of points suggests no clear relationship exists [278](#page=278). > A scatter plot is the first step to visualize potential relationships. ## 16.3 Correlation coefficient * The <span style="color: #ff9f29; font-weight: 700;">correlation coefficient</span>, denoted by $r$, measures the degree of association between two variables. * It quantifies how well the data points fit a linear relationship. * <span style="color: #ff9f29; font-weight: 700;">Formula:</span> $$r = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\sum (x_i - \bar{x})^2 \sum (y_i - \bar{y})^2}} = \frac{SS_{xy}}{\sqrt{SS_x SS_y}}$$. * $SS_x$, $SS_{xy}$, and $SS_y$ are sums of squares. * $SS_x = \sum (x - \bar{x})^2 = \sum x^2 - \frac{(\sum x)^2}{n}$. * $SS_{xy} = \sum (x - \bar{x})(y - \bar{y}) = \sum xy - \frac{(\sum x)(\sum y)}{n}$. * $SS_y = \sum (y - \bar{y})^2 = \sum y^2 - \frac{(\sum y)^2}{n}$. ## 16.4 Interpretation of the correlation coefficient * The correlation coefficient $r$ ranges from $-1$ to $+1$. * <span style="color: #ff9f29; font-weight: 700;">Positive $r$ ($0 < r \leq 1$):</span> Indicates a positive linear relationship; as $x$ increases, $y$ tends to increase. * $r = +1$ means a perfect positive linear correlation. * <span style="color: #ff9f29; font-weight: 700;">Negative $r$ ($-1 \leq r < 0$):</span> Indicates a negative linear relationship; as $x$ increases, $y$ tends to decrease [279](#page=279). * $r = -1$ means a perfect negative linear correlation. * <span style="color: #ff9f29; font-weight: 700;">Zero $r$ ($r \approx 0$):</span> Indicates no linear relationship between $x$ and $y$ [280](#page=280). > A stronger correlation means data points are closer to the regression line. ## 16.5 Significance of correlation * Sample correlation $r$ estimates the population correlation $\rho$. * A hypothesis test is used to determine if $r$ is statistically significant. * <span style="color: #ff9f29; font-weight: 700;">Null Hypothesis ($H_0$):</span> $\rho = 0$ (no linear relationship). * <span style="color: #ff9f29; font-weight: 700;">Alternative Hypothesis ($H_1$):</span> $\rho \neq 0$ (there is a linear relationship). * <span style="color: #ff9f29; font-weight: 700;">Test statistic:</span> The correlation coefficient $r$ itself. * <span style="color: #ff9f29; font-weight: 700;">Degrees of freedom:</span> $n-2$, where $n$ is the number of paired observations. * Critical values are found in correlation tables based on degrees of freedom and significance level [281](#page=281). > Significance testing helps decide if an observed correlation is likely due to chance. ## 16.6 Linear regression * Linear regression aims to find an equation for a straight line that best fits the data. * The general equation for a straight line is $y = a + bx$. * $a$ is the y-intercept. * $b$ is the slope of the line. * The goal is to find values for $a$ and $b$ that minimize the errors between observed and fitted values. ## 16.7 Method of least squares * The <span style="color: #ff9f29; font-weight: 700;">method of least squares</span> is used to find the best-fitting line. * It minimizes the sum of the squares of the vertical differences (residuals, $e_i$) between observed $y_i$ and fitted $\hat{y}_i$ values. * The sum of squared errors is $\theta = \sum e_i^2 = \sum (y_i - \hat{y}_i)^2$ [285](#page=285). * Where $\hat{y}_i = a + bx_i$. ## 16.8 Normal equations * To minimize $\theta$, calculus is used by taking partial derivatives with respect to $a$ and $b$ and setting them to zero. * This yields two <span style="color: #ff9f29; font-weight: 700;">normal equations</span>: * $\sum y_i = na + b \sum x_i$. * $\sum x_iy_i = a \sum x_i + b \sum x_i^2$ [286](#page=286). ## 16.9 Calculating regression coefficients * The normal equations can be solved for $a$ and $b$. * <span style="color: #ff9f29; font-weight: 700;">Formulas for coefficients:</span> * $b = \frac{\sum xy - \frac{(\sum x)(\sum y)}{n}}{\sum x^2 - \frac{(\sum x)^2}{n}} = \frac{SS_{xy}}{SS_x}$. * $a = \bar{y} - b\bar{x} = \frac{\sum y - b \sum x}{n}$. * The best-fitting line is then $\hat{y} = a + bx$. > The sign of the slope $b$ of the regression line is always the same as the sign of the correlation coefficient $r$ [287](#page=287). > **🔑 Important:** Always plot data using a scatter plot to check for linearity before applying regression and correlation analysis [284](#page=284). ## 16.10 Introduction to regression analysis * Regression analysis models relationships between variables. * It aims to predict a dependent variable ($y$) using one or more independent variables ($x$). * The focus is on finding a mathematical equation that best describes this relationship. ## 16.11 Calculating the regression line * To find the best-fitting line, we use sample data. * This involves calculating sums of observed and predicted values. * Key calculations include sums of $x$, $y$, $x^2$, $y^2$, and $xy$. ## 16.12 Sample means * Sample means for $x$ and $y$ are calculated by dividing their sums by the number of observations ($n$). * $\bar{x} = \frac{\sum x}{n}$. * $\bar{y} = \frac{\sum y}{n}$. ## 16.13 Sums of squares (SS) * Sums of squares measure the total variation in the data. * $SS_x = \sum x^2 - \frac{(\sum x)^2}{n}$. * $SS_y = \sum y^2 - \frac{(\sum y)^2}{n}$. * $SS_{xy} = \sum xy - \frac{(\sum x)(\sum y)}{n}$. ## 16.14 Regression coefficients * The regression line is represented by the equation $\hat{y} = a + bx$. * The coefficient $b$ represents the slope of the line. * $b = \frac{SS_{xy}}{SS_x}$. * The coefficient $a$ represents the y-intercept. * $a = \bar{y} - b\bar{x}$. ## 16.15 The regression equation * The equation $\hat{y} = a + bx$ predicts the value of $y$ for a given $x$. * The hat symbol ($\hat{y}$) indicates a predicted value. * This equation can be used for making predictions. > **📝 Example:** Predicting year-end marks from mid-year marks. If mid-year mark ($x$) is 50%, the predicted year-end mark ($\hat{y}$) is $37.65 + 0.566 \times 50 = 66.0\%$. > **📝 Example:** Predicting monthly income from years of education. The regression line is $\hat{y} = -0.535 + 0.555x$. For 12 years of education, the predicted income is $-0.535 + 0.555 \times 12 = 6.125$ (e.g., 6125 dollars). ## 16.16 Understanding residuals and sum of squares decomposition * A <span style="color: #ff9f29; font-weight: 700;">residual</span> is the difference between an observed value ($y_i$) and its predicted value ($\hat{y}_i$). * Residual = $y_i - \hat{y}_i$. * The sum of squares due to error (SSE) measures the total squared residuals. * $SSE = \sum (y_i - \hat{y}_i)^2 = \sum (y_i - a - bx_i)^2$. ## 16.17 Sum of squares decomposition * The total sum of squares ($SST$) can be broken down into two parts: * $SST = SSR + SSE$. * $SST$ represents the total variability in the dependent variable ($y$), which is equal to $SS_y$. * $SSR$ (Sum of Squares due to Regression) is the variability explained by the regression line. * $SSE$ (Sum of Squares due to Error) is the unexplained variability or residual variability. ## 16.18 Calculating SSR * $SSR$ can be calculated in two ways: * $SSR = b \cdot SS_{xy}$. * $SSR = \frac{SS_{xy}^2}{SS_x}$. > **🔑 Important:** The sum of squares decomposition ($SST = SSR + SSE$) shows how much of the total variation in $y$ is explained by the regression model [290](#page=290). > **🔑 Important:** The role of $x$ and $y$ are not interchangeable in regression. Predicting $x$ from $y$ results in a different regression line than predicting $y$ from $x$. > **🔑 Important:** Always check that your regression coefficients ($a$ and $b$) and sums of squares calculations are consistent and sensible for the dataset [288](#page=288) [289](#page=289). # 17. Regression and correlation analysis (part 2) ## 17.1 Prediction intervals and coefficient of determination * <span style="color: #ff9f29; font-weight: 700;">Prediction intervals</span>: These are confidence intervals for a predicted value of $y$ for a given $x$. They account for the variation in the data that the regression line does not explain. * The <span style="color: #ff9f29; font-weight: 700;">residual standard deviation</span> ($s$) measures the typical size of the residuals (the differences between observed and predicted $y$ values). $$s = \sqrt{\frac{\sum (y_i - \hat{y}_i)^2}{n - 2}}$$ * Prediction intervals use the t-distribution with $n-2$ degrees of freedom because $s$ is estimated. * The width of the prediction interval increases as the $x$ value moves further from the mean of $x$ ($\bar{x}$). Predictions are most reliable near the mean. > Predictions are most reliable when $x$ values are close to the average $x$ value [291](#page=291). * <span style="color: #ff9f29; font-weight: 700;">Coefficient of determination</span> ($r^2$): This statistic measures the proportion of the total variation in the dependent variable ($y$) that is explained by the regression line. $$r^2 = \frac{SSR}{SST}$$ * It is simply the square of the correlation coefficient ($r$). $$r^2 = r^2$$ * An $r^2$ of 0.57 means 57% of the variation in $y$ is explained by $x$. <span style="color: #ff9f29; font-weight: 700;">Example:</span> If $r=0.755$, then $r^2 = 0.755^2 = 0.5700$. This means 57% of the variation in final exam marks is explained by class test marks [292](#page=292). > **📝 Example:** For the relationship between education and income, an $r^2$ of 0.3494 means about 35% of the variation in monthly income is explained by years of formal education. ## 17.2 Summary of computational scheme for simple linear regression This table summarizes the key quantities needed for simple linear regression calculations. | Quantity | Formula | |:------------------- |:----------------------------------------------------------------------------------- | | Mean of $x$ | $\bar{x} = \frac{\sum x}{n}$ | | Mean of $y$ | $\bar{y} = \frac{\sum y}{n}$ | | $SS_x$ | $\sum x^2 - \frac{(\sum x)^2}{n}$ | | $SS_{xy}$ | $\sum xy - \frac{(\sum x)(\sum y)}{n}$ | | $SS_y$ | $\sum y^2 - \frac{(\sum y)^2}{n}$ | | Slope ($b$) | $b = \frac{SS_{xy}}{SS_x}$ | | Intercept ($a$) | $a = \bar{y} - b\bar{x}$ | | Correlation ($r$) | $r = \frac{SS_{xy}}{\sqrt{SS_x SS_y}}$ | | Residual Std. Dev. ($s$) | $s = \sqrt{\frac{SS_y - b SS_{xy}}{n - 2}}$ | | Predicted value ($\hat{y}$) | $\hat{y} = a + bx$ | | 95% Prediction Interval | $\hat{y} \pm t_{(0.025), n-2} \times s \times \sqrt{1 + \frac{1}{n} + \frac{(x - \bar{x})^2}{SS_x}}$ | [293](#page=293) ## 17.3 Nonlinear curve fitting * Not all relationships are linear. Some are exponential, like population growth ($p = ae^{bt}$). * These nonlinear relationships can often be transformed into linear ones. This allows us to use linear regression techniques. * The more complex the function, the more data points are needed. Linear regression is often used as an approximation for complex functions over a small range. ## 17.4 Exponential growth * An exponential relationship like $y = ae^{bx}$ can be linearized by taking the natural logarithm of both sides: $$\log y = \log a + bx$$ * By setting $Y = \log y$ and $A = \log a$, the equation becomes $Y = A + bx$, which is a linear equation. * After fitting this linear model, we transform back to the original variables to get the exponential model $y = ae^{bx}$, where $a = e^A$. [297](#page=297). <span style="color: #ff9f29; font-weight: 700;">Example:</span> To model population growth, we can take the log of the population values ($Y = \log y$) and regress $Y$ against the year ($x$). The resulting linear regression coefficients ($A$ and $b$) are then used to find $a = e^A$ and estimate the original exponential curve $y = ae^{bx}$ [298](#page=298). ## 17.5 Other relationships transformable to linear Several other nonlinear forms can be linearized using logarithms: | Original Function | Transformation | Linear Form | |:---------------- |:------------------------ |:----------------- | | $y = ab^x$ | $\log y = \log a + x \log b$ | $Y = A + Bx$ | | $y = ax^b$ | $\log y = \log a + b \log x$ | $Y = A + bX$ | | $ay = b^{-x}$ | $\log a + \log y = -x \log b$ | $Y = -A - Bx$ | Here, $Y = \log y$, $X = \log x$, $A = \log a$, and $B = \log b$ (or similar substitutions). > **📝 Example:** The relationship $y = ax^b$ can be transformed into a linear form $Y = A + bX$ by taking the natural logarithm of both sides, where $Y=\log y$, $A=\log a$, and $X=\log x$ [299](#page=299). ## 17.6 Multiple regression * <span style="color: #ff9f29; font-weight: 700;">Multiple regression</span> models use more than one explanatory variable ($x_1, x_2, \dots, x_k$) to predict a dependent variable ($y$). $$y = \beta_0 + \beta_1x_1 + \beta_2x_2 + \dots + \beta_kx_k + e$$ * $\beta_i$ are the true regression coefficients, and $e$ is the error term. * The method of least squares is used to estimate these coefficients, minimizing the sum of squared residuals ($\sum (y_i - \hat{y}_i)^2$). * Computers are typically used for calculations due to their complexity. [301](#page=301) [302](#page=302). ## 17.7 Interpreting multiple regression coefficients * In multiple regression, a coefficient $b_i$ represents the change in $y$ for a one-unit increase in $x_i$, <span style="color: #ff9f29; font-weight: 700;">holding all other explanatory variables constant</span>. * For example, in a model predicting income ($y$) from education ($x_1$) and experience ($x_2$), $b_1 = 0.379$ means a one-year increase in education increases income by R379 (if $y$ is in R1000s), assuming experience remains the same [303](#page=303). ## 17.8 Multiple coefficient of determination * The <span style="color: #ff9f29; font-weight: 700;">multiple coefficient of determination</span> ($R^2$) measures the proportion of the variation in $y$ explained jointly by all explanatory variables in the model. * It is not simply the square of a single correlation coefficient. * An increase in $R^2$ from a simple regression model indicates that the added variable(s) improve the explanation of $y$'s variability [304](#page=304). ## 17.9 Testing for overall significance * To test if at least one explanatory variable is significant, we use the F-distribution. * Null Hypothesis ($H_0$): All regression coefficients (except the intercept) are zero ($\beta_1 = \beta_2 = \dots = \beta_k = 0$). * Alternative Hypothesis ($H_1$): At least one coefficient is non-zero. * The test statistic is the ratio of the mean square for regression (MSR) to the mean square for error (MSE). $$F = \frac{MSR}{MSE} \sim F_{k, n-k-1}$$ where $k$ is the number of explanatory variables and $n$ is the number of observations. <span style="color: #ff9f29; font-weight: 700;">ANOVA Table:</span> Summarizes sources of variation for the F-test. > **🔑 Important:** Rejecting $H_0$ means at least one explanatory variable significantly relates to the dependent variable [305](#page=305). ## 17.10 Testing for significance of individual variables * To test if a specific regression coefficient ($b_i$) is significant, we use a t-test. * Null Hypothesis ($H_0$): $\beta_i = 0$. * Alternative Hypothesis ($H_1$): $\beta_i \neq 0$. * The test statistic is the estimated coefficient ($b_i$) divided by its standard error ($s_{b_i}$). $$t = \frac{b_i}{s_{b_i}} \sim t_{n-k-1}$$ * Both $b_i$ and $s_{b_i}$ are usually provided by statistical software. > **🔑 Important:** A significant t-value for an individual variable means that variable contributes significantly to the model, even after accounting for other variables [307](#page=307). > **🔑 Important:** In multiple regression, the interpretation of coefficients and the significance tests are crucial for understanding how each variable impacts the dependent variable while controlling for others [308](#page=308). ## 17.11 Hypothesis testing in multiple regression Multiple regression models allow testing the overall significance of the model and the significance of individual predictors. This involves setting up null and alternative hypotheses. ## 17.12 Testing overall model significance * <span style="color: #ff9f29; font-weight: 700;">Null hypothesis ($H_0$)</span>: All regression coefficients (except the intercept) are zero. This means no independent variable explains any variation in the dependent variable. * <span style="color: #ff9f29; font-weight: 700;">Alternative hypothesis ($H_1$)</span>: At least one regression coefficient is non-zero. This suggests the model explains some of the variation. The F-test is used to assess overall model significance. A high F-statistic indicates that the model is significant. > The F-statistic measures how well the regression model fits the data compared to a model with no predictors. ## 17.13 Testing individual coefficient significance Individual coefficients can be tested to determine if a specific predictor variable has a statistically significant relationship with the dependent variable. * <span style="color: #ff9f29; font-weight: 700;">Null hypothesis ($H_0$)</span>: The specific regression coefficient ($\beta_i$) is zero. * <span style="color: #ff9f29; font-weight: 700;">Alternative hypothesis ($H_1$)</span>: The specific regression coefficient ($\beta_i$) is not zero. The t-test is used for individual coefficient significance. A large absolute t-statistic suggests the coefficient is significant. > Each t-test checks if a predictor's contribution to the model is statistically meaningful on its own. ## 17.14 Interpreting regression coefficients Regression coefficients represent the change in the dependent variable for a one-unit change in the independent variable, holding other variables constant. * <span style="color: #ff9f29; font-weight: 700;">Coefficient magnitude</span>: A larger coefficient suggests a greater impact on the dependent variable. * <span style="color: #ff9f29; font-weight: 700;">Unit comparison</span>: Coefficients can only be directly compared if the independent variables share the same units of measurement. Otherwise, standardization or other methods are needed. In multiple regression, comparing coefficients directly can be misleading if units differ. Statistical testing is required to formally compare the impact of different predictors. > Coefficients tell us the predicted change in sales per unit increase in advertising, assuming other ad spending stays the same. ## 17.15 Comparing predictor effectiveness * <span style="color: #ff9f29; font-weight: 700;">Hypothesis for comparison</span>: To test if one predictor is more effective than another (e.g., $\beta_1$ vs. $\beta_2$), a specific hypothesis like $H_0: \beta_1 = \beta_2$ or $H_0: \beta_1 < \beta_2$ must be formulated and tested. * <span style="color: #ff9f29; font-weight: 700;">Caution</span>: Simply observing $b_1 < b_2$ does not prove $\beta_1 < \beta_2$ without statistical testing [309](#page=309). ## 17.16 Example: Part-time employee sales analysis This example explores the relationship between sales (y), hours worked ($x_1$), and months of experience ($x_2$) for part-time employees. | Person | Sales (y) | Hours Worked ($x_1$) | Months of Experience ($x_2$) | |:----- |:-------- |:------------------- |:--------------------------- | | 1 | 4 | 5 | 1 | | 2 | 2 | 4 | 2 | | 3 | 15 | 12 | 6 | | 4 | 9 | 10 | 6 | | 5 | 11 | 9 | 8 | | 6 | 8 | 8 | 10 | | 7 | 14 | 13 | 12 | | 8 | 17 | 14 | 15 | | 9 | 16 | 12 | 14 | | 10 | 2 | 4 | 3 |### 17.3.1 Regression equation and R-squared The regression equation relates sales to hours worked and experience. The coefficient of determination ($R^2$) measures the proportion of variance in sales explained by these factors. * <span style="color: #ff9f29; font-weight: 700;">Estimated Coefficients</span>: * Hours worked ($x_1$): $\hat{\beta}_1 = 1.3790$ * Experience ($x_2$): $\hat{\beta}_2 = 0.0998$ * Intercept: $\hat{\beta}_0 = -3.5176$ * <span style="color: #ff9f29; font-weight: 700;">Regression Equation</span>: $\hat{y} = -3.5176 + 1.3790 x_1 + 0.0998 x_2$. * <span style="color: #ff9f29; font-weight: 700;">ANOVA Table</span>: * Regression SS = 282.708 * Error SS = 12.892 * Total SS = 295.599 * Regression DF = 2 * Error DF = 7 * Total DF = 9 * <span style="color: #ff9f29; font-weight: 700;">$R^2$</span>: $R^2 = \frac{\text{Regression SS}}{\text{Total SS}} = \frac{282.708}{295.599} \approx 0.956$. This $R^2$ value means approximately 95.6% of the variation in sales is explained by hours worked and experience. > A high $R^2$ suggests the model fits the data well, but doesn't guarantee causality or that all important predictors are included. ## 17.17 Significance testing Testing the overall regression and individual coefficients follows the principles outlined previously. * <span style="color: #ff9f29; font-weight: 700;">Overall Model Significance (F-test)</span>: * $F = \frac{\text{Mean Square Regression}}{\text{Mean Square Error}} = \frac{282.708/2}{12.892/7} = \frac{141.354}{1.8417} \approx 76.75$ * With degrees of freedom (2, 7) and a 5% significance level, the critical F-value is 4.74. * Since $76.75 > 4.74$, the overall regression is highly significant. * <span style="color: #ff9f29; font-weight: 700;">Individual Coefficient Significance (t-tests)</span>: * <span style="color: #ff9f29; font-weight: 700;">Hours Worked ($x_1$)</span>: $t = \frac{1.3790}{0.2270} \approx 6.07$ * <span style="color: #ff9f29; font-weight: 700;">Experience ($x_2$)</span>: $t = \frac{0.0998}{0.1716} \approx 0.58$ * For a 5% significance level and 7 degrees of freedom, the critical |t|-value is 2.365. * The t-statistic for hours worked (6.07) is greater than 2.365, indicating it is significant. * The t-statistic for experience (0.58) is less than 2.365, indicating it is not statistically significant at this level. > Hours worked is a significant predictor of sales, while months of experience is not, given the current data. ## 17.18 Explaining the difference in sales The analysis suggests that the number of hours worked has a significant impact on sales. However, months of experience does not show a significant effect in this model. * <span style="color: #ff9f29; font-weight: 700;">Interpretation</span>: This could imply that for part-time employees, the actual time spent working during a shift is more critical for sales than their total accumulated experience. * <span style="color: #ff9f29; font-weight: 700;">Further investigation</span>: It's important to consider if other factors influence sales or if the experience variable was measured appropriately [310](#page=310). > 🔑 **Important:** In multiple regression, a variable can be insignificant individually even if the overall model is significant. --- > **🔑 Important:** Regression and correlation analysis helps quantify relationships between variables and test hypotheses about them, forming a crucial part of data analysis. # 18. Regression and correlation analysis (part 3) ## 18.1 Using dummy variables in regression <span style="color: #ff9f29; font-weight: 700;">Dummy variables</span> allow the inclusion of categorical or qualitative variables in a regression model. These variables are coded as 0s and 1s. For a variable with two categories, like gender, one dummy variable is sufficient. > A dummy variable acts like a "switch," turning "on" or "off" to represent different categories. ### 18.1.1 Interpreting dummy variable coefficients The coefficient of a dummy variable in a regression model represents the estimated difference in the dependent variable between the two categories. For instance, if males are coded as 1 and females as 0, a positive coefficient for the gender dummy variable suggests males earn more [311](#page=311). > <span style="color: #ff9f29; font-weight: 700;">Interpretation of</span> $b_3$ in $\hat{y} = b_0 + b_1x_1 + b_2x_2 + b_3x_3$: estimated income difference between males and females holding other variables constant [1](#page=1) [312](#page=312). ### 18.1.2 Testing dummy variable significance To determine if a categorical variable is significant, test its corresponding dummy variable's coefficient for being significantly different from zero. A t-test is used for this hypothesis. #### Hypothesis testing for dummy variables The hypothesis test for a dummy variable's coefficient ($β_3$) follows these steps: 1. <span style="color: #ff9f29; font-weight: 700;">Null Hypothesis ($H_0$)</span>: $β_3 = 0$ (the categorical variable has no effect). 2. <span style="color: #ff9f29; font-weight: 700;">Alternative Hypothesis ($H_A$)</span>: $β_3 \neq 0$ (the categorical variable has an effect). 3. <span style="color: #ff9f29; font-weight: 700;">Significance Level</span>: Typically 5%. 4. <span style="color: #ff9f29; font-weight: 700;">Degrees of Freedom</span>: Calculated as $n - k - 1$, where $n$ is the sample size and $k$ is the number of explanatory variables (including dummy variables). 5. <span style="color: #ff9f29; font-weight: 700;">Test Statistic</span>: $t = \frac{b_3}{s_{b_3}}$, where $b_3$ is the estimated coefficient and $s_{b_3}$ is its standard error. 6. <span style="color: #ff9f29; font-weight: 700;">Decision</span>: Reject $H_0$ if $|t|$ is greater than the critical t-value for the given degrees of freedom and significance level. > The test statistic $t = \frac{b_3}{s_{b_3}}$ helps determine if the dummy variable's coefficient is statistically significant. ### 18.1.3 Dummy variables for multiple categories When a categorical variable has more than two categories, you need one fewer dummy variable than the number of categories. For example, "marital status" with "single," "married," and "divorced" requires two dummy variables. #### Coding for multiple categories * <span style="color: #ff9f29; font-weight: 700;">Reference Category</span>: One category is chosen as the baseline (e.g., "married"). * <span style="color: #ff9f29; font-weight: 700;">Dummy Variables</span>: For each other category, a dummy variable is created. * `x4 = 0, x5 = 0` for "married" * `x4 = 1, x5 = 0` for "single" * `x4 = 0, x5 = 1` for "divorced" > The number of dummy variables needed is always one less than the number of categories. ### 18.1.4 Example: Share categories on JSE In finance, stocks are often categorized (e.g., Mining, Finance, Industrial). To include this in a regression model predicting return, dummy variables can be designed. [313](#page=313) [314](#page=314). | Sector | Return (%) | Beta | Dummy (x2) | Dummy (x3) | |:--------------- |:--------- |:--- |:--------- |:--------- | | Diamonds (M) | 46 | 1.31 | 0 | 0 | | West Wits (M) | 67 | 1.15 | 0 | 0 | | Metals & Mining (M)| 46 | 1.29 | 0 | 0 | | Platinum (M) | 40 | 1.44 | 0 | 0 | | Mining Houses (F)| 78 | 1.46 | 1 | 0 | | Evander (M) | 40 | 1.00 | 0 | 0 | | Motor (I) | 24 | 0.74 | 0 | 1 | | Investment Trusts (F)| 20 | 0.67 | 1 | 0 | | Banks (F) | 17 | 0.69 | 1 | 0 | | Insurance (F) | 19 | 0.79 | 1 | 0 | | Property (F) | 8 | 0.27 | 1 | 0 | | Paper (I) | 25 | 0.75 | 0 | 1 | | Industrial Holdings (I)| 27 | 0.83 | 0 | 1 | | Beverages & Hotels (I)| 34 | 0.81 | 0 | 1 | | Electronics (I) | 7 | 0.11 | 0 | 1 | | Food (I) | 19 | 0.11 | 0 | 1 | | Printing (I) | 33 | 0.51 | 0 | 1 | * <span style="color: #ff9f29; font-weight: 700;">Mining (M)</span> is the reference category (0,0). * <span style="color: #ff9f29; font-weight: 700;">Finance (F)</span> is coded as `x2 = 1, x3 = 0`. * <span style="color: #ff9f29; font-weight: 700;">Industrial (I)</span> is coded as `x2 = 0, x3 = 1`. The estimated model was $\hat{y} = -0.578 + 39.078x_1 - 1.346x_2 + 3.172x_3$. > <span style="color: #ff9f29; font-weight: 700;">Finance and Industrial categories</span>: $x_2$ and $x_3$ are dummy variables, with Mining as the baseline. Testing the significance of the dummy variables $x_2$ and $x_3$ showed they were not significant. This implies that, after accounting for beta (risk), there is no additional reward for investing in Finance or Industrial sectors compared to Mining. > <span style="color: #ff9f29; font-weight: 700;">Diversification principle</span>: Holding risk constant, no extra reward for investing in a single sector [315](#page=315). --- > **🔑 Important:** Dummy variables are essential for incorporating categorical information into regression models, expanding their analytical power beyond quantitative variables. [311-315] # 19. Regression and correlation analysis (part 4) ## 19.1 Statistical inference in regression - <span style="color: #ff9f29; font-weight: 700;">Hypothesis testing</span>: We use statistical tests to determine if relationships observed in sample data are likely to exist in the broader population. This involves testing hypotheses about population parameters, like the slope ($\beta_1$) of the regression line. - <span style="color: #ff9f29; font-weight: 700;">Null hypothesis ($H_0$)</span>: Typically states there is no linear relationship between the independent and dependent variables in the population. For example, $H_0: \beta_1 = 0$. - <span style="color: #ff9f29; font-weight: 700;">Alternative hypothesis ($H_A$)</span>: States there is a linear relationship. This can be two-sided ($H_A: \beta_1 \neq 0$) or one-sided ($H_A: \beta_1 > 0$ or $H_A: \beta_1 < 0$). > The core idea is to see if the observed relationship is strong enough to reject the idea that it happened by random chance. ## 19.2 t-distribution and hypothesis testing - <span style="color: #ff9f29; font-weight: 700;">t-statistic</span>: Calculated from sample data, it measures how many standard errors the sample slope is from zero. The formula is $t = \frac{\hat{\beta}_1 - \beta_{1,0}}{SE(\hat{\beta}_1)}$, where $\hat{\beta}_1$ is the sample slope, $\beta_{1,0}$ is the hypothesized population slope (usually 0), and $SE(\hat{\beta}_1)$ is the standard error of the slope. - <span style="color: #ff9f29; font-weight: 700;">Degrees of freedom (df)</span>: For simple linear regression, df is calculated as $n-2$, where $n$ is the number of observations. - <span style="color: #ff9f29; font-weight: 700;">Critical values</span>: Found using a t-distribution table, these values determine the rejection region for a given significance level ($\alpha$) and degrees of freedom. If the calculated t-statistic falls beyond the critical value, we reject the null hypothesis. - <span style="color: #ff9f29; font-weight: 700;">P-value</span>: The probability of observing a test statistic as extreme as, or more extreme than, the one calculated from the sample, assuming the null hypothesis is true. If the p-value is less than the significance level ($\alpha$), we reject $H_0$. > The t-distribution is like a bell curve that adjusts its shape based on sample size to help us make inferences. ## 19.3 Using t-tables - <span style="color: #ff9f29; font-weight: 700;">Table 2</span>: Provides critical values for the t-distribution. You look up your degrees of freedom along the left column and the desired probability level (related to $\alpha$) along the top row. | Degrees of Freedom (df) | P = 0.05 (two-sided) | P = 0.01 (two-sided) | |:---------------------- |:------------------- |:------------------- | | 1 | 12.71 | 63.66 | | 10 | 2.228 | 3.169 | | 30 | 2.042 | 2.750 | | z | 1.960 | 2.576 | - <span style="color: #ff9f29; font-weight: 700;">z-row</span>: Represents the critical values for the standard normal distribution, which is an approximation for the t-distribution with very large degrees of freedom [331](#page=331). > You match your sample's "freedom" (df) with the desired certainty level (P) to find your decision boundary. ## 19.4 Chi-squared distribution - <span style="color: #ff9f29; font-weight: 700;">Chi-squared ($\chi^2$) statistic</span>: Used for testing hypotheses about variances or in goodness-of-fit tests and tests of independence for categorical data. It is always positive. - <span style="color: #ff9f29; font-weight: 700;">Degrees of freedom (df)</span>: Similar to the t-distribution, the df for the chi-squared distribution depends on the number of categories or parameters being estimated. - <span style="color: #ff9f29; font-weight: 700;">Critical values</span>: Found in a chi-squared table, these values help determine if the observed data significantly deviates from what is expected under the null hypothesis. > The $\chi^2$ distribution is skewed and its shape changes with degrees of freedom, making it suitable for count-based data. ## 19.5 Using Chi-squared tables - <span style="color: #ff9f29; font-weight: 700;">Table 3</span>: Provides critical values for the $\chi^2$ distribution. It is split into two parts: P > 0.5 (left tail) and P < 0.5 (right tail). | Degrees of Freedom (df) | P = 0.05 (right tail) | P = 0.01 (right tail) | |:---------------------- |:-------------------- |:-------------------- | | 1 | 3.841 | 6.635 | | 10 | 18.307 | 23.209 | | 30 | 43.773 | 50.892 | - <span style="color: #ff9f29; font-weight: 700;">One-sided critical values</span>: The table gives values for $P = Pr[\chi^2_{df} > \chi^2(P)_{df}]$. This means the values are for the upper tail of the distribution [332](#page=332) [333](#page=333). > These tables help us decide if our observed counts are too unusual to be explained by chance alone. ## 19.6 F-distribution - <span style="color: #ff9f29; font-weight: 700;">F-statistic</span>: Used in ANOVA and regression analysis to compare variances. In regression, it tests the overall significance of the model, comparing the variance explained by the regression to the residual variance. - <span style="color: #ff9f29; font-weight: 700;">Numerator and Denominator Degrees of Freedom</span>: The F-distribution has two sets of degrees of freedom: df1 (numerator) and df2 (denominator). In regression, df1 is typically the number of predictors, and df2 is $n - (\text{number of predictors} + 1)$. - <span style="color: #ff9f29; font-weight: 700;">Critical values</span>: Found in F-distribution tables for specific significance levels (e.g., 5%, 2.5%, 1%) and degrees of freedom. > The F-statistic is a ratio of variances, telling us if one variance is significantly larger than another. ## 19.7 Using F-tables - <span style="color: #ff9f29; font-weight: 700;">Table 4.1, 4.2, 4.3</span>: These tables provide critical F-values for different probability levels (5%, 2.5%, 1%). You find the intersection of the numerator and denominator degrees of freedom. | DEN | NUM df=1 (5%) | NUM df=2 (5%) | NUM df=10 (5%) | |:-- |:---------- |:---------- |:----------- | | 1 | 161.4 | 199.5 | 241.9 | | 2 | 18.51 | 19.00 | 19.40 | | 10 | 4.96 | 4.10 | 2.98 | - <span style="color: #ff9f29; font-weight: 700;">Overall Regression Significance</span>: The F-test in regression assesses if at least one predictor variable has a significant linear relationship with the dependent variable [334](#page=334) [335](#page=335) [336](#page=336) [337](#page=337) [338](#page=338). > These tables are essential for hypothesis testing in ANOVA and for validating entire regression models. > **🔑 Important:** Understanding t-, $\chi^2$-, and F-distributions is crucial for hypothesis testing in regression and for determining the statistical significance of observed relationships. ## 19.8 Interpreting F-distribution critical values Critical values from F-distribution tables are used to determine statistical significance in hypothesis testing, particularly in ANOVA and regression analysis. These tables provide threshold values for the F-statistic based on the significance level and degrees of freedom. The F-distribution tables present critical values for different probability levels (e.g., 1% or 0.5%) and for varying numerator and denominator degrees of freedom. When the calculated F-statistic exceeds the critical value, the null hypothesis is rejected. | Probability Level | Degrees of Freedom | Critical Value Range | |:---------------- |:----------------- |:------------------- | | 1% (0.01) | Numerator: `v1` | Varies by `v1` and `v2` | | 0.5% (0.005) | Numerator: `v1` | Varies by `v1` and `v2` | [339](#page=339) [340](#page=340) [341](#page=341) ## 19.9 Using critical values for correlation coefficients Critical values for the correlation coefficient are essential for testing hypotheses about the population correlation ($\rho$). These values help determine if an observed correlation in a sample is statistically significant. The critical values are found in tables that relate the sample size (through degrees of freedom, $n-2$) to various probability levels for one-sided tests. If the absolute value of the calculated sample correlation coefficient ($r$) is greater than the critical value for the chosen significance level, the null hypothesis ($H_0: \rho = 0$) is rejected. | Degrees of Freedom (n-2) | Probability Level (P) | Critical Value | |:----------------------- |:-------------------- |:------------- | | `df` | 0.05 | `r_crit` | | `df` | 0.01 | `r_crit` | | `df` | 0.001 | `r_crit` |> 🔑 Important: A higher number of degrees of freedom generally leads to smaller critical values for correlation, meaning less evidence is needed to reject the null hypothesis for larger samples. ## 19.10 Random number generation Random numbers are crucial for statistical simulations, sampling methods like bootstrapping, and conducting experiments where randomness is required. These numbers should be uniformly distributed. Tables of random numbers provide sequences of digits that are generated through a deterministic process but appear random. These tables are used to select random samples or assign subjects to treatment groups. > **🔑 Important:** When using random numbers from a table, ensure you have a clear starting point and method for selecting numbers to avoid bias [343](#page=343). > **🔑 Important:** The concept of correlation measures the strength and direction of a linear relationship between two variables, while regression aims to model this relationship for prediction [342](#page=342).

© 2026 Maeve. All rights reserved. This content is protected by copyright.

See also