13
Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M. Ross Chapter 2 Descriptive Statistics Instructor – Sunghae Jun 1 Chapter 2 Descriptive Statistics 2.1 서론 Introduction 기술통계학(descriptive statistics) – 데이터를 기술하고 요약 2.2 데이터 집합의 기술 Describing Data Sets 2.2.1 빈도표와 그래프 Frequency tables and graphs 전기공학과 학사학위 취득자의 초임연봉 자료 (42 , 단위: 천달러) 47, 47, 47, 47, 48, 49, 49, 49, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 54, 54, 54, 54, 54, 56, 56, 57, 57, 57, 60 Table 2.1 Starting Yearly Salaries: frequency table Starting Salary Frequency 47 48 49 50 51 52 54 56 57 60 4 1 3 5 8 10 5 2 3 1 Figure 2.2 Bar graph for starting salary data.

Chapter 2 Descriptive Statistics - cju.ac.krdelab.cju.ac.kr/ch2.pdf · 2019-03-05 · Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Chapter 2 Descriptive Statistics - cju.ac.krdelab.cju.ac.kr/ch2.pdf · 2019-03-05 · Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M

Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M. Ross

Chapter 2 Descriptive Statistics

Instructor – Sunghae Jun

1

Chapter 2 Descriptive Statistics

2.1 서론 Introduction

기술통계학(descriptive statistics) – 데이터를 기술하고 요약

2.2 데이터 집합의 기술 Describing Data Sets

2.2.1 빈도표와 그래프 Frequency tables and graphs

전기공학과 학사학위 취득자의 초임연봉 자료 (42명, 단위: 천달러)

47, 47, 47, 47, 48, 49, 49, 49, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 51, 51, 51, 52, 52, 52, 52,

52, 52, 52, 52, 52, 52, 54, 54, 54, 54, 54, 56, 56, 57, 57, 57, 60

Table 2.1 Starting Yearly Salaries: frequency table

Starting Salary Frequency

47

48

49

50

51

52

54

56

57

60

4

1

3

5

8

10

5

2

3

1

Figure 2.2 Bar graph for starting salary data.

Page 2: Chapter 2 Descriptive Statistics - cju.ac.krdelab.cju.ac.kr/ch2.pdf · 2019-03-05 · Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M

Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M. Ross

Chapter 2 Descriptive Statistics

Instructor – Sunghae Jun

2

2.2.2 상대빈도표와 그래프 Relative frequency tables and graphs

Table 2.2 Starting Yearly Salaries: relative frequency table

Page 3: Chapter 2 Descriptive Statistics - cju.ac.krdelab.cju.ac.kr/ch2.pdf · 2019-03-05 · Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M

Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M. Ross

Chapter 2 Descriptive Statistics

Instructor – Sunghae Jun

3

Start.salary=c(47,47,47,47,48,49,49,49,50,50,50,50,50,51,51,51,51,51,51,51,51,52,52,52,

52,52,52,52,52,52,52,54,54,54,54,54,56,56,57,57,57,60)

hist(Start.salary, freq=T, ylab="Frequency") # 막대그래프

hist(Start.salary, freq=F, ylab="Relative Frequency") # 히스토그램

2.2.3 Grouped data, histograms, ogives (누적도수분포도), and stem and leaf

plots

표 2.3 백열등 200개의 수명

표 2.4 계급빈도 표

Page 4: Chapter 2 Descriptive Statistics - cju.ac.krdelab.cju.ac.kr/ch2.pdf · 2019-03-05 · Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M

Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M. Ross

Chapter 2 Descriptive Statistics

Instructor – Sunghae Jun

4

그림 2.5 빈도 히스토그램

[줄기-잎 그림]

줄기-잎 그림을 그리기 위해서는 먼저 주어진 데이터 값을 줄기부분과 잎부분으로

나누어야 한다.

(ex) 12, 14, 23, 16, 24, 27, 35, 34

줄기부분: 10자리, 잎부분: 1자리

1: 2 4 6

2: 3 4 7

3: 5 4

> x=c(12, 14, 23, 16, 24, 27, 35, 34)

> stem(x)

1 | 24

1 | 6

2 | 34

2 | 7

3 | 4

3 | 5

> stem(x, scale=0.5)

1 | 246

2 | 347

3 | 45

[R을 이용한 줄기 잎 그림]

Stem-and-Leaf Plots

Usage

Page 5: Chapter 2 Descriptive Statistics - cju.ac.krdelab.cju.ac.kr/ch2.pdf · 2019-03-05 · Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M

Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M. Ross

Chapter 2 Descriptive Statistics

Instructor – Sunghae Jun

5

stem(x, scale=1, width=80)

Arguments

x: a numeric vector.

scale: This controls the plot length. (출력되는 줄기 잎 그림의 형태가 달라짐)

width: The desired width of plot. (출력화면의 넓이 지정, 너무 작게 하면 그림이 축소됨)

> stem(Start.salary)

46 | 0000

48 | 0000

50 | 0000000000000

52 | 0000000000

54 | 00000

56 | 00000

58 |

60 | 0

> stem(Start.salary, scale=0.5)

4 | 77778999

5 | 0000011111111222222222244444

5 | 66777

6 | 0

> stem(Start.salary, scale=0.2)

4 | 77778999

5 | 000001111111122222222224444466777

6 | 0

> stem(Start.salary, scale=0.2, width=20)

4 | 77778999

5 | 00000111+13

6 | 0

Page 6: Chapter 2 Descriptive Statistics - cju.ac.krdelab.cju.ac.kr/ch2.pdf · 2019-03-05 · Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M

Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M. Ross

Chapter 2 Descriptive Statistics

Instructor – Sunghae Jun

6

2.3 데이터집합에 대한 요약 Summarizing Data Sets

2.3.1 (표본)평균, (표본)중앙값, (표본)최빈값 Sample mean, sample median, and

sample mode

[중앙값] (n=자료의 크기)

n: 홀수 median은 (n+1)/2 위치의 값

n: 짝수 median은 n/2 위치와 n/2 + 1 위치의 값의 평균

(예) 1, 2, 3, 4 에서 중앙값은 (2+3)/2=2.5

(예제 2.3a)

1999년에서 2008년까지의 미국 마스터즈 골프 토너먼트에서 우승점수는 다음과 같다.

280, 278, 272, 276, 281, 279, 276, 281, 289, 280

golf=c(280, 278, 272, 276, 281, 279, 276, 281, 289, 280)

mean(golf) # 평균

[1] 279.2

median(golf) # 중앙값

[1] 279.5

R을 이용한 최빈값 구하기?

table(golf)

golf

272 276 278 279 280 281 289

1 2 1 1 2 2 1

which.max(table(golf))

276

2

names(which.max(table(golf)))

[1] "276"

(note) 최빈값이 2개 이상인 경우?

Page 7: Chapter 2 Descriptive Statistics - cju.ac.krdelab.cju.ac.kr/ch2.pdf · 2019-03-05 · Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M

Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M. Ross

Chapter 2 Descriptive Statistics

Instructor – Sunghae Jun

7

(예제 2.3b)

다음은 청소년 교향악단 단원들의 연령별 빈도표이다.

연령 빈도

15

16

17

18

19

20

2

5

11

9

14

13

이 교향악단 54명 단원들의 연령에 대한 표본평균을 구하라.

(15*2+16*5+17*11+18*9+19*14+20*13)/(2+5+11+9+14+13) #가중평균 (weighted

average)

[1] 18.24074

2.3.2 표본분산과 표본표준편차

표본분산, 𝑠𝑠2 = 1𝑛𝑛−1

∑ (𝑥𝑥𝑖𝑖 − �̅�𝑥)2𝑛𝑛𝑖𝑖=1

표본표준편차, s

(예제 2.3f)

다음의 주어진 데이터 집합 A와 B에 대하여 표본분산을 구하라.

A: 3, 4, 6, 7, 10

B: -20, 5, 15, 24

A=c(3, 4, 6, 7, 10)

B=c(-20, 5, 15, 24)

var(A) # A의 분산

[1] 7.5

var(B) # B의 분산

[1] 360.6667

sd(A) # A의 표준편차

[1] 2.738613

sd(B) # B의 표준편차

[1] 18.99123

sqrt(var(A)) # A의 분산의 제곱근

[1] 2.738613

Page 8: Chapter 2 Descriptive Statistics - cju.ac.krdelab.cju.ac.kr/ch2.pdf · 2019-03-05 · Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M

Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M. Ross

Chapter 2 Descriptive Statistics

Instructor – Sunghae Jun

8

sqrt(var(B)) # B의 분산의 제곱근

[1] 18.99123

[대수적 등식] ∑𝑥𝑥𝑖𝑖 = 𝑛𝑛�̅�𝑥 ∑(𝑥𝑥𝑖𝑖 − �̅�𝑥)2 =∑𝑥𝑥𝑖𝑖2 − 𝑛𝑛�̅�𝑥2

(note) 각 데이터 값에 상수를 더하는 것은 표본분산을 변화시키지 않는 반면, 각

데이터 값에 어떤 상수를 곱할 경우 새로운 표본분산은 원래의 표본분산에 그 상수의

제곱을 곱한 것과 같게 된다.

y=a+bx 𝒔𝒔𝒚𝒚𝟐𝟐 = 𝒃𝒃𝟐𝟐𝒔𝒔𝒙𝒙𝟐𝟐

2.3.3. 표본 백분위수와 상자그림

표본 100p 백분위수(sample 100p percentile)는 데이터의 100p%가 그 이하의 값을 갖고

100(1-p)%가 그 이상의 값을 갖게 되는 데이터 값을 말한다. 두 개의 데이터 값이

이러한 조건을 만족시킬 경우 그 두 값의 산술평균이 표본 100p 백분위수가 된다.

(note) 백분위수의 계산결과는 통계패키지에 따라 조금씩 다르기도 함.

제 1사분위수 (Q1) : 25백분위수

제 2사분위수 (Q2) : 50백분위수 (median)

제 3사분위수 (Q3) : 75백분위수

사분위수범위(inter-quartile range; IQR) = Q3 – Q1

범위(range) = Max – Min

[상자그림]

Page 9: Chapter 2 Descriptive Statistics - cju.ac.krdelab.cju.ac.kr/ch2.pdf · 2019-03-05 · Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M

Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M. Ross

Chapter 2 Descriptive Statistics

Instructor – Sunghae Jun

9

(예제 2.3i)

다음의 데이터는 맨해튼의 그랜드센트럴 역 바로 밖에서 36 회에 걸쳐 측정된 소음

수준을 나타낸다. 이 데이터집합에 대한 사분위수를 구하라.

82,89,94,110,74,122,112,95,100,78,65,60,90,83,87,75,114,85,69,94,124,115,107,88,97,74,72,6

8,83,91,90,102,77.125,108,65

m=c(82,89,94,110,74,122,112,95,100,78,65,60,90,83,87,75,114,85,69,94,124,115,107,88

,97,74,72,68,83,91,90,102,77.125,108,65)

quantile(m) # Min, Q1, Q2, Q3, Max 를 구하여 줌.

0% 25% 50% 75% 100%

60.0000 76.0625 89.0000 101.0000 124.0000

quantile(m, probs=0.5) # 50 백분위수

50%

89

quantile(m, probs=0.43) # 43 백분위수

43%

86.24

IQR(m) # 사분위수범위를 구함

[1] 24.9375

range(m) # Max와 Min을 구하여 줌

[1] 60 124

boxplot(m, horizontal = TRUE) # 상자그림, horizontal=FALSE로 하면 수직으로 그려줌

60 70 80 90 100 110 120

Page 10: Chapter 2 Descriptive Statistics - cju.ac.krdelab.cju.ac.kr/ch2.pdf · 2019-03-05 · Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M

Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M. Ross

Chapter 2 Descriptive Statistics

Instructor – Sunghae Jun

10

2.4 체비셰프 부등식 Chebyshev’s Inequality

임의의 k(≥1)에 대하여 100 �1 − 1𝑘𝑘2� %보다 많은 데이터가 �̅�𝑥 − 𝑘𝑘𝑠𝑠 에서 �̅�𝑥 + 𝑘𝑘𝑠𝑠 사이의

구간에 포함,

k = 32

= 1.5이면 100 �1 − 1𝑘𝑘2� = 100 �1 − 4

9� = 55.56,

즉 55.56%보다 많은 데이터가 (�̅�𝑥 − 1.5𝑠𝑠, �̅�𝑥 + 1.5𝑠𝑠)에 존재함.

k=2 → 75% 보다 많은 데이터가 (�̅�𝑥 − 2𝑠𝑠, �̅�𝑥 + 2𝑠𝑠)에 존재함.

k=3 → 88.9% 보다 많은 데이터가 (�̅�𝑥 − 3𝑠𝑠, �̅�𝑥 + 3𝑠𝑠)에 존재함.

2.5 정규데이터 집합 Normal Data Sets

정규데이터집합: 종 모양의 대칭 구조를 이루는 데이터 집합 (정규히스토그램)

근사정규 데이터집합

오른쪽으로 긴 꼬리: “오른쪽으로 치우쳐 있다.” 라고 표현

왼쪽으로 긴 꼬리: “왼쪽으로 치우쳐 있다.” 라고 표현

그림 2.8 정규 데이터집합에 대한 히스토그램

Page 11: Chapter 2 Descriptive Statistics - cju.ac.krdelab.cju.ac.kr/ch2.pdf · 2019-03-05 · Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M

Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M. Ross

Chapter 2 Descriptive Statistics

Instructor – Sunghae Jun

11

그림 2.9 근사정규 데이터집합에 대한 히스토그램

(note) 정규데이터집합의 대칭성에 의해 그 표본평균과 표본중앙값은 거의 같게 된다.

[근사정규데이터집합의 경험적 규칙]

(1) 관찰된 데이터의 68%가 �̅�𝑥 ± 𝑠𝑠 범위에 포함된다.

(2) 관찰된 데이터의 95%가 �̅�𝑥 ± 2𝑠𝑠 범위에 포함된다.

(3) 관찰된 데이터의 99.7%가 �̅�𝑥 ± 3𝑠𝑠 범위에 포함된다.

Page 12: Chapter 2 Descriptive Statistics - cju.ac.krdelab.cju.ac.kr/ch2.pdf · 2019-03-05 · Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M

Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M. Ross

Chapter 2 Descriptive Statistics

Instructor – Sunghae Jun

12

2.6 쌍체 데이터집합과 표본상관계수 Paired Data Sets and The

Sample Correlation Coefficient

표 2.8 기온과 불량품 개수에 관한 데이터

날짜 기온 불량품 개수

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

24.2

22.7

30.5

28.6

25.5

32.0

28.6

26.5

25.3

26.0

24.4

24.8

20.6

25.1

21.4

23.7

23.9

25.2

27.4

28.3

28.8

26.6

25

31

36

33

19

24

27

25

16

14

22

23

20

25

25

23

27

30

33

32

35

24

Page 13: Chapter 2 Descriptive Statistics - cju.ac.krdelab.cju.ac.kr/ch2.pdf · 2019-03-05 · Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M

Introduction to Probability and Statistics for Engineers and Scientists, Fourth Edition, S. M. Ross

Chapter 2 Descriptive Statistics

Instructor – Sunghae Jun

13

산점도, 산포도 (scatter plot, scatter diagram)

temp=c(24.2,22.7,30.5,28.6,25.5,32.0,28.6,26.5,25.3,26.0,24.4,24.8,20.6,25.1,21.4,23.7,2

3.9,25.2,27.4,28.3,28.8,26.6)

defect=c(25,31,36,33,19,24,27,25,16,14,22,23,20,25,25,23,27,30,33,32,35,24)

plot(temp, defect)

[표본상관계수]

r =∑ (𝑥𝑥𝑖𝑖 − �̅�𝑥)(𝑦𝑦𝑖𝑖 − 𝑦𝑦�)𝑛𝑛𝑖𝑖=1

�∑ (𝑥𝑥𝑖𝑖 − �̅�𝑥)2𝑛𝑛𝑖𝑖=1 ∑ (𝑦𝑦𝑖𝑖 − 𝑦𝑦�)2𝑛𝑛

𝑖𝑖=1

-1 ≤ r ≤ 1

(예제 2.6b)

표 2.8에 주어진 데이터를 이용하여 표본상관계수를 구하여라.

cor(temp, defect)

[1] 0.418944

(note) 상관관계는 연관성을 측정하는 것이지 인과관계를 측정하는 것은 아니다.

22 24 26 28 30 32

1520

2530

35

temp

defe

ct