0% found this document useful (0 votes)
10 views29 pages

Discrete vs. Continuous Variables Explained

The document outlines the differences between discrete and continuous variables, including their nature, measurement scales, and representation methods. It also explains nominal and ordinal data, various types of graphs such as histograms and bar charts, and introduces concepts like variance, standard deviation, probability, covariance, correlation, and hypothesis testing. Additionally, it covers the five-number summary, box plots, normal distribution, outliers, permutations, and combinations.

Uploaded by

xesetey229
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views29 pages

Discrete vs. Continuous Variables Explained

The document outlines the differences between discrete and continuous variables, including their nature, measurement scales, and representation methods. It also explains nominal and ordinal data, various types of graphs such as histograms and bar charts, and introduces concepts like variance, standard deviation, probability, covariance, correlation, and hypothesis testing. Additionally, it covers the five-number summary, box plots, normal distribution, outliers, permutations, and combinations.

Uploaded by

xesetey229
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Discrete Variables vs.

Continuous Variables

Discrete
Aspect Continuous Variable
Variables

They can take only


They can take any value
Nature of Values specific or discrete
within a specific range.
values.

Discrete variables
are typically Continuous variables are
Measurement
measured on a typically measured on an
Scale
nominal or ordinal interval or ratio scale.
scale.

Discrete variables
are often Continuous variables are
Representation represented by bar often represented by line
graphs or graphs or smooth curves.
histograms.

Examples Examples include Examples include


the number of measurements such as
students in a class length, time, or temperature.
or the outcomes of
rolling a die.

Discrete variables
Continuous variables have
Probability have probability
probability density functions
Distributions mass functions
(PDF).
(PMF)

They are often employed in


They are employed
various branches of
in various
mathematics, including
mathematical
calculus, differential
Applications contexts and
equations, and real analysis,
applications where
as well as in applied fields
quantities are
such as physics, engineering
counted.
and statistics.

Nominal vs. Ordinal

Nominal Data
● Definition: Categories without any order.

● Just labels or names. You cannot say one is more or less than another.

● Examples:

○ Gender: Male, Female, Other


○ Colors: Red, Blue, Green

○ Religion: Hindu, Muslim, Christian, Sikh

○ Marital Status: Single, Married, Divorced

🧠 Tip to remember: “Nominal” = “Name only”.

🔹 Ordinal Data
● Definition: Categories with a meaningful order, but the difference between them is
not measured.

● You can rank them, but you don’t know how much better or worse they are.

● Examples:

○ Education Level: High School < Bachelor's < Master's < PhD

○ Satisfaction Rating: Very Dissatisfied < Dissatisfied < Neutral < Satisfied <
Very Satisfied

○ T-shirt sizes: Small < Medium < Large < XL

🧠 Tip to remember: “Ordinal” = “Order matters”.

Histogram VS Bar Chart

Feature Histogram Bar Chart

Type of data Continuous (numerical) Categorical (nominal/ordinal)

X-axis Intervals or bins Categories

Bars touch? Yes No

Example Age groups, test scores Favorite colors, car brands

Shows Distribution Comparison


Histogram:
Question 1:In a Park, there are 28 trees of different heights, the heights
can be measured in centimeters and the range of the trees lie between
100-350 cm. Draw the Histogram for the following data,

Solution:
Since the height of the trees are lying between 100-350, we shall start by
marking the heights on x-axis in groups of 50cm each and the number of
trees will be mentioned on y-axis.

Therefore, if a tree has a height of 230 cm, it will lie in the rectangle 200-
250.
Bar Chart:

Question 1: Draw the Bar Graph for the following table,

Solution:
The Bar Graph for the following table is,

🥧 1. Pie Charts
✅ What is a Pie Chart?

● A circular chart divided into slices.

● Each slice represents a category's proportion out of the total.

● Used for categorical data and percentages.

Fruit Frequency

Mango 6

apple 5

Banana 5

Orange 2
Grapes 2

✅ Step-by-step:

1. Total responses = 6 + 5 + 5 + 2 + 2 = 20

2. Calculate percentage:

○ Mango: (6 / 20) × 100 = 30%

○ Apple: (5 / 20) × 100 = 25%

○ Banana: (5 / 20) × 100 = 25%

○ Orange: (2 / 20) × 100 = 10%

○ Grapes: (2 / 20) × 100 = 10%

Now each slice in the pie chart will reflect this proportion.

📍 2. Scatter Plots

✅ What is a Scatter Plot?


● A graph of points (dots).

● Each dot shows two numerical values: one on the x-axis and one on the y-axis.

● Used to show relationships, patterns, or trends between two variables.

Height vs Weight of 6 people:

Person Height Weight

A 150 50

B 160 55
C 170 60

D 180 70

E 195 65

F 175 75

Variance, Std. Deviation

📘 Definitions (in Simple Words)


✅ Variance (σ²)
It measures the average squared distance of each value from the mean.

📌 Steps:

1. Find the mean (average).

2. Subtract the mean from each number.

3. Square those results (to make all differences positive).

4. Find the average of those squared differences.

✅ Standard Deviation (σ)


It’s just the square root of the variance.
So it's in the original units, and easier to interpret.

🧮 Example (Intuition)
Two datasets (both have same mean = 50):
● Set A: [48, 49, 50, 51, 52] → very close to 50

● Set B: [30, 40, 50, 60, 70] → far spread around 50

● Both h
Probability Basics

🎯 What is Probability?
Probability means how likely something is to happen.
It’s a number between 0 and 1 (or 0% to 100%).

● If something is certain → Probability = 1 (100%)

● If something is impossible → Probability = 0 (0%)

● If it's equally likely → Probability = 0.5 (50%)

🧠 Formula:

Probability=Favorable outcomesTotal outcomes\text{Probability} = \frac{\text{Favorable


outcomes}}{\text{Total outcomes}}Probability=Total outcomesFavorable outcomes

🧪 Coin Example
A coin has 2 sides: Head (H) and Tail (T)

● P(Head) = 1 / 2 = 0.5

● P(Tail) = 1 / 2 = 0.5

🎲 If you flip it twice, possible outcomes:


HH, HT, TH, TT → 4 total outcomes

🎲 Dice Example
A fair dice has 6 sides: 1, 2, 3, 4, 5, 6

● P(getting a 4) = 1 / 6

● P(getting an even number) = 3 / 6 = 0.5 (even numbers: 2, 4, 6)

🔗 Basic Probability Rules


✅ AND Rule (Both events happen)
If A and B are two independent events:

P(A and B)=P(A)×P(B)P(A \text{ and } B) = P(A) × P(B)P(A and B)=P(A)×P(B)

🧠 Example: Toss a coin & roll a dice

● P(Head and 6) = (1/2) × (1/6) = 1/12

✅ OR Rule (Either A or B happens)


If events A and B are mutually exclusive (can’t happen together):

P(A or B)=P(A)+P(B)P(A \text{ or } B) = P(A) + P(B)P(A or B)=P(A)+P(B)

🧠 Example: Roll a dice

● P(2 or 4) = 1/6 + 1/6 = 2/6 = 1/3

✅ NOT Rule (A doesn’t happen)


P(not A)=1−P(A)P(\text{not A}) = 1 − P(A)P(not A)=1−P(A)

🧠 Example:

● P(not getting a 5 on dice) = 1 − 1/6 = 5/6

Covariance vs. Correlation

This table shows the difference between Covariance and Covariance:

Covariance Correlation

Covariance is a measure of how Correlation is a statistical measure


much two random variables that indicates how strongly two
vary together variables are related.
Involves the relationship
Involves the relationship between
between two variables or data
multiple variables as well
sets

Lie between -infinity and


Lie between -1 and +1
+infinity

Measure of correlation Scaled version of covariance

Provides direction of Provides direction and strength of


relationship relationship

Dependent on scale of variable Independent on scale of variable

Have dimensions Dimensionless

Five-Number Summary:

📐 What is the Five Number Summary?


Q. Why use a box plot? To determine the outliers.

The five-number summary gives you a quick snapshot of the distribution of your data.
How do you determine the Outlier ?

Ans : ✅ It includes:
1. Minimum – Smallest value in the dataset

2. Q1 (First Quartile) – 25th percentile

3. Median (Q2) – 50th percentile

4. Q3 (Third Quartile) – 75th percentile

5. Maximum – Largest value in the dataset

🧠 Example:
Suppose you have this dataset:
2, 4, 5, 7, 8, 10, 12, 14, 18, 20

● Minimum = 2

● Q1 = Median of lower half = (4 + 5)/2 = 4.5

● Median (Q2) = (8 + 10)/2 = 9

● Q3 = Median of upper half = (14 + 18)/2 = 16

● Maximum = 20

✨ So the Five Number Summary is:

[2, 4.5, 9, 16, 20]

📊 What is a Box Plot (Box-and-Whisker Plot)?


A box plot is a graphical representation of the five-number summary.

It shows:
● A box from Q1 to Q3 (this is the Interquartile Range, IQR)

● A line inside the box at the Median (Q2)


● Two whiskers:

○ From Minimum to Q1

○ From Q3 to Maximum

Visual layout:
lua
CopyEdit
|----|=======|----|
min Q1 Q2 Q3 max

Helps you see:


● Where the center of the data is

● How spread out the data is

● Any outliers (if added)

● Skewness of the data

📌 Box Plot Key Points:


● If the box is centered, the data is symmetric.

● If the median is closer to Q1 or Q3, the data is skewed.

● You can also extend it to show outliers (using 1.5 × IQR rule).

Normal Distribution:

Normal Distribution also called guesion distribution

● The peak (center) is where most of the values are (mean , median , mode).
● On the right side the all values are positive

Empirical Rule (68–95–99.7 Rule):


Range % of Data

μ ± 1σ ≈ 68%

μ ± 2σ ≈ 95%

μ ± 3σ ≈ 99.7%

Example: If the average test score is 70 (mean), and std. dev. is 10:

● 68% of students score between 60 and 80

● 95% score between 50 and 90

● 99.7% score between 40 and 100

● When we apply the Z-score formula to all values in a normal distribution, the
result becomes a standard normal distribution.
This process is called standardization.

✅ Simple Notes on Normal Distribution


1. Bell Shape

○ The normal distribution looks like a hill or bell.

○ It's even on both sides – same shape left and right.

2. 68-95-99.7 Rule

○ About 68% of values are close to the mean (within 1 standard deviation).

○ 95% are within 2 standard deviations.

○ 99.7% are within 3 standard deviations.

3. Z-Score

○ It tells us how far a value is from the average.

○ Helps us compare and standardize data.

4. Why It Happens Often (Central Limit Theorem)

○ When we take the average of many things (like test scores), the result
becomes normal, even if the original data is not.
5. When Data is Not Normal

○ If data is skewed (more on one side) or has extreme values (outliers),


then it’s not normal.

○ Example: salaries, YouTube views.

Outliers:

An outlier is a data point that is significantly different from the other values in a dataset.

Great question! In a box plot, the lower fence and upper fence help us detect outliers.
These fences are calculated using the Interquartile Range (IQR).

📊 Step-by-Step:
1. Find Q1 and Q3:

● Q1 (25th percentile): Lower quartile

● Q3 (75th percentile): Upper quartile

2. Calculate IQR:
IQR=Q3−Q1\text{IQR} = Q3 - Q1IQR=Q3−Q1

3. Calculate the Fences :

● Lower Fence = Q1 - 1.5 × IQR

● Upper Fence = Q3 + 1.5 × IQR

✅ In Box Plot:
● Points below the lower fence or above the upper fence are outliers

● The box shows Q1 to Q3

● The whiskers extend to the minimum and maximum values within the fences

● Dots beyond the whiskers = outliers

🔢 Example:
Suppose:

● Q1 = 40

● Q3 = 60

● IQR = 60 - 40 = 20

Then:

● Lower Fence = 40 - (1.5 × 20) = 10

● Upper Fence = 60 + (1.5 × 20) = 90

So:

● Values < 10 or > 90 are outliers

Permutation and Combination


🔢 Permutation (Arrangement):
Order matters.

👉 If you're arranging items or people in a line, the order you put them in makes a difference
— that’s a permutation.

🔍 Example:

You have 3 students: A, B, and C.


How many ways can they stand in line?

● ABC

● ACB

● BAC

● BCA

● CAB

● CBA

✅ Answer: 6 ways (This is a permutation.)


Combination (Selection):
Order doesn't matter.

👉 If you're selecting items or people and you don't care about the order, it’s a
combination.

🔍 Example:

You have 3 students: A, B, and C.


How many ways can you select 2 students to form a team?

● AB

● AC

● BC

✅ Answer: 3 ways (This is a combination. AB = BA here.)


HYPOTHESIS TESTING :

Hypothesis testing is like a trial or test to check if a claim about a population is likely to be
true or not, based on a sample of data.

1. Null Hypothesis(H0): "There is no change, no effect, or nothing special happening.

Ex : Coin is fair

2. Alternate Hypothesis(H1): Something is happening!”

Ex : The Coin is not fair

3. Experiment : It’s like setting up a test to find out: “If I do X, will Y change?”

Ex: Tossing coin 100 times

Significance Level (α)


The threshold to decide whether to reject H₀.
Usually set to 0.05 (5%).

🧠 Meaning:

"I’m okay with a 5% chance of making a wrong decision."

Test Statistic

A number that tells how different your sample is from what H₀


says.
Comes from a formula — like t-test or z-test.

🧠 Example:
Using a t-test, you calculate:

from scipy import stats

stats.ttest_1samp(sample, popmean=500)

. p-value

The probability of getting results like yours if H₀ is actually


true.

🧠 Example:
You get p = 0.02

⏬ Interpret this:

● If p < 0.05, your result is rare under H₀ → so reject H₀

● If p ≥ 0.05, the result is not rare → don’t reject H₀

Decision

Now you make your conclusion:

p- Decision Conclusion
value

<α Reject H₀ "We have evidence for H₁"


≥α Do not reject "We don’t have enough
H₀ evidence for H₁"

🧠 Example:
If p = 0.02 and α = 0.05
→ Reject H₀
→ The average juice content is not 500 ml.

Imagine this situation:

You are a judge in a court.


Your job is to decide if a person is guilty or innocent.

There are two possibilities:

● The person is actually innocent

● The person is actually guilty

But you have to make a decision:

● Declare them guilty

● Declare them innocent

Now let’s see the two types of errors:

✅ Type 1 Error (False Positive):

You think the person is guilty,


👉 but they are actually innocent.

This is like punishing an innocent person.


📌 You rejected the truth (null hypothesis).
✅ Type 2 Error (False Negative):

You think the person is innocent,


👉 but they are actually guilty.

This is like letting a guilty person go free.


📌 You accepted something false.

🧠 In Statistics terms:

Error What happens Example


Type

Type 1 You reject the null when it's true Saying a coin is unfair when it
is fair

Type 2 You fail to reject the null when it's Saying a coin is fair when it is
false unfair

🔁 Easy Trick to Remember:

● Type 1 = False Alarm ❌ (You said something is wrong, but it


wasn’t)

● Type 2 = Missed Alarm 🙈 (You said everything is okay, but it wasn’t)

🎯 What Are "Tails" in Hypothesis Testing?


In hypothesis testing, the "tail" refers to the end(s) of a distribution curve (bell curve).

11 One-Tailed Test
1️⃣
✅ Used when you're testing for a specific direction
(e.g., greater than or less than)

🎓 Example:
Claim: A new battery lasts more than 10 hours.

● H₀: Battery life ≤ 10 hours

● H₁: Battery life > 10 hours (this is one direction)

🧠 Here, you're only interested in whether the value is greater, not smaller — so you test
the right tail only.

📈 Looks like this:

sql
CopyEdit
🔽 Right Tail
|

------|----|----|----|----|----|---->
8 9 10 11 12 ...

👇 Other example:
"Battery life is less than 10 hours" → Left-tailed

22 Two-Tailed Test
2️⃣
✅ Used when you're testing for any difference —
(either greater or less than the claimed value)

🎓 Example:
Claim: Juice bottle contains exactly 500 ml

● H₀: Juice = 500 ml

● H₁: Juice ≠ 500 ml

🧠 You want to know if it’s too high or too low, so you look at both tails — left and right.

📈 Looks like this:

sql
CopyEdit
Left Tail Right Tail
↓ ↓
----|----|----|----|----|----|---->
497 498 499 500 501 502 503

🍟 Example: Fast Food Fries


A fast food chain claims their average fries pack is 100g.

You take a sample of 40 packs, and you find:

● Average = 102g

● Standard deviation = 5g

You want to check this claim.

✏ Given:

● Sample mean xˉ=102\bar{x} = 102xˉ=102

● Population mean μ=100\mu = 100μ=100

● s=5

● n = 40

● Significance level α=0.05\alpha = 0.05α=0.05

✅ Step 1: Calculate Z-score


✅ Step 2: Apply both tests

🔹 TWO-TAIL TEST

🟠 Question: "Is the average different from 100g (either more or less)?"

● Critical Z for 5% = ±1.96

● Our Z = 2.53

📌 2.53 > 1.96 → Reject H₀

🟢 Conclusion: The average pack weight is significantly different from


100g.

🔸 ONE-TAIL TEST

🟡 Question: "Is the average weight greater than 100g?"

● Critical Z for 5% = 1.645

● Our Z = 2.53

📌 2.53 > 1.645 → Reject H₀

🟢 Conclusion: The packs are heavier than 100g.

Z-Test :

🔍 What is a Z-test?
A Z-test is a statistical method used to check:

"Is the sample data really different from what we expect (or just due to
chance)?"

It helps answer:
👉 “Is the average (mean) of my sample really different from the population mean?”
🎯 When to use a Z-test?
✅ Use Z-test when:

● You know the population standard deviation (or large sample, n > 30)

● Data is normally distributed (or sample is large enough)

● You’re testing the mean of something

🍕 Example: Pizza Size Test


A pizza brand claims their pizzas are 30 cm in size.
You take a sample of 50 pizzas, and the average size is 31 cm, with standard deviation 2
cm.

You want to test the claim.


🧮 Step 1: Calculate Z

🧪 Step 2: Choose test type


🔹 Two-tail test (Are pizzas different, not just bigger?)
● Critical z = ±1.96 (for 5%)

● Our z = 3.54 → Greater than 1.96

📢 Reject H₀ → The pizzas are not 30 cm. They're significantly different.


🎯 What is a t-test?
A t-test is used to check:

“Is the sample mean (average) really different from the expected (or claimed)
mean?”

Very similar to a Z-test — but used when:

● ✅ Your sample size is small (usually n < 30), or

● ✅ You don’t know the population standard deviation (σ)

🤔 When to use t-test instead of Z-test?


Situation Use Z- Use t-
test? test?

Population std dev is known ✅ ❌


Population std dev is unknown ❌ ✅

Sample size is large (>30) ✅ ✅ (okay)

Sample size is small (<30) ❌ ✅

📏 What’s the difference between Z and t?


● Z uses the known population std deviation (σ)

● t uses the sample std deviation (s)

● t uses something called degrees of freedom = (n - 1)

● t is more flexible for small or uncertain data

🍩 Example: Donut Weight Test


A bakery claims their donuts weigh 150g.
You take a sample of 10 donuts, and find:

● Sample mean = 145g

● Sample standard deviation = 5g


● n = 10

● Significance level = 5% (α = 0.05)

Let’s test: are the donuts lighter than claimed?

You might also like