********************************************************************* NAME: STUDENTNAME (REPLACE WITH YOIR NAME). ********************************************************************* CPSC223FinalExam2024.txt Advanced Scientific Programming, Fall 2024 This assignment counts the same 20% for the semester as the preceding four programming assignments. It MUST BE IN VIA D2L BY THE DUE DATE OF WEDNESDAY DECEMBER 11 AT 11:59 PM. THERE WILL BE A 10-POINT DEDUCTION FOR EVERY CALENDAR DAY IT IS LATE AFTER THAT DUE DATE. I need to grades into MyKU on time. ANSWER THE "STUDENT" QUESTIONS BELOW WHERE INDICATED. Keep this take-home exam in a text file format, NOT a Word, PDF, or other format. An incorrect format costs 10 points. ********************************************************************* The study guide slides that I presented on November 25 are here: https://faculty.kutztown.edu/parson/fall2024/CPSC223_Take_home_final_exam.pptx The Zoom video recording of that presentation is here: https://kutztown.zoom.us/rec/share/CXoASg08pifG_oMMCy52OKoh0dLcScehi_arJ5vT7rygyXrgJW0FW0YXyQbO0tZy.32pEf9w_u5zViMLy You can find these ^^^ links on the course page. Our CPSC223 Final Exam slots, Zoom or in-person, are as follows: 3:00 PM class Wednesday the 11th 11:00-1:00 to work on take-home final exam. 4:30 PM class Wednesday the 11th 2:00-4:00 to work on take-home final exam. Attendance is optional. Please turn in the final exam via D2L by the deadline. I will NOT take questions about this exam itself. I will take questions about the study materials the week BEFORE finals. Each Question 1 through 10 below is worth 10 points of this assignment. ********************************************************************* Question 1 relates to the handout code for your Assignment 1. If you have deleted it, you can: unzip ~parson/Scripting/CSC223f24SORTassn1.problem.zip from your directory to inspect handout code in CSC223f24SORTassn1.py. Q1: Slide 30 of the above study slides states: "The purpose of seeding a pseudo-random generator is so that it produces the same sequence of values on each run. This repeatability is often used for testing, comparing program output to a previous run’s output. Seeding guarantees the same, repeatable sequences of values." However, CSC223f24SORTassn1.py does not seed its two pseudo-random generators: 24 bitsgen = random.Random() # No seed, different bits in radix each run. 25 numsgen = np.random.default_rng(seed=None) # Gen large range of nums to sort. and down in __main__: 119 radixbits = bitsgen.randint(1, 7) # [2**1, 2**7] range 120 unsorted = [math.ceil(abs(v)) for v in # 10000 is the median value 121 numsgen.exponential(scale=10000, size=__LISTSIZE__)] Given the fact that the bitsgen and numsgen generators will generate different radixbits and unsorted values every time, how does CSC223f24SORTassn1.py verify that your "ourRadixSort(unsorted, radixbits)" and "ourInsertionSort(unsorted)" functions return correctly sorted sequences of numbers? STUDENT ANSWER FOR Q1 GOES HERE, ADD LINES AS NEEDED: ********************************************************************* Question 2 relates to the handout code for your Assignment 2. If you have deleted it, you can: unzip ~parson/Scripting/CSC223f24WAVEassn2.problem.zip from your directory to inspect handout code in CSC223f24WAVEassn2.py. Q2: What does this function in CSC223f24WAVEassn2.py accomplish? Answer in specific terms. What range of values does it produce, and why does it produce this range of output values in returned variable normed? 86 def __normalize__(floatvalues, gain): 87 minvalue = (min(floatvalues)) 88 maxvalue = (max(floatvalues)) 89 range = (maxvalue - minvalue) 90 normed = [] 91 for cell in floatvalues: 92 newcell = (cell - minvalue) / range 93 newcell = int(newcell * 65535 - 32768) 94 newcell = int(gain * newcell) 95 newcell = max(newcell, -32767) 96 normed.append(np.int16(newcell)) 97 return normed STUDENT ANSWER FOR Q2 GOES HERE, ADD LINES AS NEEDED: ********************************************************************* Question 3 relates to the handout code for your Assignment 3. If you have deleted it, you can: unzip ~parson/Scripting/CSC223f24DeriveAssn3.problem.zip from your directory to inspect handout code in CSC223f24DeriveAssn3.py. Q3: What is the primary syntactic difference -- difference in form or appearance -- between how method (also know as "member function") VisitorClass.visit accesses fields inside the object during calls to visit, and how closure delta.deltaClosure accesses variables in the outer function delta during calls to deltaClosure? STUDENT ANSWER FOR Q3 GOES HERE, ADD LINES AS NEEDED: ********************************************************************* Question 4 relates to the handout code for your Assignment 4. BE CAREFUL NOT TO CLOBBER YOUR WORK-IN-PROGRESS IN DIRECTORY CSC223f24MeasureWaves4/. You can just use the copy of CSC223f24MeasureWaves4.py that you are working on instead of re-unzipping. If you have deleted it, you can: unzip ~parson/Scripting/CSC223f24MeasureWaves4_SafeCopy.zip from your directory to inspect handout code in CSC223f24MeasureWaves4.py in new directory CSC223f24MeasureWaves4_SafeCopy/. Q4: Each generator in CSC223f24MeasureWaves4.py PULLS data from its predecessor's "yield" statement in a loop like this: 229 def makeCSVoutput(predecessor, csvOutFile): 230 ''' 231 makeCSVoutput first writes __header__ to csvOutFile. 232 It then iterates over the 27-field attributes yielded by 233 its predecessor, writes them to csvOutFile, and yields them. 234 ''' 235 # PARSON-supplied code: 236 csvOutFile.writerow(__header__) 237 for datarow in predecessor: 238 csvOutFile.writerow(datarow) 239 yield datarow What problem would this approach to PULLing data from a predecessor generator present if a secobd generator or function like this makeCSVoutput was a peer to makeCSVoutput in the dataflow graph, meaning the peer is also PULLing data from the same predecessor generator object? If there is no possible problem, just answer with that. STUDENT ANSWER FOR Q4 GOES HERE, ADD LINES AS NEEDED: ********************************************************************* Examine Table 1 and Figure 1 in this Assignment's web page: https://faculty.kutztown.edu/parson/fall2024/CSC223Fall2024Final5.html Table 1 shows the PearsonR (pcc) and SpearmanR (scc) correlation coefficients between two waveforms from your Assignments 2 and 4. waveLeftWaveType pulse duplication factor 3 waveRightWaveType sine duplication factor 3 PearsonR for the waveform pair -0.489243 SpearmanR for the waveform pair -0.17092 Absolute value of their difference (abs(pcc-scc)) 0.318323 Q5: Which one of these two measures, PearsonR or SpearmanR, shows closer (tighter) correlation between the two waveforms? Explain the reasoning behind your answer. STUDENT ANSWER FOR Q5 GOES HERE, ADD LINES AS NEEDED: ********************************************************************* Examine Table 2 and Figure 2 in this Assignment's web page: https://faculty.kutztown.edu/parson/fall2024/CSC223Fall2024Final5.html Table 2 shows the PearsonR (pcc) and SpearmanR (scc) correlation coefficients between two waveforms from your Assignments 2 and 4. waveLeftWaveType triangle duplication factor 1 waveRightWaveType sine duplication factor 1 PearsonR for the waveform pair 0.992709 SpearmanR for the waveform pair 1 Absolute value of their difference (abs(pcc-scc)) 0.318323 Q6: Which one of these two measures, PearsonR or SpearmanR, shows closer (tighter) correlation between the two waveforms? Explain the reasoning behind your answer. STUDENT ANSWER FOR Q6 GOES HERE, ADD LINES AS NEEDED: ********************************************************************* Q7: Given these ipython statements: from sklearn.metrics import mean_absolute_error, root_mean_squared_error seq1 = [i for i in range(0,100,4)] seq2 = [i+7 for i in seq1] What values would these two function calls return? float(mean_absolute_error(seq1, seq2)) STUDENT ANSWER FOR Q7 mean_absolute_error GOES HERE: float(root_mean_squared_error(seq1, seq2)) STUDENT ANSWER FOR Q7 root_mean_squared_error GOES HERE: ********************************************************************* Q8: Given these ipython statements: from statistics import mean, median_low, median_high, median, mode, multimode seq3 = [i for i in range(1,6)] median(seq3) Out: 3 seq4 = [i for i in range(1,7)] What values would these three function calls return? STUDENT ANSWER FOR Q8 median GOES HERE: median(seq4) STUDENT ANSWER FOR Q8 median_low GOES HERE: median_low(seq4) STUDENT ANSWER FOR Q8 median_high GOES HERE: median_high(seq4) ********************************************************************* Q9: Given the import statement from Q8 and this ipython statement: seq5 = [i//4 for i in range(0,16)] # // is integer division. It drops any fraction. What values would these two function calls return? STUDENT ANSWER FOR Q9 mode GOES HERE: mode(seq5) STUDENT ANSWER FOR Q9 multimode GOES HERE: multimode(seq5) ********************************************************************* Q10: Given the import statement from Q8 and this ipython statement: seq6 = [i//4 for i in range(0,20)] What value would this function call return? STUDENT ANSWER FOR Q10 mean GOES HERE: mean(seq6) *********************************************************************