Merge Sort Analysis Worst-case time complexity for applying the merge function to a size-k subarray: M(k) = 18k-7. template template Etype> void merge(Etype source[], void merge(Etype source[], Etype Etype dest[], dest[], int int lower, lower, int int middle, middle, int int upper) upper) { int int s1 s1 = = lower; lower; int // int s2 s2 = = middle middle + + 1; 1; // 1 1 TU TU int int d d = = lower; lower; do do { if if (source[s1] (source[s1] < < source[s2]) source[s2]) // // If If block: block: { // 14 { // 14 TU TU dest[d] dest[d] = = source[s1]; source[s1]; s1++; s1++; } else else { { dest[d] dest[d] = = source[s2]; source[s2]; s2++; s2++; } d++; // d++; // 1 1 TU TU } while ((s1 <= middle) && // } while ((s1 <= middle) && // k-m k-m iter. iter. (s2 // @ (s2 <= <= upper)); upper)); // @ 3 3 TU TU } } if (s1 > middle) do do { { dest[d] dest[d] = = source[s2]; source[s2]; s2++; s2++; d++; } } while while (s2 (s2 <= <= upper); upper); else else do do { { dest[d] = source[s1]; s1++; s1++; d++; d++; } } while while (s1 (s1 <= <= middle); middle); CS 340 // 1 TU // // // // // // // 6 6 1 1 1 m m TU TU TU TU TU iter. iter. @ @ 1 1 TU TU Time complexity for applying the order function to a size-k subarray: R(k), where R(1)=1 and R(k) = 5+M(k)+2R(k/2) = 18k-2+2R(k/2). This recurrence relation yields R(k) = 18klogk-logk+2. template template void order(Etype source[], Etype dest[], int lower, int upper) { int middle; if (lower != upper) { middle = (lower + upper) / 2; order(dest, source, lower, middle); order(dest, source, middle + 1, upper); merge(source, dest, lower, middle, upper); } } // 1 TU // // // // 3 TU R(k/2) TU R(k/2)+1 TU M(k) TU Time complexity for applying the mergesort function to a sizen subarray: T(n) = 8n+1+R(n) = 18nlogn+8n-logn+3. template void mergeSort(Etype A[], const int n) { Etype Acopy[n+1]; // 1 TU int size; for (int k = 1; k <= n; k++) // n iter. @ 2 TU Acopy[k] = A[k]; // 6 TU order(Acopy, A, 1, size); // R(n) TU } While While this this O(nlogn) O(nlogn) time time complexity complexity is is favorable, favorable, the the requirement requirement of of aa duplicate duplicate array array is is detrimental detrimental to to the the Merge Merge Sort Sort algorithm, algorithm, possibly possibly making making it it less less popular popular than certain alternative choices. than certain alternative choices. Page 16
Jagged arrays Implemented as arrays of arrays , 4 index type index lower bound index upper bound address address , 3 , 3 index type index type index lower bound index lower bound index upper bound index upper bound address address , 7 , 7 index type index type index lower bound index lower bound index upper bound index upper bound address address , 4 , 4 index type index type index lower bound index lower bound index upper bound index upper bound address address , 5 , 5 index type index type index lower bound index lower bound index upper bound index upper bound address address 24
Excel Methods to Create Frequency Distribution • COUNTIFS Excel function with two criteria • Count between the lower and upper limit • Because you have control over the comparative operators, you can create any type of Upper and Lower Limit. • This is different than with the PivotTable Grouping feature and the FREQUENCY Array Function. • PivotTables and the Grouping feature • When Grouping in a PivotTable: • Integer data yields unambiguous labels • Decimal data yields ambiguous labels • Remember: when you are counting between an upper and lower limit, the Upper Limit is NOT included and the Lower Limit IS included; unlike formulas we do not have control over how the upper and lower limits work when grouping. • FREQUENCY Array Function: • Next slide has full details about this function • One note here: For FRQUENCY Array Formula when you are counting between an upper and lower limit, the Upper Limit IS included and the Lower Limit is NOT included; unlike formulas we do not have control over how the upper and lower limits work when grouping. • FREQUENCY Array Function and Data Analysis Tools, Histogram yield the same answer. • Data Analysis Tools, Histogram • You must add this feature in: File tab, Options, Add-ins, Manage: Excel Ass-ins, Click Go, Check box for Analysis Toolpak, Click OK • This feature will create the Frequency Table (just like the FREQUENCY Array Function), a Histogram and a Cumulative Distribution. If Gap Width in Chart is not zero, you must change it!! • FREQUENCY Array Function and Data Analysis Tools, Histogram yield the same answer. 33
Step 1: Matrix Multiplication A Simple Host Version in C // Matrix multiplication on the (CPU) host in double precision 44 WIDTH N WIDTH k P WIDTH void MatrixMulOnHost(float* M, float* N, float* P, int WIDTH) { int i, j, k; double a, b, sum; j for (i = 0; i < WIDTH; ++i) for (j = 0; j < WIDTH; ++j) { sum = 0; for (k = 0; k < WIDTH; ++k) { a = M[i * WIDTH + k]; M b = N[k * WIDTH + j]; sum += a * b; i } P[i * WIDTH + j] = sum; } } k WIDTH
TABLE SIZE • • • Initially, a table’s width is determined by the width of its columns whose width is determined by the width of the cells within the column whose width is determined by the widest item in each column – This is very flexible but may give your table an unbalanced look – You can control this width by setting the table’s width combined with setting the column (cell) width. You can control the total width of the table using a style within the table tag – width:value; – Value is normally designated as a percentage (e.g. 80%) or in pixels (px) • If you use pixels, the table will always be the same size regardless of the window size. Percent will scale to window size – NOTE: the width= and height= attributes (not in a style) are deprecated. Table height is rarely specified. Table height is normally, automatically based on the number of rows in the table and height of those rows.
Readback of Error Count CDL Readback of ERROR_COUNT Block: RCA 0x1000, FC 5 COUNT DESCRIPTION LIMIT 0 No Known cause 1 Temperature Greater than Upper Limit Error. > 50.0 C. 2 28V Voltage Lower Limit Error. < 27.0 V. 3 28V Voltage Upper Limit Error. > 29.0 V. 4 Rectifier High Voltage Error. 5 Rectifier Low Voltage Error. 6 1.8V Voltage Upper Limit Error. > 2.2 V. 7 3.3V Voltage Upper Limit Error. > 3.6 V. 8 5.0V Voltage Upper Limit Error. > 5.5 V. 9 Rectifier Over Temperature Alert. 10 1.8V Current Upper Limit Error. > 60.0 A. 11 9UBPS 3.3V Current Upper Limit Error. > 50.0 A. 12 5.0V Current Upper Limit Error. > 3.0 A. 13 QCC V1.8 Lower Limit Error. < 1.6 V. 14 QCC V3.3 Lower Limit Error. < 3.0 V. 15 QCC V5.0 Lower Limit Error. < 4.5 V. 16 QCC V1.8 Upper Limit Error. > 2.2 V. 17 QCC V3.3 Upper Limit Error. > 3.6 V. ALMA Correlator Workshop, May 2016 11
Avoid Inference About Standard Deviations* There are methods for inference about the standard deviations of Normal populations. The most common such method is the “F test” for comparing the standard deviations of two Normal populations. Unlike the t procedures for means, the F test for standard deviations is extremely sensitive to nonNormal distributions. We do not recommend trying to do inference about population standard deviations in basic statistical practice.