25
1 1 Summarizing Measured Data CS 700 2 Acknowledgement These slides are based on presentations created and copyrighted by Prof. Daniel Menasce (GMU)

Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

1

1

Summarizing Measured Data

CS 700

2

Acknowledgement

These slides are based onpresentations created and

copyrighted by Prof. Daniel Menasce(GMU)

Page 2: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

2

3

Types of Data

Qualitative (also called categorical) Data has states, categories, or levels that are

mutually exclusive and exhaustive• E.g. computers can be classified as laptops,

handheld (PDAs), desktops, servers

Categories can be ordered or unordered

Quantitative (also called numerical) Discrete variables Continuous variables

4

Major Properties of Numerical Data Central Tendency: arithmetic mean,

geometric mean, harmonic mean, median,mode.

Variability: range, inter-quartile range,variance, standard deviation, coefficient ofvariation, mean absolute deviation

Distribution: type of distribution

Page 3: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

3

5

Measures of Central Tendency

Arithmetic Mean

Based on all observations greatlyaffected by extreme values.

n

X

X

n

ii∑

== 1

6

Effect of Outliers on Average

1.1 1.11.4 1.41.8 1.81.9 1.92.3 2.32.4 2.42.8 2.83.1 3.13.4 3.43.8 3.810.3 3.5

Average 3.1 2.5

Page 4: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

4

7

Median Middle Value in an Ordered Set of Data. If there are no ties, 50% of the values are

smaller than the median and 50% are larger.1.1 1.11.4 1.41.8 1.81.9 1.92.3 2.32.4 2.42.8 2.83.1 3.13.4 3.43.8 3.810.3 3.5

Median 2.4 2.4

8

Median

The median is unaffected by extreme values. Obtaining the median:

Odd-sized samples:

Even-sized samples:

2/)1( +nX

21)2/(2/ ++ nn XX

Page 5: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

5

9

Mode

Most frequently occurring value. Mode may not exist. Single mode distributions: unimodal. Distributions with two modes: bimodal.

unimodal bimodal

10

Selecting between the mean, mode, andmedian

Categorical data Use mode

Numerical data If the total of all observations is meaningful,

use mean• E.g. total execution time for five different

queries

If total not of interest, select median ifdistribution is skewed, o/w select mean

Page 6: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

6

11

Geometric Mean

Geometric Mean:

Used when the product of the observations is ofinterest.

Important when multiplicative effects are at play: Cache hit ratios at several levels of cache Percentage performance improvements between

successive versions. Performance improvements across protocol layers.

nn

iiX

/1

1

∏=

12

Example of Geometric Mean

Test NumberOperating System Middleware Application

Avg. Performance Improvement

per Layer

1 1.18 1.23 1.10 1.172 1.25 1.19 1.25 1.233 1.20 1.12 1.20 1.174 1.21 1.18 1.12 1.175 1.30 1.23 1.15 1.236 1.24 1.17 1.21 1.217 1.22 1.18 1.14 1.188 1.29 1.19 1.13 1.209 1.30 1.21 1.15 1.22

10 1.22 1.15 1.18 1.18 Average Performance Improvement per Layer 1.20

Performance Improvement

Page 7: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

7

13

Harmonic Mean

The harmonic mean of a sample {x1, x2, …,xn} isdefined as

Weighted harmonic mean

where wi’s are weights that add up to 1 A harmonic mean or weighted harmonic mean should

be used whenever an arithmetic mean can be justifiedfor 1/xi (or wi/xi)

˙ ̇ x = n1/ x1 +1/ x2 +L+1/ xn

˙ ̇ x = 1w1 / x1 + w2 / x2 +L+ wn / xn

14

Selecting between arithmetic,geometric and harmonic means

Controversy (in late 1980s) over which mean to useto characterize the results of benchmarksconsisting of a suite of programs See link to article on class home page

Basic idea: should be guided by physicalinterpretation of number produced by benchmark Can be confusing if benchmark reports a ratio of two

numbers, e.g. floating pt operations and execution time

Page 8: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

8

15

Selecting between means (cont’d)

If number produced by individual programs in thebenchmark is proportional to execution time, thenarithmetic mean makes sense to characterize thebenchmark suite

If the inverse of the number produced byindividual benchmarks has a physicalinterpretation, then harmonic mean is appropriatefor characterizing the performance of thebenchmark suite E.g. if benchmark reports MFLOPs rating of a program,

i.e. number of floating pt ops divided by execution time

16

Summarizing variability

Indices of dispersion Range Variance or standard deviation 10- and 90- percentiles Semi-interquartile range Mean absolute deviation

Page 9: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

9

17

Range, Variance, and Standard Deviation

Range: Variance:

Standard Deviation:

minmax XX −

1

)(1

2

2

=∑=n

XX

s

n

ii

( )

11

2

=∑=n

XX

s

n

ii

In Excel:s=STDEV(<array>)

In Excel:s2=VAR(<array>)

18

Meanings of the Variance and StandardDeviation The larger the spread of the data around the

mean, the larger the variance and standarddeviation.

If all observations are the same, the variance andstandard deviation are zero.

The variance and standard deviation cannot benegative.

Variance is measured in the square of the units ofthe data.

Standard deviation is measured in the same unitsas the data.

Page 10: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

10

19

Coefficient of Variation Coefficient of variation (COV) :

no unitsXs /

1.05 S 29.501.06 Average 9.511.09 COV 3.101.191.211.281.341.341.771.801.832.152.212.272.612.672.772.833.513.775.765.7832.07144.91

COV not very meaningful if the random variable has anegative or zero mean

20

Quantiles (quartiles, percentiles) and midhinge

Quartiles: split the data into quarters. First quartile (Q1): value of Xi such that 25% of the

observations are smaller than Xi. Second quartile (Q2): value of Xi such that 50% of the

observations are smaller than Xi. Third quartile (Q3): value of Xi such that 75% of the

observations are smaller than Xi.

Percentiles: split the data into hundredths. Midhinge:

213 QQ

Midhinge+

=

Page 11: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

11

21

Example of Quartiles1.05 Q1 1.321.06 Q2 2.181.09 Q3 3.001.19 Midhinge 2.161.211.281.341.341.771.801.832.152.212.272.612.672.772.833.513.775.765.7832.07144.91

In Excel:Q1=PERCENTILE(<array>,0.25)Q2=PERCENTILE(<array>,0.5)Q3=PERCENTILE(<array>,0.75)

22

Example of Percentile1.05 80-percentile 3.6130021.061.091.191.211.281.341.341.771.801.832.152.212.272.612.672.772.833.513.775.765.7832.07144.91

In Excel:p-th percentile=PERCENTILE(<array>,p) (0≤p≤1)

Page 12: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

12

23

Interquartile Range

Interquartile Range: not affected by extreme values.

Semi-Interquartile Range (SIQR)SIQR = (Q3- Q1)/2

If the distribution is highly skewed, SIQRis preferred to the standard deviation forthe same reason that median is preferredto mean

13 QQ −

24

Coefficient of Skewness

Coefficient of skewness: 3

13

)(1∑=

−n

ii XX

ns(X-Xi)^3

1.05 -606.11.06 -602.91.09 -596.11.19 -575.21.21 -571.81.28 -557.91.34 -546.41.34 -544.81.77 -464.51.80 -458.11.83 -453.12.15 -398.92.21 -388.82.27 -379.02.61 -328.52.67 -320.52.77 -306.62.83 -298.73.51 -215.93.77 -189.65.76 -52.95.78 -52.132.07 11476.6144.91 2482007.1

4.033

Page 13: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

13

25

Mean Absolute Deviation Mean absolute deviation: ∑

=

−n

ii XX

n 1

1

abs(Xi-Xbar)1.05 8.46 Average 9.511.06 8.45 Mean absolute deviation 13.161.09 8.421.19 8.321.21 8.301.28 8.231.34 8.181.34 8.171.77 7.741.80 7.711.83 7.682.15 7.362.21 7.302.27 7.242.61 6.902.67 6.842.77 6.742.83 6.683.51 6.003.77 5.745.76 3.755.78 3.73

32.07 22.56144.91 135.39

315.90

26

Shapes of Distributions

mode

mode

Mode, median, mean

median

medianmean

Symmetric distribution

Left-skewed distribution

Right-skewed distributionmean

Page 14: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

14

27

Selecting the index of dispersion

Numerical data If the distribution is bounded, use the range For unbounded distributions that are unimodal

and symmetric, use C.O.V. O/w use percentiles or SIQR

28

Box-and-Whisker Plot Graphical representation of data through a

five-number summary.I/O Time (msec)

8.049.965.686.958.8110.844.264.828.337.587.247.468.845.736.777.118.155.396.427.8112.746.08

Five-number SummaryMinimum 4.26First Quartile 6.08Median 7.35Third Quartile 8.33Maximum 12.74

4.26

6.087.358.33

12.74

50% of the datalies in the box

Page 15: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

15

29

Determining the Distributions of a Data Set

A measured data set can be summarized by statingits average and variability

If we can say something about the distribution ofthe data, that would provide all the informationabout the data Distribution information is required if the summarized

mean and variability have to be used in simulations oranalytical models

To determine the distribution of a data set, wecompare the data set to a theoretical distribution Heuristic techniques Graphical/Visual): Histograms, Q-Q

plots Statistical goodness-of-fit tests: Chi-square test,

Kolmogrov-Smirnov test

30

Comparing Data Sets

Problem: given two data sets D1 and D2 determineif the data points come from the samedistribution.

Simple approach: draw a histogram for each dataset and visually compare them.

To study relationships between two variables use ascatter plot.

To compare two distributions use a quantile-quantile (Q-Q) plot.

Page 16: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

16

31

Histogram

Divide the range (max value – min value) into equal-sized cells or bins.

Count the number of data points that fall in eachcell.

Plot on the y-axis the relative frequency, i.e.,number of point in each cell divided by the totalnumber of points and the cells on the x-axis.

Cell size is critical! Sturge’s rule of thumb

Given n data points, number of bins

k = 1+ log2 n

32

HistogramData-3.00.81.21.52.02.32.43.33.54.04.55.5

Bin FrequencyRelative Frequency

<=0 1 8.3%0<x<= 1 1 8.3%1<x<=2 3 25.0%2<x<=3 2 16.7%3<x<=4 3 25.0%4<x<=5 1 8.3%>5 1 8.3%

8.3% 8.3%

25.0%

16.7%

25.0%

8.3% 8.3%

0.0%

5.0%

10.0%

15.0%

20.0%

25.0%

30.0%

<=0 0<x<= 1 1<x<=2 2<x<=3 3<x<=4 4<x<=5 >5

In Excel:Tools -> Data Analysis -> Histogram

Page 17: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

17

33

HistogramData-3.00.81.21.52.02.32.43.33.54.04.55.5

Bin FrequencyRelative Frequency

<=0 1 8.3%0<x<= 0.5 0 0.0%0.5<x<=1 1 8.3%1<x<=1.5 2 16.7%1.5<x<=2 1 8.3%2<x<=2.5 2 16.7%2.5<x<=3 0 0.0%3<x<=3.5 2 16.7%3.5<x<=4 1 8.3%4<x<=4.5 1 8.3%4.5<x<=5 0 0.0%>5 1 8.3%

8.3%

0.0%

8.3%

16.7%

8.3%

16.7%

0.0%

16.7%

8.3% 8.3%

0.0%

8.3%

0.0%

2.0%4.0%

6.0%8.0%

10.0%12.0%

14.0%16.0%

18.0%

<=0

0<x<

= 0.

5

0.5<

x<=1

1<x<

=1.5

1.5<

x<=2

2<x<

=2.5

2.5<

x<=3

3<x<

=3.5

3.5<

x<=4

4<x<

=4.5

4.5<

x<=5 >5

Same data, different cell size,different shape for the histograms!

34

Scatter Plot

Plot a data set against each other tovisualize potential relationships betweenthe data sets.

Example: CPU time vs. I/O Time In Excel: XY (Scatter) Chart Type.

Page 18: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

18

35

Scatter PlotCPU Time (sec) I/O Time (sec)

0.020 0.0430.150 1.5160.500 1.0370.023 0.1410.160 1.6350.450 0.9000.170 1.7440.550 1.1320.018 0.0370.600 1.2290.145 1.4790.530 1.1020.021 0.0940.480 1.0190.155 1.5630.560 1.1710.018 0.1310.600 1.2360.167 1.7030.025 0.103

0.00.20.40.60.81.0

1.21.41.61.82.0

0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7

CPU time (sec)

I/O

tim

e (s

ec)

36

Plots Based on Quantiles

Consider an ordered data set with n valuesx1, …, xn.

If p = (i-0.5)/n for i ≤n, then the p quantileQ(p) of the data set is defined as

Q(p)= Q([i-0.5]/n)=xi

Q(p) for other values of p is computed bylinear interpolation.

A quantile plot is a plot of Q(p) vs. p.

Page 19: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

19

37

Example of a Quantile Ploti p=(i-0.5)/n xi = Q(p)

1 0.05 10.52 0.15 24.03 0.25 28.04 0.35 29.05 0.45 34.06 0.55 36.57 0.65 40.38 0.75 44.59 0.85 50.310 0.95 55.3

0.0

10.0

20.0

30.0

40.0

50.0

60.0

0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95

p

Q(p)

38

Quantile-Quantile (Q-Q plots)

Used to compare distributions. “Equal shape” is equivalent to “linearly

related quantile functions.” A Q-Q plot is a plot of the type

(Q1(p),Q2(p)) where Q1(p) is the quantilefunction of data set 1 and Q2(p) is thequantile function of data set 2. The valuesof p are (i-0.5)/n where n is the size of thesmaller data set.

Page 20: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

20

39

Q-Q Plot Examplei p=(i-0.5)/n Data 1 Data 2

1 0.033 0.2861 0.56402 0.100 0.3056 0.86573 0.167 0.5315 0.91204 0.233 0.5465 1.05395 0.300 0.5584 1.17296 0.367 0.7613 1.27537 0.433 0.8251 1.30338 0.500 0.9014 1.31029 0.567 0.9740 1.6678

10 0.633 1.0436 1.712611 0.700 1.1250 1.928912 0.767 1.1437 1.949513 0.833 1.4778 2.184514 0.900 1.8377 2.362315 0.967 2.1074 2.6104

y = 1.0957x + 0.4712

R2 = 0.9416

0.0

0.5

1.0

1.5

2.0

2.5

3.0

0.0 0.5 1.0 1.5 2.0 2.5

Q1(p)

Q2(p)

A Q-Q plot that is reasonably linear indicates that the two data setshave distributions with similar shapes.

40

Theoretical Q-Q Plot

Compare one empirical data set with atheoretical distribution.

Plot (xi, Q2([i-0.5]/n)) where xi is the[i-0.5]/n quantile of a theoreticaldistribution (F-1([i-0.5]/n)) and Q2([i-0.5]/n) is the i-th ordered data point.

If the Q-Q plot is reasonably linear thedata set is distributed as the theoreticaldistribution.

Page 21: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

21

41

Examples of CDFs and Their InverseFunctions

−−−=

−−=

−−−=

)1Ln(

)(Ln)1(1)(

)1(

11)(

)1(Ln1)(

/1

/

p

upxF

uxxF

uaexF

x

aa

axExponential

Pareto

Geometric

42

Example of a Quantile-QuantilePlot

One thousand values are suspected ofcoming from an exponential distribution(see histogram in the next slide). Thequantile-quantile plot is pretty much linear,which confirms the conjecture.

Page 22: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

22

43

Histogram

0.00

0.05

0.10

0.15

0.20

0.25

0.30

0.35

0.40

0.45

1 3 5 7 9 11 13 15 17 19

Bin

Frequency

44

Data for Quantile-Quantile Plot

qi yi xi0.100 0.22 0.210.200 0.49 0.450.300 0.74 0.710.400 1.03 1.020.500 1.41 1.390.600 1.84 1.830.700 2.49 2.410.800 3.26 3.220.900 4.31 4.610.930 4.98 5.320.950 5.49 5.990.970 6.53 7.010.980 7.84 7.820.985 8.12 8.400.990 8.82 9.211.000 17.91 18.42

Page 23: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

23

45

y = 0.9642x + 0.016

R2 = 0.9988

0

2

4

6

8

10

12

14

16

18

20

0 2 4 6 8 10 12 14 16 18 20

Theoretical Percentiles

Ob

serv

ed P

erce

nti

les

46

What if the Inverse of the CDF Cannotbe Found?

Use approximations or use statisticaltables Quantile tables have been computed and

published for many important distributions

For example, approximation for N(0,1):

For N(µ,σ) the xi values are scaled as])1([91.4 14.014.0

iii qqx −−=

ixσµ +

before plotting.

Page 24: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

24

47

y = 1.0505x + 0.0301

R2 = 0.9978

-2

-1

0

1

2

3

4

5

-2.0 -1.0 0.0 1.0 2.0 3.0 4.0

Theoretical Quantile

Ob

serv

ed Q

uan

tile

intercept: meanslope: standard deviation

48

Normal Probability Plot

-4

-3

-2

-1

0

1

2

3

4

5

-4 -3 -2 -1 0 1 2 3 4

Z Value

Dat

a

longer tails than normal

Page 25: Acknowledgement - George Mason Universitysetia/cs700-S06/slides/lecture2.pdf2 3 Types of Data Qualitative (also called categorical) Data has states, categories, or levels that are

25

49

Normal Probability Plot

-4

-3

-2

-1

0

1

2

3

4

5

-4 -3 -2 -1 0 1 2 3 4

Z Value

Dat

a

shorter tails than normal

50

Normal Probability Plot

-4

-3

-2

-1

0

1

2

3

4

5

-4 -3 -2 -1 0 1 2 3 4

Z Value

Dat

a

asymmetric