Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Chapter 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 44

Artificial Intelligence

Statistics

Chapter 1

Descriptive Analysis : Numerical


Describing Data Numerically
Describing Data Numerically

Central Tendency Variation

Arithmetic Mean Range

Median Interquartile Range

Mode Variance

Standard Deviation

Coefficient of Variation
Measures of Central Tendency
Overview
Central Tendency

Mean Median Mode

x i
x i1
n
Arithmetic Midpoint of Most frequently
average ranked values observed value
Arithmetic Mean
 The arithmetic mean (mean) is the most
common measure of central tendency
 For a population of N values:
N

xx1  x 2    x N
i Population
μ 
i1
values
N N
Population size

 For a sample of size n:


n

x i
x1  x 2    x n Observed
x i1
 values
n n
Sample size
Arithmetic Mean
(continued)

 The most common measure of central tendency


 Mean = sum of values divided by the number of values
 Affected by extreme values (outliers)

0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10

Mean = 3 Mean = 4
1  2  3  4  5 15 1  2  3  4  10 20
 3  4
5 5 5 5
Median
 In an ordered list, the median is the “middle”
number (50% above, 50% below)

0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10

Median = 3 Median = 3

 Not affected by extreme values


Finding the Median

 The location of the median:

n 1
Median position  positionin the ordered data
2
 If the number of values is odd, the median is the middle number
 If the number of values is even, the median is the average of
the two middle numbers

n 1
 Note that is not the value of the median, only the
2
position of the median in the ranked data
Mode
 A measure of central tendency
 Value that occurs most often
 Not affected by extreme values
 Used for either numerical or categorical data
 There may may be no mode
 There may be several modes

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 1 2 3 4 5 6

No Mode
Mode = 9
Review Example
 Five houses on a hill by the beach
$2,000 K
House Prices:

$2,000,000
500,000 $500 K
300,000 $300 K
100,000
100,000

$100 K

$100 K
Review Example:
Summary Statistics

House Prices:
 Mean: ($3,000,000/5)
$2,000,000 = $600,000
500,000
300,000
100,000
100,000  Median: middle value of ranked data
Sum 3,000,000
= $300,000

 Mode: most frequent value


= $100,000
Which measure of location
is the “best”?

 Mean is generally used, unless


extreme values (outliers) exist
 Then median is often used, since
the median is not sensitive to
extreme values.
 Example: Median home prices may be
reported for a region – less sensitive to
outliers
Shape of a Distribution

 Describes how data are distributed


 Measures of shape
 Symmetric or skewed

Left-Skewed Symmetric Right-Skewed


Mean < Median Mean = Median Median < Mean
Measures of Variability
Variation

Range Interquartile Variance Standard Coefficient


Range Deviation of Variation

 Measures of variation give


information on the spread
or variability of the data
values.

Same center,
different variation
Range

 Simplest measure of variation


 Difference between the largest and the smallest
observations:

Range = Xlargest – Xsmallest

Example:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

Range = 14 - 1 = 13
Disadvantages of the Range
 Ignores the way in which data are distributed

7 8 9 10 11 12 7 8 9 10 11 12
Range = 12 - 7 = 5 Range = 12 - 7 = 5

 Sensitive to outliers
1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,4,5
Range = 5 - 1 = 4

1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,4,120
Range = 120 - 1 = 119
Interquartile Range

 Can eliminate some outlier problems by using


the interquartile range

 Eliminate high- and low-valued observations


and calculate the range of the middle 50% of
the data

 Interquartile range = 3rd quartile – 1st quartile


IQR = Q3 – Q1
Interquartile Range

Example:
Median X
X Q1 Q3 maximum
minimum (Q2)
25% 25% 25% 25%

12 30 45 57 70

Interquartile range
= 57 – 30 = 27
Quartiles
 Quartiles split the ranked data into 4 segments with
an equal number of values per segment

25% 25% 25% 25%

Q1 Q2 Q3

 The first quartile, Q1, is the value for which 25% of the
observations are smaller and 75% are larger
 Q2 is the same as the median (50% are smaller, 50% are
larger)
 Only 25% of the observations are greater than the third
quartile
Quartile Formulas

Find a quartile by determining the value in the


appropriate position in the ranked data, where

First quartile position: Q1 = 0.25(n+1)

Second quartile position: Q2 = 0.50(n+1)


(the median position)

Third quartile position: Q3 = 0.75(n+1)

where n is the number of observed values


Quartiles

 Example: Find the first quartile


Sample Ranked Data: 11 12 13 16 16 17 18 21 22

(n = 9)
Q1 = is in the 0.25(9+1) = 2.5 position of the ranked data
so use the value half way between the 2nd and 3rd values,

so Q1 = 12.5
Population Variance

 Average of squared deviations of values from


the mean
N
 Population variance:
 (x  μ)
i
2

σ 2 i1
N -1
Where μ = population mean
N = population size
xi = ith value of the variable x
Sample Variance

 Average (approximately) of squared deviations


of values from the mean
n
 Sample variance:
 (x  x)i
2

s 
2 i1
n -1
Where X = arithmetic mean
n = sample size
Xi = ith value of the variable X
Population Standard Deviation
 Most commonly used measure of variation
 Shows variation about the mean
 Has the same units as the original data

 Population standard deviation:

 i
(x  μ) 2

σ i1
N -1
Sample Standard Deviation
 Most commonly used measure of variation
 Shows variation about the mean
 Has the same units as the original data

 i
 Sample standard deviation:
(x  x) 2

S i1
n -1
Calculation Example:
Sample Standard Deviation
Sample
Data (xi) : 10 12 14 15 17 18 18 24
n=8 Mean = x = 16

(10  X)2  (12  x)2  (14  x)2    (24  x)2


s
n 1

(10  16)2  (12  16)2  (14  16)2    (24  16)2



8 1

126 A measure of the “average”


  4.2426 scatter around the mean
7
Measuring variation

Small standard deviation

Large standard deviation


Comparing Standard Deviations

Data A
Mean = 15.5
11 12 13 14 15 16 17 18 19 20 21 s = 3.338

Data B
Mean = 15.5
11 12 13 14 15 16 17 18 19 20 21 s = 0.926
Data C
Mean = 15.5
11 12 13 14 15 16 17 18 19 20 21 s = 4.570
Advantages of Variance and
Standard Deviation

 Each value in the data set is used in the


calculation

 Values far from the mean are given extra


weight
(because deviations from the mean are squared)
The Empirical Rule

 If the data distribution is bell-shaped, then


the interval:
 μ  1σ contains about 68% of the values in
the population or the sample

68%

μ
μ  1σ
The Empirical Rule
 μ  2σ contains about 95% of the values in
the population or the sample
 μ  3σ contains about 99.7% of the values
in the population or the sample

95% 99.7%

μ  2σ μ  3σ
Coefficient of Variation

 Measures relative variation


 Always in percentage (%)
 Shows variation relative to mean
 Can be used to compare two or more sets of
data measured in different units

 s
CV     100%
x 
Comparing Coefficient
of Variation
 Stock A:
 Average price last year = $50

 Standard deviation = $5

s $5
CVA    100%  100%  10%
x $50 Both stocks
have the same
 Stock B:
standard
 Average price last year = $100 deviation, but
stock B is less
 Standard deviation = $5 variable relative
to its price
s $5
CVB    100%  100%  5%
x $100
Using Microsoft Excel

 Descriptive Statistics can be obtained


from Microsoft® Excel
 Use menu choice:
tools / data analysis / descriptive statistics

 Enter details in dialog box


Using Excel

Use menu choice:


tools / data analysis /
descriptive statistics
Using Excel
(continued)

 Enter dialog box


details

 Check box for


summary statistics

 Click OK
Excel output
Microsoft Excel
descriptive statistics output,
using the house price data:
House Prices:

$2,000,000
500,000
300,000
100,000
100,000
The Sample Covariance
 The covariance measures the strength of the linear relationship
between two variables

 The population covariance:


N

 (x   i x )(yi   y )
Cov (x , y)   xy  i1
N
 The sample covariance:
n

 (x  x)(y  y)
i i
Cov (x , y)  s xy  i1
n 1
 Only concerned with the strength of the relationship
 No causal effect is implied
Interpreting Covariance

 Covariance between two variables:

Cov(x,y) > 0 x and y tend to move in the same direction

Cov(x,y) < 0 x and y tend to move in opposite directions

Cov(x,y) = 0 x and y are independent


Coefficient of Correlation
 Measures the relative strength of the linear relationship
between two variables

 Population correlation coefficient:


Cov (x , y)
ρ
σXσY
 Sample correlation coefficient:
Cov (x , y)
r
sX sY
Features of
Correlation Coefficient, r
 Unit free
 Ranges between –1 and 1
 The closer to –1, the stronger the negative linear
relationship
 The closer to 1, the stronger the positive linear
relationship
 The closer to 0, the weaker any positive linear
relationship
Scatter Plots of Data with Various
Correlation Coefficients
Y Y Y

X X X
r = -1 r = -.6 r=0
Y
Y Y

X X X
r = +1 r = +.3 r=0
Using Excel to Find
the Correlation Coefficient
 Select
Tools/Data Analysis
 Choose Correlation from
the selection menu
 Click OK . . .
Using Excel to Find
the Correlation Coefficient
(continued)

 Input data range and select


appropriate options
 Click OK to get output
Interpreting the Result
Scatter Plot of Test Scores
 r = .733 100

95

Test #2 Score
 There is a relatively 90

85

strong positive linear 80

relationship between 75

test score #1 70
70 75 80 85 90 95 100

Test #1 Score
and test score #2

 Students who scored high on the first test tended


to score high on second test

You might also like