Content
    Population and Sample

Introduction to Statistics

This article is still work in progress!

The notes on this page are taken from:

Udacity: Intro to Statistics.

Packt: Statistics for Data Science and Business Analysis .

Population and Sample

Population

  • all items of interest
  • properties of interest: parameters
  • mathematical symbol: NN

Sample

  • a subset of the population
  • properties of interest: statistics
  • mathematical symbol: nn

A sample needs to be random and representative for the population.

Data

Types of Data

  • Categorical
  • Numerical
    • Discrete
    • Continuous

Measurement Levels

  • Qualitative
    • Nominal
    • Ordinal
  • Quantitative
    • Interval
    • Ratio

Statistics and Probability

Statistics and Probability

Independent Events

  • Probability of Event: PP
  • Probability of opposite Event: 1P1-P
  • Probability of composite Events: PP...PP \cdot P \cdot ... \cdot P

Dependent Events

P(AB)P(A\mid B): Probability of Event AA when BB already occurred.

Probability Distributions

In Continuous Distributions every outcome has the Probability 00.

Density

PDF: Probability Density Function

Probability for continuous spaces. Density can be bigger than 11.

Density:

  • Always non-negative
  • Doesn’t need to be continuous
  • Doesn’t need to be smaller or equal than one
  • Integrates to one

Estimation

Estimation problem is:

Data → P

P → P(Data)

Maximum Likelihood Estimator (MLE):

1NiXi\frac{1}{N} \cdot \sum_{i}^{} X_i

The sum is always between 00 and 11.

Laplace Estimator:

1N+k(1+iXi)\frac{1}{N + k} \cdot \left(1 + \sum_{i}^{} X_i \right)

kk: Number of Outcomes

NN: Number of Experiments

Averages

Mean

Sum up all elements and divide by the number of elements.

Population

μ=1ni=1nxi{\displaystyle {\mu}={\frac {1}{n}}\sum_{i=1}^{n}{x_{i}}}

Sample

xˉ=1ni=1nxi{\displaystyle {\bar {x}}={\frac {1}{n}}\sum_{i=1}^{n}{x_{i}}}

Median

Sort all elements and take the one in the middle (or the mean of the two elements in the middle).

  • if nn is odd: median(x)=x(n+1)/2{\displaystyle \mathrm {median} (x)=x_{(n+1)/2}}
  • if nn is even: median(x)=x(n/2)+x(n/2)+12{\displaystyle \mathrm {median} (x)={\frac {x_{(n/2)}+x_{(n/2)+1}}{2}}}

Mode

The value of the elements that appears most often in a data set.

Asymmetry

Skewness

  • Positive skew: mean>medianmean > median
  • Zero skew: mean=median=modemean = median = mode
  • Negative skew: mean<medianmean < median

Sample Skewness

gm=1ni=1n(xix)31n1i=1n(xix)23{\displaystyle g_{m}={\frac {{\tfrac {1}{n}}\sum_{i=1}^{n}(x_{i}-{\overline {x}})^{3}}{{\sqrt {{\tfrac {1}{n-1}}\sum_{i=1}^{n}(x_{i}-{\overline {x}})^{2}}}^{3}}}}

Variability

Variance

The variance measures the dispersion of data points around their mean.

Subtract the mean from every item. Then sum up the squares of the subtractions and divide the result by the number of data items.

Population
σ2=Var(X)=1ni=1n(xiμ)2\sigma^2 = {\displaystyle \operatorname {Var} (X)={\frac {1}{n}}\sum _{i=1}^{n}(x_{i}-\mu )^{2}}
Sample
S2=1n1i=1n(xix)2{\displaystyle S^{2}={\frac {1}{n-1}}\sum _{i=1}^{n}\left(x_{i}-{\overline {x}}\right)^{2}}

Standard Deviation

The standard deviation is giving a sense how far away the items in a data set are from the mean.

It is the square root of its variance.

It’s the most common measure of variability for a single data set.

Population
σ=σ2\sigma = \sqrt{\sigma^2}
Sample
S=S2S = \sqrt{S^2}

Coefficient of Variation

It is used to compare multiple data sets.

Population
cv=σμc_{v} = \frac{\sigma}{\mu}
Sample
cv^=Sx\hat{c_{v}} = \frac{S}{\overline {x}}

Overview of Mean, Variance and Standard Deviation

These notes are taken from Khan Academy

ConceptPopulationSamples
Meanμ=1Ni=1Nxi\mu = \frac{1}{N}\sum_{i=1}^{N} x_ixˉ=1ni=1nxi\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i
Varianceσ2=1Ni=1N(xiμ)2\sigma^2 = \frac{1}{N} \sum_{i=1}^{N} (x_i - \mu)^2s2=1n1i=1N(xixˉ)2s^2 = \frac{1}{n-1} \sum_{i=1}^{N} (x_i - \bar{x})^2
Standard Deviationσ=σ2\sigma = \sqrt{\sigma^2}s=s2s = \sqrt{s^2}

NN: Number of items in Population

nn: Number of items in sample set taken from the population

For an unbiased estimator (Variance of samples) the sum is divided by n1n-1!

s=s2s = \sqrt{s^2}: is not an unbiased estimator due to the non-linear nature of the square root.

Relationship between Variables

Correlation: variables are statically related.

Covariance

Main statistic to measure correlation.

Population:

σxy=cov(x,y)=1Ni=1N(xiμx)(yiμy)\sigma_{xy} =\operatorname {cov}(x, y) = {\frac {1}{N}}\sum_{i=1}^{N}(x_{i}-\mu_x ) \cdot (y_{i}-\mu_y )

Sample:

Sxy=cov(x,y)=1n1i=1n(xix)(yiy)S_{xy} =\operatorname {cov}(x, y) = {\frac {1}{n -1}}\sum_{i=1}^{n}(x_{i}-\overline x ) \cdot (y{i}- \overline y )

Correlation Coefficient

Adjust covariance to be easy to interpret.

corr(xy)=cov(x,y)stdev(x)stdev(y)\operatorname {corr}(xy)={\frac {\operatorname {cov} (x,y)}{\operatorname{stdev}(x) \cdot \operatorname{stdev}(y)}}

The correlation coefficient is between 1-1 and 11.

Population:

ρxy=σxyσxσy\rho_{xy} =\frac{\sigma_{xy}}{\sigma_{x} \cdot \sigma_{y}}

Sample:

rxy=SxySxSyr_{xy} =\frac{S_{xy}}{S_{x} \cdot S_{y}}

Binomial Coefficients

Choose kk elements from nn possible elements (without putting back elements and without caring about the order of the chosen elements):

(nk)=n!k!(nk)!\binom{n}{k} = \frac{n!}{k! \cdot (n - k)!}

Inferential Statistics

Use Probability Theory and Distributions with sample data, to predict population values.

Distributions

A distribution is a function that shows how often each value of a variable occurs.

Binomial Distribution

Binomial Distribution is a discrete distribution.

i.e. Flip a loaded coin:

p=P(heads)p = P(heads): Probability to get a head from one coin flip.

Flip coin nn times.

P(#heads=k)P(\#heads = k): Expectation to get kk heads from all the flips.

P(#heads=k)=n!k!(nk)!pk(1p)nk=(nk)pk(1p)nkP(\#heads = k) = \frac{n!}{k! \cdot (n - k)!} \cdot p^k \cdot (1-p)^{n-k} = \binom{n}{k} \cdot p^k \cdot (1-p)^{n-k}
The Normal Distribution

Also called Gaussian Distribution or Bell Curve.

Notation:

N(μ,σ2)N \sim (\mu, \sigma^2)

Where:

  • NN \sim: Normal Distribution
  • μ\mu: Mean
  • σ2\sigma^2: Variance
  • σ\sigma: Standard Deviation

Definition:

f(x)=12πσ2e(12(xμ)2σ2)f(x) = \frac{1}{\sqrt{2\pi\sigma^2}}\cdot e^{\left(-\frac{1}{2}\cdot\frac{\left(x-\mu\right)^2}{\sigma^2}\right)}

The expression 12πσ2\frac{1}{\sqrt{2\pi\sigma^2}} is needed to normalise the area underneath the curve given by the rest of the formula (e(12(xμ)2σ2)e^{\left(-\frac{1}{2}\cdot\frac{\left(x-\mu\right)^2}{\sigma^2}\right)}). Otherwise, it would not add up to 11.

Properties:

  • mean == median == mode
  • no skew
Standard Normal Distribution

Standardizing the Normal distribution to have a mean μ=0\mu = 0 and standard deviation σ2=1\sigma^2 = 1.

(μ,σ2)  (0,1)\sim (\mu, \sigma^2) \ \Rightarrow \ \sim (0, 1)

Formula:

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

Where:

  • zN(0,1)z \sim N(0, 1)
  • zz: Standard Normal Distribution (zz-Score)
  • μ\mu: Mean
  • σ\sigma: Standard Deviation

Central Limit Theorem (CLT)

Given a normalized sample mean. That is the mean of a number of samples from a population. That sample mean converges to a standard normal distribution as the number of samples increase.

  1. take a sample from the population
  2. calculate the mean of that sample (sample mean)
  3. repeat until enough samples were processed

All the sample means together form the Sampling Distribution of the mean.

The Sampling Distribution of the mean will approximate a normal distribution no matter of what kind the population distribution is (binomial, exponential, …).

Sampling distribution:

The sampling distribution has the same mean as the original (population) distribution. It’s variance is the population variance divided by the sampling size:

N(μ,σ2n)N(\mu, \frac{\sigma^2}{n})

Where:

  • μ\mu: mean of the population distribution
  • σ2\sigma^2: variance of the population distribution
  • nn: number of samples

Typically, at least around 30 samples are needed for the CLT to apply.

Standard Error

The standard deviation of the sampling distribution.

That is standard deviation of the distribution formed by the sampling mean.

It shows the variability of the means of the samples.

Variance of the sampling distribution: σ2n\frac{\sigma^2}{n}

Standard error:

σn\frac{\sigma}{\sqrt{n}}

Estimators

Approximation of a population parameter. Depending on sample information only.

An estimator is a type of (sample) statistic.

A value of an estimator is called estimate. There are:

  • point estimates
  • confidence interval estimates

The point interval is located in the middle of the confidence interval.

Some basic estimates:

  • Sample mean xˉ\bar {x} is a point estimate of the population mean μ\mu.
  • Sample variance s2s^2 is a point estimate of the population mean σ2\sigma^2.
Properties of Estimators
  • Efficiency
  • Bias

Prefer most efficient, unbiased estimator.

Unbiased estimator: expected value equal to population parameter.

Most efficient estimator: unbiased with the smallest variance

Bayes’ Rule

See also Wikipedia

P(AB)  =  P(BA)P(A)P(B)P(A\mid B) \; = \; \frac {P(B\mid A) \cdot P(A)} {P(B)}

Prior Probability & Test Evidence -> Posterior Probability

Prior:

P(A)P(A)

Posterior:

P(AB)=P(A)P(BA)P(¬AB)=P(¬A)P(B¬A)P(A \mid B) = P(A) \cdot P(B \mid A)\\ P(\lnot A\mid B) = P(\lnot A) \cdot P(B \mid \lnot A)
  • P(A)P(A): the prior, is the initial degree of belief in AA.
  • P(AB)P(A \mid B): the posterior, is the degree of belief having accounted for BB.
  • the quotient P(BA)P(B)\frac{P(B \mid A)}{P(B)} represents the support BB provides for AA.

Algorithm

Imagine there is a disease. The possibility to get this particular disease is P(D)P(D).

There is a test to check if someone has that disease. But the test is not completely reliable.

Prior: P(D)P(D) Sensitivity: P(PosD)P(Pos \mid D) Specificity: P(Neg¬D)P(Neg \mid \lnot D)

The Prior says how many people have the disease.

The Sensitivity says how many get a positive test if they have the disease.

The Sensitivity says how many get a negative test if they don’t have the disease.

Imagine someone get’s a positive test result. How can we calculate the probability that this person has the disease?

Algorithm to calculate Bayes' rule

  1. Take the Prior and multiply it with P(PosD)P(Pos \mid D) (Sensitivity) → P(Pos,D)P(Pos, D).
  2. Take the Prior and multiply it with P(Pos¬D)P(Pos \mid \lnot D)P(Pos,¬D)P(Pos, \lnot D).
  3. Add the results of 1. and 2. up → P(Pos)P(Pos).
  4. Divide the result from 1. P(Pos,D)P(Pos, D) by the result of 3. P(Pos)P(Pos)P(DPos)P(D \mid Pos).
  5. Divide the result from 2. P(Pos,¬D)P(Pos, \lnot D) by the result of 3. P(Pos)P(Pos)P(¬DPos)P(\lnot D \mid Pos).
  6. Check: add the results of 4. and 5. → 11.

Note: P(A,B)=P(B,A)P(A, B) = P(B, A)

The calculation for a negative test result are analogous. Just replace PosPos with NegNeg.



  • Category

  • Mathematics

  • Tags

  • Statistics

  • Created

  • 22. May 2015


  • Modified

  • 18. January 2025