What is Statistics? #
Statistics is the study of collecting, analyzing, and interpreting data to find patterns and make decisions.
Mean (Average) #
The mean is the average of all values.
Formula: #
Mean = Sum of values / Total number of values
Example:
Median #
The median is the middle value when data is sorted.
Example: #
Even case:
Mode #
The mode is the value that appears most frequently.
Example: #
Variance #
Variance measures how far data is spread from the mean.
Formula: #
Example:
Data = [2, 4, 6]
Mean = 4
Variance = [(2-4)² + (4-4)² + (6-4)²] / 3
= (4 + 0 + 4) / 3
= 2.67Standard Deviation #
Standard deviation is the square root of variance.
Formula: #
Standard Deviation = √Variance
Example:
SD = √2.67 ≈ 1.63
SD = √2.67 ≈ 1.63
Probability Basics #
Probability measures the chance of an event happening.
Formula: #
Probability = Favorable outcomes / Total outcomes
Example:
Coin toss: P(Heads) = 1 / 2 = 0.5
Basic Python Example
import numpy as np
data = [2, 4, 6, 8, 8]
# Mean
print("Mean:", np.mean(data))
# Median
print("Median:", np.median(data))
# Mode (simple way)
from collections import Counter
print("Mode:", Counter(data).most_common(1)[0][0])
# Variance
print("Variance:", np.var(data))
# Standard Deviation
print("Std Dev:", np.std(data))