Statistical Operations

ECON 3209 · Week 3, Lecture 3 · Kerala Agricultural University

Department of Development Economics, KAU

Autumn 2026

Learning Outcomes

By the end of this lecture, you will be able to:

  1. Compute descriptive statistics with NumPy
  2. Work with percentiles, standard deviation, and correlation
  3. Generate random numbers from common distributions
  4. Use seeds for reproducible simulation results
  5. Interpret statistical output in agricultural and banking contexts

NumPy as a Statistics Toolkit

  • NumPy is not only for arrays and algebra
  • It also provides fast descriptive statistics
  • These tools are useful before any regression analysis
  • Economists begin by summarising data, looking for variation and patterns
  • The same functions work on small examples and large datasets

Mean, Median, and Standard Deviation

  • The mean is the average value
  • The median is the middle observation after sorting
  • Standard deviation measures dispersion
  • ddof=1 gives the sample standard deviation

Percentiles and Quantiles

  • Percentiles show the position of observations within the distribution
  • They are useful when averages hide skewed data
  • Banks often study medians and upper quantiles of loan exposure
  • Agricultural incomes are also often better summarised with quantiles

Axis-Based Statistics

  • axis=0 means compute down each column
  • axis=1 means compute across each row
  • This is useful for panel-like data and multivariable summaries
  • Understanding axes is essential when working with matrices

Correlation and Covariance

  • Covariance measures whether variables move together
  • Correlation rescales that relationship between -1 and 1
  • Positive correlation means the variables tend to rise together
  • Correlation does not imply causation

Random Numbers and Reproducibility

  • Random draws are central in simulation and resampling
  • seed() makes results reproducible for teaching and research
  • Uniform draws lie between 0 and 1
  • Normal draws follow the bell-shaped distribution

Simulating Crop Yield Shocks

  • Simulation helps us think about uncertainty
  • Here random weather shocks affect paddy yield
  • We can study possible outcomes without collecting new data first
  • Monte Carlo logic is widely used in modern econometrics

Common Distributions in Applied Work

Useful Distributions

  • Uniform for random assignment ideas
  • Normal for measurement error and shocks
  • Binomial for success/failure counts
  • Poisson for event counts

Economic Examples

  • Rainfall shock simulations
  • Loan default events
  • Crop pest incidents
  • Sampling variation in surveys

Standardising Data with Z-Scores

  • Z-scores show how far an observation is from the mean
  • They are measured in standard deviations
  • Standardisation helps compare variables on different scales
  • This idea appears in data cleaning and index construction

Interpreting Summary Statistics Carefully

  • The mean can be distorted by outliers
  • The standard deviation depends on the scale of the variable
  • Correlation shows association, not policy effect
  • Simulations depend on assumptions about the distribution
  • Statistical summaries guide the next step; they do not replace economic reasoning

Always combine numerical summaries with domain knowledge about crops, climate, markets, and institutions.

Exercise

Create a NumPy array of coconut yields: 9000, 10400, 9800, 11200, 10750.

  1. Compute the mean and sample standard deviation.
  2. Compute the 25th and 75th percentiles.
  3. Generate 5 random normal shocks with mean 0 and standard deviation 150 using a fixed seed.

Summary

  • ✅ NumPy computes core descriptive statistics quickly
  • ✅ Percentiles reveal distribution shape beyond the mean
  • axis lets us summarise rows or columns of matrices
  • ✅ Correlation and covariance describe co-movement
  • ✅ Random seeds make simulation reproducible
  • ✅ Statistical summaries are the first step in serious econometric analysis

Next Lecture

Series & DataFrames with pandas

  • We will move from arrays to labelled tabular data
  • pandas will let us organise observations and variables more naturally
  • This is the standard toolkit for applied data wrangling