Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tutorial 2, Q1 solution The five scales: 1.Nominal scale serves only for classification. The order of the classes is unimportant as is the difference between.

Similar presentations


Presentation on theme: "Tutorial 2, Q1 solution The five scales: 1.Nominal scale serves only for classification. The order of the classes is unimportant as is the difference between."— Presentation transcript:

1 Tutorial 2, Q1 solution The five scales: 1.Nominal scale serves only for classification. The order of the classes is unimportant as is the difference between them. A renaming of classes is a valid transformation of scales. Example: blood types. 2.The Ordinal Scale is for classification where the order is important but the difference between classes is arbitrary. Any monotonic transformation is meaningful. Example: top ten whatevers. 3.Interval scale: order important and differences between classes meaningful. Any affine transformation (S' = kS + c) is meaningful, as in the conversion from C to F. Eg. temperature in Celsius (F = (9/5)*C + 32). 4.Ratio scale: as interval scale but also has meaningful zero. Any Linear transformation (S' = kS) is meaningful as in conversion of currencies. 5.The Absolute scale is just used for counting. Meaningful zero and differences between values. Only the identity transformation is valid. Eg. Lines of Code (given a particular definition of LoC).

2 Tutorial 2, Q1 solution “100 C is the boiling point of water" is a meaningful. Degrees C is an interval scale since each degree is equal but the zero is arbitrary. Transformation to Fahrenheit scale is example of an affine transformation which is valid for interval scales. “Today is twice as hot as yesterday" is unlikely to be meaningful as weather temperature is measured in C or F which are not ratio scales (which would be required for “twice" to be meaningful). Differences are meaningful however, so if today is 10 degrees C, and yesterday was 5 degrees C, then it would be meaningful to say that today is 5 degrees hotter than yesterday. The FT index is an example of an indirect measure (calculated from the value of lots of different shares). The calculation is made such that the resulting value is on a ratio scale. The zero is meaningful (the shares have value) and the differences are equal. Depending on its precise definition, Line of Code is probably an absolute scale so the sentence is meaningful. Transformations which convert between lines of code measures for different languages may be empirically substantiated but are not valid for an absolute scale. Elapsed time is a ratio scale made by subtracting two points in time. Points in time are measured on interval scale (eg. 3/10/2002 10:11:30). Transformations of elapsed time such as 1 month = 20 working days are valid for elapsed time (ratio scale). But (31 Jan 1997) = 31 * (1st Jan 1997) is not valid since date is an interval scale. Cost is a ratio scale. Assuming we are talking about something like cost of maintenance per year, then the sentence is meaningful. Complexity however defined is likely to be at least an ordinal scale so the sentence is OK.

3 Tutorial 2 Q2 Solution Check the notes for week two. There are lots of problems with the Lines of Code LoC measure: Do blank lines count? What about comments? Compiler directives? Declarations? Procedure headings? Imports, exports? What about side effects in expressions – you can get lots of effects in a single expression, for example in Java you can write X = i++,j++,k++,--p,t=t*4 ; This assigns to X, but has also 5 side effects.

4 Control Flowgraphs Conditional Atomic Loop Sequence Start or Stop node

5 Tutorial 2, Q3 solution IF(...)THEN x:=1 ELSE x:=2 FI ; y:=50 ; IF (...) THEN z:=1 ELSE DO WHILE (...) z:=z+1 OD FI ; y:=0 S C A S A S A A C AL A Draw the CFG:

6 Tutorial 2, Q3 solution To calculate number of nodes: M(S(C(A,A),S(A,S(C(A,L(A)),A)))) = M(C(A,A))+M(S(A,S(C(A,L(A)),A)))-1 = M(A) +M(A) + M(A) +M(S(C(A,L(A)),A)) -1 -1 = 2 + 2 + 2 + M(C(A,L(A))) + M(A) -1 -1 -1 = 2 + 2 + 2 + M(A) + M(L(A)) +2 -1 -1 -1 = 2 + 2 + 2 + 2 + M(A) +1 +2 -1 -1 -1 = 2 + 2 + 2 + 2 + 2 +1 +2 -1 -1 -1 = 10 For number of edges: M(S(C(A,A),S(A,S(C(A,L(A)),A)))) = M(C(A,A)) + M(S(A,S(C(A,L(A)),A))) = M(A) + M(A) + 2 + M(A) + M(S(C(A,L(A)),A)) = 1 + 1 + 2 + 1 + M(C(A,L(A))) + M(A) = 1 + 1 + 2 + 1 + M(A) + M(L(A)) + 2 + 1 = 1 + 1 + 2 + 1 + 1 + M(A) + 2 + 2 + 1 = 1 + 1 + 2 + 1 + 1 + 1 + 2 + 2 + 1 = 12 S C A S A S A A C AL A 2 2 2 2 2 5 2 6 3 7 4 10 1 1 1 6 7 1 8 11 4 12 3

7 Another (simpler) way Number of Nodes: FA() = 2 Fs(m1,m2) = m1 + m2 - 1 FC(m1,m2) = m1 + m2 FL(m1) = m1 + 1 S C A S A S A A C AL A 2 2 2 2 2 5 2 6 3 7 4 10 1 1 1 6 7 1 8 11 4 12 3 6 As + 3 Ss + 2 Cs + 1 L6 * 2 + 3 *-1 + 2 *0 + 1 * 1


Download ppt "Tutorial 2, Q1 solution The five scales: 1.Nominal scale serves only for classification. The order of the classes is unimportant as is the difference between."

Similar presentations


Ads by Google