CS251 AVL Tree Requirement Implement a C++ AVL Tree class AVLTree in files AVLTree.h and AVLTree.cpp 1. The constructor AVLTree () builds the AVLTree. 2. The destructor ~AVLTree() deallocates all dynamically allocated memory. 3. The void insert(int k) method inserts the key k into the AVLTree, and does not do anything if the key is already stored. 4. The void remove(int k) method removes key k from the AVLTree and does not do anything if AVLTree does not contain key k. 5. The items stored are positive integers which serve both as keys and as elements. 6. The void printInorder() method prints the tree to the standard output using an inorder traversal; it prints a (key, height) pair for each node and ends with a newline. 7. The void printPostorder() method prints the tree to the standard output using postorder traversal; it prints a (key, height) pair for each node and ends with a newline.
Final Exam Information and Study Guide Fall 2025 The final exam is on Wednesday, December 17 from 9:00-11:00 AM. All students will begin writing at the same time. To access the exam, go to the “Tests & Quizzes” tab on our OWL course site. For students who are registered with the ACSD office and have exam accommodations, these will be automatically added to the exam. You will have 120 minutes to complete the exam. The format of the final exam is multiple-choice questions and long answer questions. Once you begin the exam, you must finish it. You will only have one attempt to challenge the exam. Please make sure you do not have any distractions or interruptions. The exam has 100 possible points. As noted above there are two parts to the exam. Part I consists of 60 multiple-choice questions (60 marks). Part II consists of long answer style questions related to the course material. There are four questions. Each is worth 10 marks (40 marks total). The exam is not cumulative. You are responsible for Modules 6-11 only. This includes course notes, assigned readings, required course videos, important tutorial discussions etc. You are not required to memorize the stats from our class survey in Module 11. You must not use AI, ChatGPT, online translators, textbooks, lecture materials, study notes, online searches, or our course site for this midterm. All work must be your own. You may not collaborate with others. You may not make a copy of the exam. Students who do not adhere to these rules will receive a zero grade. On a personal note, do not be tempted to cheat; it is not worth the compromise of your integrity and value. Some things that might be helpful to know … Popular Culture and Death • Know how popular culture portrays death in various genres (types of movies, cartoons, superhero stories, horror films, music etc.). • Know what the concept of abject represents and be able to identify its presence in specific forms of media. Facing Death / End-of-Life Care • Be able to identify the various awareness contexts of dying (Glaser & Strauss). • Be familiar with the various ways that people experience the dying process. • Be familiar with illness trajectories. • Know the definitions of palliative and hospice care and what they entail. Non-Death Loss and Grief • Know what comprises the assumptive world. • Know the following: non-finite loss, ambiguous loss, chronic sorrow, tangible loss, intangible loss. Helping Bereaved Individuals • Be familiar with the various ways that grief can manifest. • Be able to identify some of the current thinking about grief. • Be familiar with the typical social messages that bereaved individuals encounter. • Know the difference between instrumental versus intuitive grievers. • Know what is meant by the term, disenfranchised grief. • Understand what is most helpful for bereaved individuals? • Be able to identify the contributions made by professionals in the field of thanatology. Funerals and Funeral Planning • Know the various purposes a funeral serves. • Know the things necessary that must be done after the death of someone. • Know the various options available for disposition of the body that were discussed in the lecture materials. Animal Companion Loss and Course Conclusion • Know the key aspects of animal companion loss and grief. • Understand the relationship/bonds between humans and animal companions. • Be familiar with post-modern theories as they relate to animal companion loss.
SOCS0055 Advanced Computational Techniques for Data Science Summative Assessment 100% - Autumn Term 2025-2026 1. There are four tasks in this assessment that add up to 100 marks 2. There is no word limit. We advise to write concise, short, focused answers; otherwise, you may run out of time 3. To achieve full marks, no additional references/bibliography are required or expected. However, if you use them, list them at the end of the assessment following an accepted referencing style (check these UCL guidelines) 4. AI can be used as an assistive tool. However, it is not permitted to generate any part of your exam. Use of AI needs to be acknowledged at the end of the exam. 5. The assessment is split into two parts, A and B. For Part A, students must create their own wrangled version of the UKHLS dataset. For Part B, a cleaned version of the dataset is provided. a. Instructions to download the full USoc data from the UK Data Service are provided in an Appendix. Note, these instructions will download data for both USoc and its predecessor, the British Household Panel Survey (BHPS), but we only want you to use USoc data in this assessment. b. For Part B, a cleaned version of the dataset is provided on the moodle asssesment section. The specific outputs required differ between Part A and B. You must submit: • Coversheet.docx Part A • “partA_task1.qmd” (Quarto file containing code) • “partA_task2.qmd” (Quarto file containing code) • “partA_task2_table.html” (Output table as a HTML) • “partA_task3.qmd” (Quarto file containing code) Part B • “partB_task4.html” (html file with your explanation, your code and your output) • “partB_task4.qmd” (Quarto file of your task) The individual Quarto files needs to be self-contained and must be capable of running in full, from scratch in a new, ‘clean’ session (i.e., from loading packages and data to performing analyses). The code should also be well formatted with comments, sections, sensible variable names, and so on. Your final submission must be a zip folder containing the above files and everything necessary to run the code (except the data, which your examiners will have access to already). Please name this file: “ [CandidateNumber].zip” where you replace [CandidateNumber] with your anonymous candidate number (not your student id). You can use the course materials as an example. Part A Task 1 (25% of Marks) Create a “long” dataset with one row per pidp x wave combination from all of the adult interview (*_indresp.dta) files. The dataset should have rows only for those participants who appeared in the a_indresp.dta file (i.e., completed an adult interview in Wave 1 of USoc). The dataset should have cleaned versions of current smoking status (binary, derived from *_smever and *_smnow), obesity (binary, BMI ≥ 30 kg/m2, derived from *_bmi_dv), SF- 12 mental and physical component summary scores (*_sf12pcs_dv and *_sf12mcs_dv), overall life satisfaction, age at interview (*_age_dv), date of interview (month-year), sex (*_sex_dv), whether the participant has a degree or above level education (binary, derived from *_hiqual_dv), and employment status (binary, derived from *_jbhas and *_jboff). Include a step to save the cleaned dataset as using the saveRDS() function — you will need to load and use this dataset in Tasks 2 and 3. Most of the stubs of the variables that should be used to create these variables are provided above, but for overall life satisfaction and date of interview, you are required to find relevant variables yourself. Note, some of the variables are only available in some waves but not all. See this website for a helpful tool which provides variable names and waves of collection. You can alternatively use the labelled::lookfor() function. All that is required for this question is the code used to complete this task, provided in a Quarto (.qmd) document. Marks will be awarded to students who reduce the amount of code written to complete this task, compared with writing out all instructions manually (e.g., using functions called repeatedly or combining data to clean variables in one fell swoop), and to students who include helpful comments explaining their code. Task 2 (10% of marks) Load the dataset from Task 1 and create a ‘Table 1 ’ which shows descriptive statistics for each variable in the dataset. This table should report statistics separated by study wave (i.e., in separate columns). For categorical variables, report sample sizes and proportions (as % of non- missing) in each category. For continuous variables, report mean and standard deviation. Format the table so that variable names are descriptive and human interpretable rather than repeating the R column names. Also remove any variables that are not helpful to report. Save the table as an .html file. You can use whatever package you wish to create the table (e.g., gt, gtsummary, flextable, and so on). Along with the code used to complete this task (and helpful explanations) in a Quarto (.qmd) file, we require the saved table file(s). Marks will be awarded for completing the task successfully (e.g., displaying the correct descriptive statistics), but also for producing a table that is ‘publication-ready’ – i.e., well formatted, aesthetically pleasing, and understandable. Task 3 (15% of marks) Load the dataset from Task 1 and run a series of cross-sectional regressions for each (valid) combination of: - Outcome: smoking status, SF-12 MCS, SF-12 PCS, obesity, and life satisfaction - Exposure: employment status and degree qualification - Control variables: age, age-squared and date of interview - Wave: 1-14, separately. - Sex: males, females, and males and females combined Store the results of the regressions in a single tibble containing coefficients, standard errors, and upper and lower confidence intervals for the exposure of interest, as well as details on the parameters of the regression (outcome, exposure, … , sex used). For each regression, use OLS regression (lm()), regardless of whether the outcome variable is continuous or binary. As with Task 1, all that is required for this question is the code used to complete this task, provided in a Quarto (.qmd) document. Marks will again be awarded to students who reduce the amount of code written to complete this task, compared with writing out all instructions manually, and to students who include helpful comments explaining their code. Part B Task 4 (50% of marks) The datafile “Brexit.RData” contains data from Understanding Society, wave 8. It includes approx. 25,000 individuals and information on the following characteristics: • pidp: Person ID • bornuk_dv: Born in UK • gor_dv: Region of residence • brexit_leave: Intention to vote "leave" (1 means intention to vote “leave”) • age_dv: Age • sex_male: Male • marstat_dv: Marital status • migback_gen: Migration background • ethn_dv: Ethnic group • hiqual_dv: Highest level of education • nkids_dv: Number of kids • jobstat: Employment status • unemployed: Unemployed • fihhmnnet1_dv: Household labour income • hh_inc_oecd: Household equivalence income • ind_lab_inc: Individual labour income • tenure_dv: Housing tenure • area_rural: Lives in rural area • lkmove: Likes to move to a new place of residence • financial_diff_fut: Subjective financial situation - future (Looking ahead, how do you think you will be financially a year from now, will you be) • financial_diff_now: Subjective financial situation - current (How well would you say you yourself are managing financially these days? Would you say you are) • health: General health • distress: Level of distress (0 indicating the least amount of distress; 36 indicating the greatest amount of distress) • lifesat: Satisfaction with life overall (1 Completely dissatisfied; 7 Completely satisfied) • deprivation: Household-level material deprivation (0 no deprivation - 100 highest level of deprivation) • problems_bills: Having trouble to pay the bills • problems_counciltax: Having trouble to pay the council tax • nbh_deprivation: Neighbourhood deprivation percentile (1 lowest level of deprivation, 10 highest level of deprivation) • nbh_foreign: Neighbourhood share of foreigners (1 lowest percent of foreign residents, 10 highest percent of foreign residents) • nbh_above65: Neighbourhood share of residents above 65 (1 lowest percent of residents above 65, 10 highest percent of residents above 65) Factors have labels in the data. For binary indicators (1 mean yes and 0 mean no). Here is your task: Build a machine learning algorithm to predict the intention to vote “Leave” in the Brexit referendum (brexit_leave). Your main aim is to increase the out-of-sample accuracy. You can use any algorithm that we have covered in our module, and you can also use different algorithms if you can justify your decision. Your submission should include an HTML document that clearly addresses the following: A) Data Preparation • Describe any recoding or preprocessing steps you performed. B) Sample Size • Report the final sample size used in your analysis. • If it differs from the original sample, explain why. C) Train/Test Split • Explain how you split the data into training and test sets. D) Hyperparameter Tuning • Describe how you selected or tuned hyperparameters for your model(s). If you used Cross-validation, explain briefly what you did. The code for CV needs to be executable. E) Prediction Methods • Briefly explain which machine learning methods you used to generate predictions and why you selected those. You can also compare the performance of multiple algorithms to make your final choice — if so, include the comparison in your code. F) Performance Evaluation • Select a final model that is your preferred choice for predicting the outcome. Your final model must be recognizable in the code – so that we can use it for prediction with our hold-out sample. • Report your final performance metric (e.g., accuracy, AUC, MSE). G) Feature Importance • Provide a summary of feature importance and a short explanation of the key findings from your preferred model. Your document should make clear how you selected your final prediction model and provide evidence of its out-of-sample performance using the provided data. Note: The primary goal is out-of-sample prediction accuracy. For Part B of your coursework, please submit: • A document with a narrative explanation of your approach (HTML / DOC / PDF) • Your quarto / R script. with fully replicable code (must run on a different device) This code should be self-contained and be capable of running in full from scratch – i.e., from a clean R session, to loading packages, wrangling the provided data, and producing and saving relevant outputs (e.g., plots or tables). We will test your model’s performance on hold-out data that is not included in the dataset you received. Extra marks will be awarded to submissions that achieve a high prediction accuracy on this hold-out data (defined as being within a reasonable range of the best-performing model).
Final Project Options COSI 112a Fall 2025 1 Overview The final project is an opportunity to apply concepts from this course to a substantial problem of your choosing. You may select one of the three project tracks below or propose your own project that incorporates course topics in a novel way. 2 Requirements All projects must include: • A 4—8 page written report (excluding references) • Code/implementation or formal analysis (depending on track) • A 1-page project proposal 3 Timeline • Friday, November 14: Project proposal due • Monday, December 2: Progress check-in • Wednesday, December 18: Final project due 4 Project Tracks 4.1 Track 1: Research & Training This track focuses on training or fine-tuning models to perform logical reasoning tasks using the frameworks we’ve covered in class (modal logic, epistemic logic, temporal logic, dynamic logic, etc.). Projects should involve substantial machine learning work that goes beyond parsing—your model should use these logics in interesting ways, not just convert natural language to formal syntax. Example projects: • Fine-tune an LLM on a modal logic task and analyze changes in model performance and behavior. • Apply a new architecture (e.g. TRM) to SAT Solving • Create a benchmark for evaluating temporal reasoning in language models and show how models perform on it • Train a model to reason about multi-agent beliefs in interactive scenarios using logics we have discussed • Compare different training objectives (SFT vs. RL) for teaching models deontic reasoning 4.2 Track 2: Systems & Applications This track focuses on building interactive systems or applications that use logical frameworks from the course in a practical way. Your system should have a working implementation with a user interface (could be command-line, web-based, or graphical) and demonstrate a clear use case. The logic should be doing real computational work in your application—not just for decoration. Think games, tools, simulations, or interactive experiences that actually require logical reasoning under the hood. Example projects: • Build a multiplayer deduction game where an LLM opponent uses epistemic logic to reason about what other players know • Build a multi-agent coalition system that computes and visualizes strategic options for boardgames or online games • Create a dialogue system that explicitly tracks user beliefs and common knowledge given a video and prompt • Build a deontic logic compliance checker for policies or workflows • Create an interactive theorem prover with a game-like interface for learning modal logic • Create a procedural puzzle generator that uses modal logic to ensure solvability and difficulty scaling 4.3 Track 3: Analysis & Theory This track focuses on rigorous investigation of logical systems or models’ reasoning capabilities. Projects should provide novel insights through either formal mathematical analysis (proofs, com- plexity results, expressiveness comparisons) or systematic empirical study (designing experiments, collecting data, statistical analysis). This isn’t about building something that works—it’s about deeply understanding how or why something works, what its limitations are, or how different ap- proaches compare. Example projects: • Conduct an empirical study of LLM performance on modal reasoning with varying complexity • Propose and formalize a novel logical system for a specific application domain • Apply probabilistic epistemic logic to model a real-world scenario (e.g., information diffusion) • Investigate the computational complexity of reasoning in hybrid logics • Formalize and prove completeness/soundness results for a novel probabilistic modal logic • Model LLM dialogue using Kripke structures and analyze belief update dynamics • Define a formal semantics for LLM context windows using possible worlds and prove properties about information flow • Model multi-turn LLM conversations as dynamic epistemic logic and analyze common knowl- edge emergence 4.4 Your Own Project You are encouraged to propose your own project that combines course topics in a creative way. You must discuss your idea with the instructor or TA before submitting your proposal. 5 Submission Your proposal (1—2 pages, due November 14) should include: • Title and track (or indicate if it’s a hybrid) • Motivation: Why is this interesting? What gap does it address? • Approach: What methods or tools will you use? • Deliverables: What will you produce? • Evaluation: How will you measure success? • Related work: 2—3 relevant citations We will provide feedback to help you scope the project appropriately. 6 Evaluation Projects will be graded on: • Technical quality (50%) • Conceptual understanding (30%) • Written communication (20%)
Financial Modelling Techniques Individual Coursework for 2025 - 2026 Write a report entitled ‘An explanation of short-run changes in U.K. inflation, 2000 – 2025 ’. Your report should be around 1,500 words and must be uploaded on canvas on Thursday 11th December 2025. Your project will require you to use cointegration techniques and to build a short-run error correction model. You are required to select three variables of your own choice, which you feel are useful in explaining recent movements in U.K. inflation. You may use STATA or EVIEWS and/or other statistical software of your own choice. You are required to submit your software output as an appendix, and you should also submit your data and econometric work files. Possible Data Sources: You may find the following sources of data useful DataStream Bank of England Statistical Interactive Database World Bank Open Data https://data.worldbank.org/ DataBank: World Development Indicators FAME CRSP COMPUSTAT Bloomberg Guidelines for writing up projects: Your project should cover the following themes. 1. Introduction This section identifies the topic, explaining why it is of interest, what the expected conclusions are, what your paper's findings are, and how the report is structured. 2. Brief Literature Review You may use DataStream, or other databases to identify previous models and work. You should describe the economic theory underlying the topic outlined above. In particular, you should define concepts that you are likely to be testing in the statistical analysis. This is where you should be laying out your model, and you are expected to describe the model you plan to estimate and whose earlier work you have based it on. 3. Data and Methodology Explain the sources of the data (display a table of your data along with precise sources, and detailed definitions of variables in an Appendix). Explain why you have chosen to use specific definitions in your analysis and describe any problems you have encountered in collecting the data (e.g., limited availability of data, changes in definitions of published variables, etc.). Are there likely to be any problems specific to your project? A concise description is needed of the econometric techniques to be employed. Explain why these techniques are necessary and/or appropriate for the data in hand. 4. Results and Interpretation This is a particularly important section of the project. Clearly present the results of your analysis. Comment on the goodness of fit of the model and the economic and statistical properties of the estimates. If you have tried different specifications of the model, make comparisons of the different interpretations of these models. Check for any technical problems with your preferred regression model. Model mis- specification tests are recommended. Clearly show the tests you have used and the conclusions you have drawn, and also identify which model is the best econometric model and why it is so. If problems still exist in your best model, comment on the potential cures. There is a need for carefully interpreting the economic meaning of the best model based on the model specification tests above. 5. Conclusions Please ensure your conclusions are broader than just a simple summary of your results. 6. Limitations and Policy Recommendations You should report any limitations of your study and suggest recommendations to economic policymakers. 7. Bibliography Use standard economics referencing techniques here and with references in the text. Note: A useful guide to writing an empirical research report is to be found in Saunders M.K., Lewis P. and Thornhill A., “Research Methods for Business Students” Ninth Edition. Pearson Press, ISBN 13- 978-1292402727 Chapter 14
Study Paper: Precision Design 1. Based on the 2D tolerance analysis techniques [1,2], we can determine the spatial variations of kinematic dimensions. In particular, we can use the sensitivity OTJaTT analysis [1,2] to identify key component dimensions in any design. This will allow us to focus on the key dimensions that affect the assembly dimensions u. The newtechnique can guide us to a new domain where we can improve our design to achieve high product quality without significant increase in cost. It is a new kind of design optimization, where we can achieve an optimal balance between product quality and production cost. (1) Select a suitable design, where m=6 or greater and nv=2 or greater, for 2D precision analysis. Provide assembly drawing and also component drawings for your design and determine x. Describe your design (See the example below) and the assembly dimensions u. Also determine n, n, nv, vector chain L, Ix, Iu, Lilφ/Σφ table, Φ, Φk, Φ, Ik, It, n, m, q, total number of unknowns for nν. (2) Discuss each of assembly dimensions, u, i=1,2,,mtq, and explain how quality or performance of your design is affected if ui, i=1,2,...,m+q, is changed. (3) Identify the key component dimensions [1,2] to demonstrate the usefulness and applicability of the lecture contents [1,2]. Determine H, ua-n,. Фa-n, Ax, Δu, ΔH each A element, A, each B element, B, T, table, To, Tuo, u, Ф, oTuaToT. Based on x, give a list of key dimensions. Also, based on To for making x, determine the total manufacturing cost Cmo [3] for making x. Consider two approaches: (a) The precision of each key component dimension is increased by 30%, which is the new approach, based on the common approach of To. For the new approach the total manufacturing cost Cm(a) [3] for making x is to be examined. Based on To, give T(a). Also, base on T(a), determine Tu(a). (b) The precision of every component dimension x is increased by 30%, which is the traditional approach, based on the common approach of To. For this approach, the total manufacturing cost Cm(b) [3] for making x is to be examined Based on To, give T(b). Also, base on Tb), determine Tu(b). Now compare the two approaches, (a) and (b), in terms of assembly's precision or quality, specifically, in terms of Tu, and in terms of total manufacturing cost Cm [3] for x. (4) Determine the total manufacturing cost increase ACma/b), ACm(a/b)=Cm(a/b) - Cmo, and the kinematic spatial error reduction ATu(a/b), ATu(ab)- Tuo-Tu(ab). Study the precision improvement per unit cost increase ATula/ACma). and ATub/ACm(b) (5) Give your recommendation on choice of precision design approach, based on your analysis, when upgrading product quality. The work in (6) is optional: (6) Based on the 2D tolerance analysis techniques together with the sensitivity aTJaTT analysis technique [1,2], a nice precision design work can be done as in (1)-(5). In addition, a new kind, one step further, of good design work can also be done. This is precision based design optimization: Consider several designs under a particular set of design specifications, try to conduct the 2D sensitivity analysis and compare the elements in Tu/aTT and select the best design among the several available designs. Example: For your reference, an example of design for 2D tolerance analysis is the optical lens assembly (Fig. 1). The precision assembly includes two spherical lenses, a retainer, and a housing design. The assembly is symmetrical about the axis (Fig. 1), so only the upper half is illustrated. For simplicity, the section view hatchings for the retainer and the housing are omitted (Fig. 1). The assembly is also called as narrow field of vision lens assembly. In a particular version of the proposed design, the thickness of Lens 1 a is 0.3±0.001 inches, the radius of curvature of the surface of Lens 1, noted as b, is 10.72+0.022 inches. Lens 1 is held against an inclined surface c. The lens is in contact with the surface c at a particular point. The angle between the inclined surface c and the axis, also called as lip angle, is 84.8°. The retainer flange depth e is 0.5±0.001 inches, and the retainer radius fis 1.03±0.0005 inches. The housing length h is 7.07±0.002 inches, and the depth of Lens 2, noted as i, is 0.47±0.001 inches. The 2D tolerance analysis techniques [1,2] can be used to investigate the spatial variation of the distance g between the two lens surfaces (Fig. 1). It is noted that in order to restrict the analysis to 2D and to simplify the analysis, the following assumptions can be applied to the precision assembly (Fig. 1): i) the lenses have no tilting; and ii) the contact between the housing and the retainer is circular. Please include your name and ID at the top of your study paper's front page. (2025) References [1] Gao, Y., 2025, "Precision Manufacturing Technologies", Lecture Notes, HKUST, Hong Kong. [2] Zhang, H.C., 1997, "Advanced Tolerancing Techniques", John Wiley and Sons, New York. [3] Parker, M., 1991, "Manual of British Standards in Engineering Drawing and Design", Stanley Thornes, England.
GEOS 103 Fall 2024 Lab 2: Hillslopes Background Mass movements are hillslope processes that transport debris such as rocks, soil, and trees downslope by gravity. Three main types of mass movements are falls, slides, and flows. These mass movements can be further discriminated by the type of “debris” they carry. For example, rockslides are slides which primarily carry rocks, landslides carry dirt or soil, mudflows carry mud, and debris flows may carry a mixture of mud, trees, and rocks. Figure 1: Three types of mass movements. Falls (a &d), flows (b & e), and slides (c & f). Rockfall on Mt. Webb near Chilliwack, BC (d). Debris flow on Mt. Joffre near Pemberton, BC (e). Historic 1965 ‘Hope Slide’ near Hope, BC (f). Learning Objectives In this lab we will hillslope processes and mass movements. After completing the lab you should be able to, • Differentiate between slides, flows, and falls • Apply conservation of energy to mass movement runout distances • Evaluate hillslope stability using force balances • Calculate the factor of safety and explain its relevance to evaluating hillslope stability Required Files and Software Only a calculator is needed for this activity. Part I - Conservation of Energy and Mass Movement Runout Mass movements convert gravitational energy into heat by moving material downslope. If material of mass M moves down a vertical height Has it runs out horizontally a distance L, conservation of energy provides the governing equation, This equation says that the gravitational potential energy MgH is converted into heat over a runout distance L. The parameter Ris an energy dissipation rate per unit weight and distance. Ris a dimensionless parameter that characterizes how rapidly the mass movement converts gravitational energy to heat as it moves. This equation allows us to calculate R by analyzing a mass movement’s source and deposit locations. Dividing the above equation by MgL provides, If a mass movement has large R, its runout distance L will be small, but if it has small R, its runout distance will be large. This suggests that we can define the efficiency of a mass movement travelling downslope by, In other words, the more efficient a mass movement is, the farther it will travel. In the next several questions, we will analyze the efficiency of Tahoma Watershed mass movements. Figures 2-4 Figure 3: Tahoma Creek Watershed mass movement sites explored in this lab. Figure 2: Satellite images of the Tahoma Creek Watershed mass movements with the source (S - pink) and depositional (D - blue) zones outlined. Question 1: Looking at figures 2-3 and using figure 1 as a reference, site A shows a ___________, Site B shows a _____________, Site C shows a _____________, and Site D shows a _______________. Options include rockfall, rockslide, & debris flow, and can be used more than once. (4 pts) Figure 4: Tahoma Creek Watershed mass movement ‘long profiles,. Profiles measure elevation vs. downslope distance along mass movement centreline, starting from the source (S) and ending at the end of deposition (D). A-D corresponds with A-D in Figures 2-3. Question 2: Using Figure 4, calculate the efficiency of mass movements A-D. Round your answer to 2 decimal places (4 pts) Site A: Site B: Site C: Site D: Question 3: Based on your answers in Q2, order the efficiencies of slides, falls, and flows from smallest (1) to largest (3). (3 pts) 1. 2. 3. Part II - Force Balances & Slope Stability Slope stability results from a balance between driving and resisting forces. When driving forces exceed resisting forces, slopes can collapse. When resisting forces exceed driving forces, slopes are stable. These statements are summarized by the factor of safety (FS), which is the ratio of resisting shear strength to driving shear stress. The following diagram describes the infinite slope model (ISM) for the factor of safety: Figure 5: Infinite slope model for the factor of safety. The factor of safety equation is, Based on Figure 5 and the equation above, answer the following questions. Question 4: Which values of the factor of safety characterize a stable slope? Circle all that apply. (1 pt) A: FS > 1 B: FS < 1 C: FS = 0 D: FS ≥ 0.5 Question 5: Which would be the net effect on slope stability of an increased pore- water pressure if everything else stays the same? What could increase pore-water pressure? (1 pt) Much more evidence of former mass movements can be found in the upper reaches of Tahoma Creek, just downstream of the South Tahoma glacier terminus. The area immediately in front of the glacier is termed a proglacial zone. In this area loosely packed glacially derived sediment (till) has become exposed as the Tahoma glacier retreated. River erosion and landslides from the banks of Tahoma Cr. leave scars or “scarps” in this loose sediment. Site (e) from figure 2 shows two scarps and one over steepened slope which may collapse in the future (Figure 6). Sediment in the proglacial zone of South Tahoma Glacier (Figure 6) is loosely packed and sandy, so it is non-cohesive (C = 0) and quickly drains water, meaning it is usually unsaturated (m = 0). Under these conditions, the factor of safety equation can be simplified to. Where Sm is the maximum gradient that a stable hillslope takes on (tan ∅), and Sf is the gradient of the potential failure plane (tan θ). For loose sand, ∅ ranges between 25˚ and 30˚. Figure 6: Recent mass movements in till within Tahoma Creek Watershed proglacial zone. Corresponds to Site E from figure 2. Panel (a) shows an over steepened area which may collapse in the future (blue) and two former landslide scarps (II & III - orange). Panel (b) shows the longitudinal profiles from source to deposit along the black centrelines. Panel (c) shows a crescent-shaped landslide scarp traced in orange in the same area as panel (a) that led to a large debris flow in 1988. Question 6: Estimate Sf for Slope I in Figure 6b. (1 pt) Hint: Estimate Sf by calculating the slope between distance 10 and 40 m (the steep part where a landslide is most likely to occur). Sf: Question 7: Using Sf from Q6, calculate the factor of safety for Slope I. Report your answer to 2 decimal places. (2 pts) FS: Question 8: Does the infinite slope model indicate that Slope I is stable or unstable? (1 pt) Question 9: There are many assumptions used to derive the infinite slope model (ISM) that limit its application to natural hillslopes. By comparing the ISM definition sketch above with the real Tahoma watershed landslide scarps in Fig. 6, identify and briefly explain (2-3 sentences) two major shortcomings of the ISM. (3 pts)
FPGA Model-Based Design and Verification of a Convolution Encoder MSc Advanced Reconfigurable Systems and Designs Aims and Objectives: This exercise consolidates your understanding of model-based design through the practical design and implementation of a convolutional encoder widely used in today’s wireless communication systems. The recommended encoder follows IEEE practice as adopted by multiple wireless standards. It also tests your ability to solve real FPGA design problems and to work effectively in a team. By the end, you should be confident in designing other digital systems. Background knowledge Design and implement a convolutional encoder used in IEEE 802.11 or IEEE 802.16 standards. Please refer to the standards [1], [2]. Requirements / Tasks 1. From specification to circuit Using the encoder specification (polynomial and octal form) from the standard, derive the circuit and select the required components. Justify your decisions. Build a Simulink model to prove the functional design and explain how it meets the requirements. Present the generator polynomials in both forms and show the conversion steps (octal ⇄ polynomial), including constraint length and code rate. Include a small trellis/block diagram to illustrate taps. 2. Model-based design & hardware verification Design the selected convolutional encoder using System Generator for DSP (model-based flow) to further verify the encoder. Justify your design. Implement the design on FPGA hardware and verify using Hardware-in-the-Loop (HIL). 3. Synthesis, analysis and improvement Synthesis the design in Xilinx Vivado and analyse/discuss resource usage and speed. Evaluate performance, including any environmental and societal impacts. Identify the critical path; discuss techniques to improve the design to meet requirements and the drawbacks if timing is not met. 4. RTL cross-check Write VHDL to implement the convolutional encoder. Use the same binary input as in Simulink and compare results with the model-based design. Challenge: Create your own components using BlackBox in System Generator for DSP to replace library components. Re-implement your design and demonstrate equivalent results. Suggestions You are recommended to read a tutorial article or watch an introductory video on convolutional encoders [1]. More details on IEEE 802.11 and IEEE 802.16 can be found at [2], [3]. Many textbooks explain convolutional coding clearly; it is relatively straightforward to understand. Report Submit a group report describing how you met the design requirements and discussing simulated and measured results by the deadline stated in the Assignment Briefing Sheet. Indicate each member’s contribution clearly. Each group should have a coordinator/group leader, and members should have different tasks. Each group should have 3–4 members. Your report must be typed using the IEEE two-column journal template (template available on IEEE journals’ websites). Keep the report well-organised and concise, with no more than five pages (excluding appendix). In the report, show the full design process. All design decisions must be explained and justified. Details of the marking scheme are provided in the Assignment Briefing Sheet. References: [1]https://www.youtube.com/watch?v=o_iKfGlxwXw [2]https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=9363693 [3]https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=8303870
Assignment briefings (2025/26) Weighting %: 50% Submission deadline (for students): See Canvas Authorship: Group Target date for returning marked coursework: 13/01/2025 Tutor setting the work: Mudassir Hussain /Kaung Oo Htet/ Baochun Hou Number of hours you are expected to work on this assignment: 20 This Assignment assesses the following module Learning Outcomes (from Definitive Module Document): 1. Demonstrate critical understanding of design methodologies for modern FPGA systems. (M1) 2. Design and implement digital signal processing algorithms on an FPGA and evaluate its performance including the environmental and societal impact; (M2, M3, M5, M7) 3. Work effectively within a team and demonstrate professional, ethical, and sustainable conduct skills. (M16, M17) Assignment Tasks: This assignment is intended to help you to enhance your ability to logic design and digital signal processing algorithms implementation on FPGA for an application in communication systems. It is also to develop your skill working in a group. More detail of the assignment, please see the Assignment Information in a separate document. Submission Requirements: You are required to submit a group report (one for each group). In the report • You must clearly show all the design process and stages. • All design decisions must be fully explained and justified. • You should present the simulation results and discuss them in detail. • Indicated the contributor of each section/chapter. Your report must be typed and use IEEE standard two columns format. A template can be downloaded from IEEE Journal website. It should be organized and concise, and no more than five pages in length (using Arial font at font size 11). You need to submit your group report in electronic version on StudyNet/Canvas. Marks awarded for: 1. Project planning with clear individual contribution. You must divide the task equally among group members, where you must have a group leader. At the end of project, there will be a peer assessment (each student assesses each other member student’s contribution.) (10%) 2. Report: (70 %) a. Report presentation and layout including clarity of exposition (20%), b. Discussion of the design methodology and process (40%), c. Quality of analysis of simulation and synthesis results (30%), d. Conclusions and future improvement (10%). 3. Overall performance of the design (20%) a. Individual performance: leadership role, quality of responsible task and challenge task Marks will only be awarded to students who have made contribution to the group assignment. Type of Feedback to be given for this assignment: General feedback will be provided on StudyNet and written feedback will be provided on each report. Additional information: • Regulations governing assessment offences including Plagiarism and Collusion are available from https://www.herts.ac.uk/ data/assets/pdf_file/0007/237625/AS14-Apx3-Academic-Misconduct.pdf(UPR AS14). • Guidance on avoiding plagiarism can be found here:https://herts.instructure.com/courses/61421 (see the Referencing section) • For postgraduate modules: a score of 50% or above represents a pass mark.
LI Econometrics (08 29172) Stata Assignment In this assignment, you will explore correlates of earnings. You will use data on real individuals collected by the Office for National Statistics and published in the Quarterly Labour Force Survey. In the course of working on this assignment, you will: • be introduced to an important source of data for research on the UK (the UK Data Service); • become familiar with processing and analysing data using Stata; • interpret regression output; • develop critical thinking about economic phenomena and econometric analysis of them. Practical details Word limit: no more than 1500 words. Reasonable use of tables and figures does not count toward the word limit. Submission file: one file (in .pdf or .doc format). Sections: Please label the sections and sub-sections clearly. Figures and tables: should be numbered and titled appropriately. Tables should be formatted and presented as in standard economics journals (copy-pasted output from Stata is not acceptable). Appendix: an appendix should be included at the end of the assignment, containing a copy of the Stata code used to obtain the results. This should be the exact code used to go from loading the dataset to generating the results presented (no more, no less). For convenience, you can simply copy and paste the .do file. Preliminaries You will have familiarised yourself with how to use the UK Data Service in the support session in week 6. Following the same steps, access and download “Quarterly Labour Force Survey, April-June, 2018 (SN 8381)". 0. Loading data and defining the sample a) Load the main dataset (lfsp_aj18_eul.dta) in Stata. b) We will focus on individuals reporting positive gross weekly earnings and not currently working towards a qualification. To keep only these observations, do: keep if GRSSWK > 0 & QULNOW == 2 c) Check: the resulting dataset should contain 9141 observations. If this is not the case, something has gone wrong somewhere. Section A 1. Region and earnings a) Plot the distribution of weekly earnings (GRSSWK) in a histogram and provide a brief comment. b) Now let us think about the region in which the respondents live. With reference to economic theory and intuition, why might there be regional differences in earnings? c) Construct a new variable by taking the logarithm of gross weekly earnings, i.e. log(GRSSWK). Then, using the variable AGE, create a new variable that represents the squared age. Further, using the variable COUNTRY, that represents the country within the UK that the respondent lives in, create dummy variables for each one, i.e. England, Scotland, Wales and Northern Ireland (make sure that your Scotland variable includes both the categories of “Scotland” and “Scotland North of Caledonian Canal”). Using Wales as the baseline country, estimate the regression: logGRSSWKi=α+γ1Agei+γ2Agei2+β1Englandi+β2Scotlandi+β3Northern Irelandi+ϵi (1) Report your findings in a table, discuss the coefficients and comment on the country differences that you have found. d) Using Stata’s test command, perform. three tests to show whether there are any statistical differences in earnings between residents living in (i) England and Scotland; (ii) England and Northern Ireland; and (iii) Scotland and Northern Ireland. Specifically for test (i), show also how it can be done by hand, i.e. by calculating the F statistic yourself (make sure you show all your calculations as well as the restricted model that you need to estimate in order to calculate the test statistic). e) Now let’s consider only residents that live in England, by removing anyone that lives in the other nations (you can use the keep command for this). The resulting dataset should contain 7616 observations. Using the URESMC variable, create dummy variables for each region in England and estimate a regression that includes the age variables and these region dummies (use Merseyside as the base category as it has the fewest observations). Report your findings in a new table and make sure that your regional dummies have meaningful names. Are there significant regional differences in earnings? Do your findings support your economic intuition about regional effects, for example, do your results show a London effect? 2. Education a) The variable HIQUL15D details the highest qualification that each respondent has achieved. Tabulate HIQUL15D to see what categories exist. Remove anyone that either did not answer or did not know their highest qualification, i.e. keep only those people that have a qualification of some sort or have no qualifications at all. This should leave you with 7521 observations. Create a dummy variable that takes the value 1 if someone has a degree or equivalent and 0 otherwise. Run the same regression as in part 1e) but now include your degree dummy as well. Report your findings in the same table from part 1e). With reference to links between education and region, how might differences between these results and those from part 1e) be explained? b) Run a test to see whether all the region coefficients are the same. Then run the test again but exclude Inner London, Outer London and the rest of the southeast. Are these results what you expected? Section B 3. Other factors a) Pick an additional dimension on which information is available in the dataset (consult the user manual and codebook (lfs_user_guide_vol3_variabledetails2018.pdf) for details) and construct variable(s) which allow you to explore the relationship between this dimension and earnings. Without running additional regressions (yet), why does economic theory tell you to expect this dimension to matter for earnings? Do you think your chosen dimension might vary across English regions, or between respondents with and without a degree? b) In the sample you used for part 2, estimate additional regressions to test whether your theoretical predictions hold in the data. Present these in a second table and discuss. What do your findings tell you about how your chosen dimension matters for earnings? 4. Taking a step back a) In defining our sample, we kept only individuals reporting positive gross weekly earnings. Why might that affect any conclusions we draw about regional differences in labour market outcomes? b) When conducting our regional analysis above, we considered respondents’ region of residence. The people residing in a region will be a mix of those who were born there (“non-movers”) and those who moved there from other regions or from abroad (“movers”). Suppose we could distinguish between “movers” and “non-movers”. Speculate on how you think the various results you have found in your analysis might differ between the two groups.
Assignment Remit Programme Title BSc Economics etc Module Title Econometrics Module Code 08 29172 Assignment Title Stata Assignment Level LI Weighting 50% Hand Out Date Deadline Date & Time 17/12/2025 12pm Feedback Post Date 16th working day after the deadline date Assignment Format Report Assignment Length 1500 words Submission Format Online Individual Module Learning Outcomes: This assignment is designed to assess the following module learning outcomes. Your submission will be marked using the Grading Criteria given in the section below. LO 1. demonstrate knowledge and critical understanding of econometric theory LO 2. apply a range of methods of inference to practical problems in econometrics and empirical economics LO 3. interpret econometric results Assignment: Students will: Access and download economic data from standard sources. Handle, manage and analyse data using econometric software (Stata). Produce summary statistics and carry out regression analyses to explore important economic relationships (both guided and open-ended). Apply economic and econometric theory to interpret results. Think critically about econometric limitations. Grading Criteria / Marking Rubric Students will be marked on (rubric at end): Clarity of argument (in writing and use of tables/figures). Use of evidence (claims made supported by results from empirical analysis). Critical application of economic and econometric theory. See the marking rubric at the end of the remit for more information on how your work will be marked and graded.
Assessment Proforma 2024–25 Key Information Module Code CMT304 Module Title Programming Paradigms Assessment Title Logic Programming Assessment Number Logic Programming tasks of the portfolio coursework Assessment Weighting 25% of the portfolio coursework Assessment Limits Limits are per task as set in the instructions The Assessment Calendar can be found under ‘Assessment & Feedback’ in the COMSC–ORG– SCHOOL organisation on Learning Central. This is the single point of truth for (a) the hand out date and time, (b) the hand in date and time, and (c) the feedback return date for all assessments. The COMSC Assessment Calendar for all assessments is also available on Learning Central: by going to ‘COMSC-SCHOOL’ organisation -> ‘Assessment & Feedback 2025 - 26’ folder -> ‘COMSC Assessment Calendar 2025 - 26’ page. 1 Learning Outcomes The learning outcomes for this assessment are • Explain the conceptual foundations, evaluate and apply various programming paradigms, such as logic, functional, scripting, filter-based programming, pattern matching and quantum com- puting, to solve practical problems. • Discuss and contrast the issues, features, design and concepts of a range of programming paradigms and languages to be able to select a suitable programming paradigm to solve a problem. 2 Submission Instructions The coversheet can be found under ‘Assessment & Feedback’ in the COMSC–ORG–SCHOOL or- ganisation on Learning Central. All files should be submitted via Learning Central. The submission page can be found under ‘As- sessment & Feedback’ in the CMT304 module on Learning Central. Your submission should consist of these files: Description Type Name Coversheet Compulsory One PDF ( . pdf) file coversheet. pdf Task 1.1 Compulsory One ASP ( . lp) source file problem_encoding. lp Task 1.2 Compulsory One PDF (.pdf) file task1-2. pdf If you are unable to submit your work due to technical difficulties, please submit your work via e- mail to [email protected] and notify the module leader (and ideally the setter, if different). If the technical is- sue is with Cardiff University systems, also report it to the University IT Support: email [email protected], tel. +44 (0)29 2251 1111. Any code will be tested on a Linux system equivalent to COMSC’s Linux lab machines and must run there. 3 Assessment Description 3.1 Logic Programming Consider the following situation: Patent requests are submitted to the patent office and are reviewed by members of the technical board (referees). To find a good match between patent requests and referees, every referee declares their expertise for each submitted request that needs to be reviewed: Expert, Knowledgeable, Familiar or Inexpert For example, declaring Expert for a given patent request P1, means “I am an expert on the topic of patent request P1 ”. The goal is to write a program to automate this process. Using a list of bids that indicate each referee’s level of expertise for each patent request, the task is to assign each submitted patent request to exactly of n referees, subject to the following requirements: • the workloads of the referees are approximately equal, that is, do not differ by more than m; • no referee is required to review more than k submissions from the Familiar category; • the total number of cases when a submission is assigned to a referee who placed it in the Inexpert category is as small as possible; • the total number of cases when a submission is assigned to a referee who placed it in the Expert category is as large as possible. The parameters n, m and k are arguments set when calling the program. Task 1.1: Write a logic program in ASP (problem_encoding. lp) which finds all solutions to the problem, given as input n, m and k and a list of bids. Your program will receive as input a set bid/3 of triples ref, req, exp, such that the referee ref has declared to have expertise exp for request req. (The parameters n, m and k are set when calling the program). The output of your program is a set assign/2 of pairs ref and req such that the referee ref has been assigned to review request req. Make sure you document your code, so the following is clear: 1. How it should be used. 2. What the approach to solving the problem is. In particular, you need to explain what each rule achieves. Task 1.2: Write a short report on logic programming related to the problem: 1. Provide, in no more than 300 words, an analysis of the design and functioning of your pro- gram: (a) Describe the operation of each rule, explaining both how the body of the rule is evaluated and what output is generated. (b) Discuss how your program implements the guess-and-test methodology. The word limits are an upper limit, not a target length. Text longer than the word limit will be ignored. 4 Assessment Criteria Task 1.1 worth 70% of the coursework High Distinction 80% − 100% Code is valid without syntax errors and creates a valid output for every valid input. A suitable attempt to solve the problem has been made, that will find all solutions (if there are any) for all problems. The approach is natural and correctly uses the declarative nature of ASP. The attempt has been excellently documented and clearly shows an effort to optimise the program’s performance. Distinction 70% − 79% Code is valid without syntax errors and creates a valid output for every valid input. A suitable attempt to solve the problem has been made, that will find all solutions (if there are any) for all problems. The approach is natural and correctly uses the declarative nature of ASP. The attempt has been well documented. Merit 60% − 69% Code is valid without syntax errors and creates a valid output for every valid input (or produces a suitable error message for valid cases it cannot process). A suitable attempt to solve the problem has been made, that will find all solutions (if there are any). The attempt has been well documented. Pass 50% − 59% Code is valid without syntax errors and creates a valid output for every valid input (or produces a suitable error message for valid cases it cannot process). A suitable attempt to solve the problem has been made, that will often find at least one solution (if there is any). The attempt has been reasonably doc-umented, but no consideration has been given to optimise the program’s performance. Marginal Fail 40% − 49% Code is valid without syntax errors and creates a valid output for every valid input (or produces a suitable error message for valid cases it cannot process). A suitable attempt to solve the problem has been made, that will in some cases will find at least one solution (if there is any). The attempt has been reasonably documented, but no consideration has been given to optimise the program’s performance. Fail 0% − 39% Code does not run or does not produce valid output for any valid input; little to no relevant documentation. Task 1.2 worth 30% of the coursework High Distinction 80% − 100% The analysis of the design and functioning of the program is clear, showing a good understanding of the Guess-and-Test methodology. It clearly describes how the rules work and the interaction of the two phases of the guess-and-test methodology, making clear reference to the program. It shows an un-derstanding of related performance issues. Distinction 70% − 79% The analysis of the design and functioning of the program is clear, showing a good understanding of the Guess-and-Test methodology. It clearly describes how the rules work and the interaction of the two phases of the guess-and-test methodology, making clear reference to the program. Merit 60% − 69% The analysis of the design and functioning of the program is well-developed, showing a clear understanding of the Guess-and-Test methodology. Pass 50% − 59% A suitable attempt has been made to analyse the design and functioning of the program. Marginal Fail 40% − 49% An attempt has been made to analyse the design and functioning of the pro-gram. It correctly discusses some aspects of the Guess-and-Test methodol-ogy. Fail 0% − 39% At most an incomplete attempt to analyse the design and functioning of the program has been made.
CS 548—Fall 2025 Enterprise Software Architecture and Design Assignment Nine—Kubernetes In this assignment, you will deploy the microservices that you developed in previous assignments into a Kubernetes cluster. Step 1: Install Kubernetes I will assume that you have already installed Docker Desktop, if you are running this on a Windows or MacOS machine. You will need to enable Kubernetes in Docker Desktop in Settings: The kubectl Kubernetes client is installed with Docker Desktop (at/usr/local/bin/kubectl on MacOS). You may need to use the following command to set your Kubernetes context to that for Docker Desktop (if for example you have installed minikube): $ kubectl config get-contexts $ kubectl config use-context docker-desktop Kubernetes for Docker Desktop does not come with the dashboard enabled, you will have to install it for yourself if you wish, and it requires the installation of helm. But this is not required for the assignment. Step 2: Deploy the Database Server We will deploy the database server in Kubernetes. In the previous assignment, you created a Docker image that initialized the database when the server was run. To now deploy this in Kubernetes, create a YAML configuration file clinic-database-deploy.yaml for Kubernetes: apiVersion: apps/v1 kind: Deployment metadata: name: clinic-database labels: app: clinic-database spec: replicas: 1 selector: matchLabels: app: clinic-database template: metadata: labels: app: clinic-database spec: restartPolicy: Always containers: - name: clinic-database image: cs548/clinic-database env: - name: POSTGRES_PASSWORD value: XXXXXX - name: DATABASE_PASSWORD value: YYYYYY imagePullPolicy: Never The matchLabels field specifies how this deployment matches the pods that it may manage. The imagePullPolicy ensures that Kubernetes does not attempt to pull the docker image from the global docker repository, but only pulls it from the local repository. Start this database server up as a pod in Kubernetes: $ kubectl apply -f clinic-database-deploy.yaml $ kubectl get pods $ kubectl describe pod pod-name Now create a YAML configuration file clinic-database-service.yaml to provide access to this deployment. It would make sense to just make this available within the cluster by specifying a type of ClusterIP, but you may want the option of being able to connect to it from the “node” (i.e., your laptop) with psql or the Intellij Database tool, so we expose it outside the cluster using NodePort: apiVersion: v1 kind: Service metadata: name: clinic-database labels: app: clinic-database spec: type: NodePort ports: - name: jdbc port: 5432 targetPort: 5432 selector: app: clinic-database The node port is the port on the node (your laptop) on which this service is exposed outside the cluster. Since it is not specified here, it will be generated automatically. The port is internal to the cluster and is that on which other pods in the cluster can access this service (with “virtual host name” clinic-database), and accesses on the node port are forwarded to this service port. Accesses on the port of the service are forwarded to the target port 5432 in the pod (if not specified, this target port defaults to be the same as port). This target port is the port that the server in the pod should be listening on. Start this service up in Kubernetes: $ kubectl apply -f clinic-database-service.yaml $ kubectl get service clinic-database $ kubectl describe service clinic-database Here is an example output from the last step: Name: clinic-database Namespace: default Labels: app=clinic-database Annotations: Selector: app=clinic-database Type: NodePort IP Family Policy: SingleStack IP Families: IPv4 IP: 10.107.176.144 IPs: 10.107.176.144 Port: jdbc 5432/TCP TargetPort: 5432/TCP NodePort: jdbc 31338/TCP Endpoints: 10.1.0.8:5432 The node port gives you the port on the local machine (localhost) that you can use to connect to the database server. Communications to this port are forwarded to port 5432 on the container in the pod. You can test this out by setting up a connection from Intellij IDEA, with host name localhost and port number given by the node port: Step 3: Deploy the Microservice It is best practice to separate the pods where the frontend applications and the domain microservice run. If they both run in the same JVM, then restarting one requires restarting the other. Create a deployment configuration clinic-domain-deployment.yaml as before: apiVersion: apps/v1 kind: Deployment metadata: name: clinic-domain labels: app: clinic-domain spec: replicas: 1 selector: matchLabels: app: clinic-domain template: metadata: labels: app: clinic-domain spec: restartPolicy: Always containers: - name: clinic-domain image: cs548/clinic-domain:1.0.0 env: - name: QUARKUS_DATASOURCE_USERNAME value: clinicuser - name: QUARKUS_DATASOURCE_PASSWORD value: YYYYYY imagePullPolicy: Never The matchLabels field specifies how this deployment matches the pods that it may manage. The imagePullPolicy ensures that Kubernetes should not pull the docker image to the local repository if it is not already present. Since we are running Kubernetes locally, and we will have pushed the docker image to the local repository already, this is not necessary here, but this will change if we deploy in a Kubernetes cluster in the cloud. The environment variable bindings for the container should match those from the previous assignment. Start this microservice up as a pod in EKS: $ kubectl apply -f clinic-domain-deployment.yaml $ kubectl get pods $ kubectl describe pod pod-name $ kubectl logs pod-name And create a service configuration clinic-domain-service.yaml: apiVersion: v1 kind: Service metadata: name: clinic-domain labels: app: clinic-domain spec: type: NodePort ports: - name: http port: 8080 selector: app: clinic-domain Start this service up in Kubernetes: $ kubectl apply -f clinic-domain-service.yaml $ kubectl get service clinic-domain $ kubectl describe service clinic-domain Once the service is running, you can test some of the CRUD operations at this URL, using the node port (which you will again have to look up with kubectl describe service): http://localhost:31435/api/ Step 4: Deploy the applications Each application will be a client of the microservice. For the frontend Web application, define the deployment descriptor: apiVersion: apps/v1 kind: Deployment metadata: name: clinic-webapp spec: replicas: 1 selector: matchLabels: app: clinic-webapp template: metadata: labels: app: clinic-webapp spec: restartPolicy: Always containers: - name: clinic-webapp image: cs548/clinic-webapp:1.0.0 imagePullPolicy: Never And also, the service descriptor: apiVersion: v1 kind: Service metadata: name: clinic-webapp labels: app: clinic-webapp spec: type: LoadBalancer ports: - name: http port: 8080 selector: app: clinic-webapp The endpoint for the service will now be exposed by the public port number 8080 outside the cluster, and you can view the state of the domain via a Web browser at this URL: http://localhost:8080/ Use a similar strategy to deploy the frontend Web service, clinic-rest. Define a YAML file describing its deployment: apiVersion: apps/v1 kind: Deployment metadata: name: clinic-rest spec: replicas: 1 selector: matchLabels: app: clinic-rest template: metadata: labels: app: clinic-rest spec: restartPolicy: Always containers: - name: clinic-rest image: cs548/clinic-rest:1.0.0 imagePullPolicy: Never Next define a YAML file describing its service, where we specify a different port from the target port because the webapp has already bound to port 8080 on your host machine: apiVersion: v1 kind: Service metadata: name: clinic-rest labels: app: clinic-rest spec: type: LoadBalancer ports: - name: http port: 9090 targetPort: 8080 selector: app: clinic-rest The web service can be accessed at this URL: http://localhost:9090/api You need to specify different ports for the webapp and web service, because both must be accessible outside the cluster on your laptop. This was not necessary for the microservice because it was never exposed outside the cluster (except via the randomly assigned nodeport). Within the cluster, it is accessed on its own pod via a DNS lookup that resolves to the pod IP address. The combination of pod IP address and port are unique within the cluster. You can use a web browser to test some of the query operations for the microservice and this web service, and use the REST client from a previous assignment to upload data to the web service. Use kubectl logs to show via logs that both the webapp and the web service are using the backend microservice to access the domain. For your submission, you should provide your dockerfile and shell script for creating the image for the database, and YAML configuration files. You should also provide a video that demonstrates: 1. Creating docker images for the services that you deploy. 2. Launching your services and using kubectl (e.g. kubectl describe service) to show the endpoint information for these services. 3. Demonstrate your assignment working, as in previous assignments: a. Use a web browser to query the microservice (e.g., for lists of patients and providers). b. Use a web browser to query the REST web service (e.g., for a patient). c. Use the REST client CLI to invoke your frontend web service. d. Use a web browser to show the results in the webapp. e. Show with the logs that the webapp and REST web service are invoking the domain microservice in the background. 4. Show the database tables via Intellij Database tool, connecting to the database server node port, and querying the database using the clinic-rest and clinic-domain web services. Make sure that your name appears at the beginning of the video. For example, display the contents ofa file that provides your name. Do not provide private information such as your email or cwid in the video. Be careful of any “free” apps that you download to do the recording, there are known cases of such apps containing Trojan horses, including key loggers. Your video must be MP4 format! Your submission should be uploaded via the Canvas classroom, as a zip file. Your solution should consist of a zip archive with one folder, identified by your name. This folder should contain the files and subfolders with your submission. It is important that you provide your database dockerfile and all of the YAML files. You should also provide one or more videos demonstrating setting up and running your services in Kubernetes. It is sufficient to demonstrate Kubernetes running on your own machine. You should also provide a completed rubric.
CS 548—Enterprise Software Architecture and Design Assignment Nine—Kubernetes—Rubric 1. [15] Create database docker image, launch deployment and service, and describe service using kubectl. Show database logs via kubectl logs. Show database tables by connecting via Intellij Database tool. 2. [20] Launch deployment and service for microservice, and describe service using kubectl. Show microservice logs via kubectl logs. Show invocation of some query operations on microservice using web browser. Show health checks on microservice. 3. [20] Launch deployment and service for webapp, and describe service using kubectl. Show that webapp works using a web browser and use logs to show it is using the backend microservice. 4. [15] aunch deployment and service for REST web service, and describe service using kubectl. Test query operations using a web browser and show web service logs via kubectl logs. 5. [25] Add patients, providers and treatments via REST client, and show that these are added to the domain using the web application. 6. [5] Completed rubric Total:
Homework 8: Shapes Photo Album Part 1 Shapes Photo Album Part 1: The Model The Shapes Photo Album: Part 1 This assignment starts with a context of the application, followed by an outline of what you must achieve. It is a relatively open-ended assignment and does not spell out explicitly which interfaces, classes, methods and variables you need. Spend time understanding what the application must do, and then design your solution accordingly. This "open ended" approach is intentional, and allowing you freedom in your design decisions is important part of this assignment. Context Many of us use our phones (and cameras) to take pictures of friends and family members, and then share those pictures in photo albums - either online or in-person (with actual "photo books"). Pictures can be used to succinctly and effectively illustrate many things. For example, a stationary histogram visually depicts the distribution of some data points. A histogram with moving bar heights visually depicts music (e.g. a music equalizer). In the next two assignments, we will build an application that helps to create a simple "photo album" from shapes. One of our main goals will be to practice the "separation of concerns" we've covered during lecture. We will support the description of data we want visualized and then have an application that renders the descriptive text properly in a variety of ways. Concept Informally using English, we could provide a description for one page of our photo album in a way similar to this: Create red rectangle R with corner at (200,200), width 50 and height 100 Create blue oval C with center at (500,100), radius 60 and 30 R moves to (300,300) C moves to (500,400) C changes from blue to green Take a Snapshot R changes width from 50 to 25 These are descriptive commands that tell us, in sequence what things (shapes) to place on a logical canvas, where to place them, how to color (or resize) them, and when to "take a selfie" (snapshot) of the system. Our application may then use such a description to: • "Show" the photo album in various ways. Perhaps we simply want to view the sequence of changes in a spreadsheet, or perhaps we want to see each "snapshot" as a visual rendition of the shapes, on different pages of an electronic album. • Produce a verbose description for what the photo album will look like (for the visually impaired). • Other possibilities... The Shapes Photo Album We will build this application progressively using the classic Model-View-Controller architecture. In this assignment (Part 1) we will focus on the model of this application. There is no starter code for this assignment: you must use the above description and broad ideas to design the interface and implementation of the model. You are deliberately not being told about the specific details of what the controller and views will need or do. You are also not being told about how exactly the application will receive a description from the user (it would not be relevant to the model). Here are some aspects to think about: • What does the model represent? Remember: this is a shapes application, so think "application model" here. • The model should be able to support various kinds of 2D shapes, although currently we have described only rectangles and ovals. • The model should support adding various kinds of transformations to shapes, such as moving, changing color and scaling. • As you implement, remember to consider the client perspective (the person or class that is using the model). How is the photo album seen? One way the application may show the progression of creating the photo album is to produce a text description of the commands and the model state changes. Here is what a description might look like: Name: R Type: rectangle Min corner: (200.0,200.0), Width: 50.0, Height: 100.0, Color: (1.0,0.0,0.0) Name: O Type: oval Center: (500.0,100.0), X radius: 60.0, Y radius: 30.0, Color: (0.0,0.0,1.0) (NB: After moving and resizing and changing color of rectangle) Name: R Type: rectangle Min corner: (100.0,300.0), Width: 25.0, Height: 100.0, Color: (0.0,1.0,0.0) Name: O Type: oval Center: (500.0,100.0), X radius: 60.0, Y radius: 30.0, Color: (0.0,0.0,1.0)(NB: After moving Oval) Name: R Type: rectangle Min corner: (100.0,300.0), Width: 25.0, Height: 100.0, Color: (0.0,1.0,1.0) Name: O Type: oval Center: (500.0,400.0), X radius: 60.0, Y radius: 30.0, Color: (0.0,0.0,1.0) (NB: After removing the rectangle) Name: O Type: oval Center: (500.0,400.0), X radius: 60.0, Y radius: 30.0, Color: (0.0,0.0,1.0) (NB: Snapshots are similar to "still pictures" or selfies of the shape system) List of snapshots taken before reset: [2022-03- 30T11:51:02.174193, 2022-03-30T11:51:02.246661, 2022-03- 30T11:51:02.247210, 2022-03-30T11:51:02.247794] (NB: Snapshot details) Printing Snapshots Snapshot ID: 2022-03-30T11:51:02.174193 Timestamp: 30-03-2022 11:51:02 Description: After first selfie Shape Information: Name: R Type: rectangle Min corner: (200.0,200.0), Width: 50.0, Height: 100.0, Color: (1.0,0.0,0.0) Name: O Type: oval Center: (500.0,100.0), X radius: 60.0, Y radius: 30.0, Color: (0.0,0.0,1.0) Snapshot ID: 2022-03-30T11:51:02.246661 Timestamp: 30-03-2022 11:51:02 Description: 2nd selfie Shape Information: Name: R Type: rectangle Min corner: (100.0,300.0), Width: 25.0, Height: 100.0, Color: (0.0,1.0,0.0) Name: O Type: oval Center: (500.0,100.0), X radius: 60.0, Y radius: 30.0, Color: (0.0,0.0,1.0) Snapshot ID: 2022-03-30T11:51:02.247210 Timestamp: 30-03-2022 11:51:02 Description: Shape Information: Name: R Type: rectangle Min corner: (100.0,300.0), Width: 25.0, Height: 100.0, Color: (0.0,1.0,1.0) Name: O Type: oval Center: (500.0,400.0), X radius: 60.0, Y radius: 30.0, Color: (0.0,0.0,1.0) Snapshot ID: 2022-03-30T11:51:02.247794 Timestamp: 30-03-2022 11:51:02 Description: Selfie after removing the rectangle from the picture Shape Information: Name: O Type: oval Center: (500.0,400.0), X radius: 60.0, Y radius: 30.0, Color: (0.0,0.0,1.0) In short, it first describes the shapes that are part of the photo album and their details. Next it describes model state changes as the shapes are transformed/moved/removed. Each snapshot is a "freeze frame" of the model state - think of it as a "system selfie" - the picture captured is that of the shapes in their then-current locations (and state) and is analogous to a "page" in a photo album. You may think of the first part of this output as a “read-back” of the model state changes, perhaps for devices that cannot show the photo album visually, or for users who are visually impaired who have screen readers. The snapshots are historical "save points" that can be retrieved irrespective of the model state. What to do 1. Design a model to represent a shapes photo album. This model may consist of one or more interfaces, abstract classes, concrete classes, enums, etc. Consider carefully what operations it should support. Create a high-level UML class diagram to represent your design. 2. Think about and include in the model interface operations that you think are relevant and the model should offer. 3. Document your model well. Be sure to document clearly what each method does, what purpose it serves and why it belongs in the model. 4. Implement your model. 5. Test your model. 6. Implement the text output rendering of your model according to the format given in the previous section (How is the photo album seen?), so we can visualize your data. What to submit Submit any files created in this assignment, along with a text README file explaining your design, and your UML class diagram. Your README file and UML should give the graders quick insight into the purposes are for every class, interface, etc. that you include in your model. Verbosity is not a virtue here, so clear, concise documentation is better than reams of verbiage. Think of your graders as your users; help them so that they can quickly get a high-level overview of your solution and code. NB: The UML diagram and README do not replace the need for proper Javadoc! Grading Since this is an open-ended assignment with you making design trade-off decisions, there are no server-side tests. For this assignment, you will be graded on • the design of your model interface(s), in terms of clarity, flexibility, and how plausibly it will support needed functionality; • the appropriateness of your representation choices for the data (please comment on why you chose the representation you did in the code); • the forward thinking in your design, in terms of its flexibility, use of abstraction, etc. • the correctness and style. of your implementation, and • the comprehensiveness and relevance of your test coverage.
LI Econometrics Problem Set Week 8 1. An economist studying happiness is interested in the determinants of people’s well-being and life satisfaction, as measured by a composite happiness score. They collected data from a random sample of 600 individuals employed in Birmingham and estimated the following model: ln(Happyi ) = α + β1 ln(Incomei) + β2 Femalei + β3Marriedi + β4 SOCIi + β5 SOCIIi + β6 SOCIIIi + β7 SOCIVi + β8Educi + β9Agei + ϵi (1) where Happyi is the happiness score (out of 100), Incomei is annual income, Femalei is a dummy equal to one if i is female, Marriedi is a dummy equal to one if i is married, Educi is the number of years of education, and Agei is age. The sequence of dummy variables SOC are the Standard Occupational Classifiers used by the Office for National Statistics (ONS). SOCI indicates professionals, SOCII managers, SOCIII skilled workers and SOCIV semi-skilled workers. SOCV is the omitted category, indicating unskilled workers. Estimating this equation by OLS yielded RSS = 6.37 and ESS = 2.72. a) Excluding the SOC variables from the model and re-estimating yielded ESS = 2.48. Test the joint significance of the SOC variables. b) The model is re-estimated separately for the 278 men and the 322 women in the sample. Es-timating these two models yielded RSS of 3.13 and 3.02, respectively. Conduct a Chow test for a structural break between the two groups. Carefully write down the models you are estimat-ing and the null hypothesis you are testing. What do you conclude about the determinants of happiness for the two groups? c) Adding three multiplicative dummy variables to model 1 – Femalei×ln(Incomei), Femalei×Educi and Femalei × Agei – reduced the RSS to 6.18. Test the joint significance of these additional multiplicative variables. d) Compare the model estimated in c) with the two models estimated in b). Write down the restrictions you must impose on the models in b) to produce the model in c), and then test these restrictions. 2. An insurance company is interested in the relationship between the level of insurance premiums and the value of claims. They are particularly interested in the effect of a new premium structure introduced at the beginning of 2011. They use quarterly data from 1983:1 to 2010:4 (i.e. before the introduction of the new premium structure) to estimate: Claimst = β0 + β1 Premiumt + β2 Q1t + β3 Q2t + β4 Q3t + ϵt (2) where Claimst is the value of insurance claims per insured person, Premiumt is the average premium, and Qjt are three quarterly dummies indicating the first, second and third quarter of the year (the fourth quarter is omitted as baseline). These are the results they obtained: The RSS was 0.057, and the T SS was 4.140. The company then collected additional data for the first eight quarters after the introduction of the new premium structure. Suppose we add eight dummy variables to model 2, with D2011:1,t taking a value of one for the first quarter of 2011, D2011:2,t taking a value of one for the second quarter of 2011, and so on, with one dummy for each of the eight new quarters. This new model was re-estimated with the same data from 1983:1 to 2010:4 plus the new data from 2011:1 to 2012:4. The coefficients and standard errors on the eight dummy variables were as follows: a) What is the interpretation of each of the eight coefficients we have just estimated? b) In the model we have just estimated, what would be the coefficient and standard error on the variable Premiumt? What would the RSS be for the new model? Provide an explanation for your answers. c) Estimating model 2 using the complete data from 1983:1 to 2012:4 (without the eight dummies), gave an RSS of 0.065. Perform. a predictive failure test to check whether the old model 2 still accurately predicts claims under the new premium structure.
MPHY0020 MATLAB coursework 2025 Introduction and guidance The tasks for the coursework are described in detail below.They are related to the signal processing and data visualisation required for brain MRI. All the required mathematical formulas and algorithms are provided,but you willneed to implement these using MATLAB, thinking carefully about the steps needed to complete each task. When you submit your solution,you should: · Submit allthe .m files you created for this coursework. Include all functions and scripts. · Name the functions and scripts in such a way that it is clear what each function or script. does, e.g. MRI_process and Task1 for a function that processes the MRI and for the script for Task 1,respectively. · In addition, submit a text file that outlines which .m file corresponds to which task. · Combine all scripts and functions into a single .zip file and upload this single file to Moodle. · Include only your student number in the file name-do not include your name! Please note: · Do not submit graphics,videos and figures;instead ensure your codes generate the figures at run-time in exactly the way you wish them to look. Also do not submit the data sets. This MATLAB coursework accounts for 34% of the total course mark. Marks for this coursework willbe awarded using the following criteria: · Up to 60%will be based on whether your code correctly implements the methods and mathematics described for each task,and in addition produces the correct results and clear visualisations. · Upto 25%willbe based on how easy it is to understand and use your code. This includes the use of both internal and external comments,informative variable and function names,and clarity and structure of the code. · Upto 15%will be based on adhering to other good programming practices that you have learned about in the lectures,such as memory management,error checking, and vectorisation. Marks for implementation correctness will be awarded for each task individually (the marks available are indicated next to each task number),whereas the marks for clarity and good practice will be awarded based on your entire solution. Please be aware that submitted coursework will be compared for similarity with other s ubmitted coursework and code available elsewhere (e.g. on the internet). This does not prevent you from discussing the coursework with others or using the various sources of help mentioned in the lectures,it just means you have to devise and write your own code.Generative (or other)Al platforms must not be used to generate any of the codes you submit. Magnetic Resonance Imaging (MRI) is one of the most widely used medical imaging modalities, capable of generating high-resolution images of soft tissues without ionising radiation.Unlike ultrasound or X-ray imaging, which record signals directly in the spatial domain,MRI data is collected in the frequency domain, known as k-space.The final image is reconstructed from this k-space data by means of inverse Fourier transformation and subsequent processing steps. In this coursework,you willwork with both 2D and 3D MRI datasets in MATLAB,starting from raw k-space data and progressing toward full 3D image reconstruction, filtering, rotation correction,and segmentation. The tasks are designed to gradually introduce you to the principles of MRI signal processing, from simple Fourier reconstruction to segmentation of anatomical structures and tumours. Unless explicitly stated otherwise, allparameter values set in one task should be kept constant in subsequent tasks.Throughout,you are expected to ensure visualisations are informative in layout and appearance suitable for MRI data visualisation. Task 1 [10] MRI scanners acquire raw data in the spatial frequency domain(k-space). Each point in k-space corresponds to a spatial frequency component of the final image, and only after transformation into the image domain can anatomical structures be visualised. However, k- space itself is often inspected to understand the spatial distribution of signal energy and noise characteristics. For this task, please download the dataset "kspace_single_slice.mat"from Moodle,which contains the raw k-space for a single MRI slice. You should write a MATLAB script that loads this dataset into the workspace and displays the magnitude of the k-space values. To improve interpretability,you should apply a logarithmic transform by computing L=|log10 E|, where L(in dB)is the log-compressed result of the k-space data E.The image should be displayed with a suitable colormap with 20 dB dynamic range. A colour bar should be displayed next to your image. Importantly, the axes of k-space should not simply be shown as pixel indices, but instead converted into spatial frequency coordinates in mm⁻¹. To do this, you must use the pixel spacing values provided. For this dataset,△x=△y=0.43mm. The frequency axes are obtained by computing: Where FOVxand FOVy are the field of view in millimetre,Nx and Ny are the image matrix dimensions in pixels,Δx and Δy are the pixel spacings in millimetres,and kxand ky are the spatial frequency axes in mm⁻¹. Task 2 [15] Whilst k-space is informative,it cannot be directly interpreted by clinicians.A more clinically meaningful image can be obtained by reconstructing the data into the spatial domain through the inverse Fourier transform.The second task will therefore focus on image reconstruction from the k-space dataset considered in Task 1. For this task,write a script that reconstructs the MRI image.The script should process the complex k-space array from Task 1 into a reconstructed image.Your script should implement a two-dimensional inverse Fourier transform on the k-space data,scale the image so that the maximum pixel value of the image equals 1,and display the image. Task 3 [20] MRI k-space filtering allows us to selectively preserve or suppress spatial frequency components in the reconstruction.The central region of k-space corresponds to low frequencies,and contains mostly information on image contrast and gross anatomical features, while the edges of k-space contain high frequencies responsible for fine structural details.By applying low-pass filtering,high-frequency detail is suppressed,resulting in a smoother but blurrier image.Conversely,high-pass filtering suppresses the central,low-frequency content, resulting in edge-enhancement but with reduced overall contrast. In this task,you will write a MATLAB function that applies a circular spectral filter to k-space data and reconstructs the corresponding image.The function should be able to read a raw k- space dataset,allow the user to select the filter type (low-pass,high-pass,or no filter),and specify the cut-off frequency.The cut-off frequency should be normalised between 0 and 1, where O corresponds to the centre of k-space and 1 corresponds to the outermost frequency Inside the function,you should generate a binary mask in the shape of a circle,centred at the origin of k-space.For the low-pass case,the mask should retain all k-space values inside the circle (blanking out values outside).For the high-pass case,the opposite should be done, retaining values outside the circle and blanking out the centre.The function should then inverse Fourier transform the filtered k-space data into the image domain,and the magnitude of the resulting image should be normalised such that its maximum pixel value is equal to 1. The function should return this reconstructed image and it's corresponding filtered k-space data. In a separate script,you should load the single-slice k-space dataset,call your function three times to generate: 1.The unfiltered reconstruction (for comparison). 2.The low-pass filtered reconstruction,with normalised cut-off spatial frequency of 0.1. 3.The high-pass filtered reconstruction,with normalised cut-off spatial frequency of 0.01. Finally,display the reconstructed MRI image with its corresponding filtered k-space image in a single 6-panel figure window using subplots.Sample outputs are shown below,but other layouts are acceptable. Figure 1. Up until now you have considered only a single two-dimensional slice.However,MRI data is inherently volumetric,and three-dimensional acquisitions allow structures such as the brain to be visualised in multiple planes.For this task, download the dataset "kspace3D_tumour.mat"from Moodle,which contains a full 3D k-space acquisition of a head with an embedded tumour. Write a script that loads this dataset,and applies a 3D fast inverse Fourier transform to form the 3D volume.From the reconstructed 3D volume,display three orthogonal slices centred within the image volume in one axis.Ensure your visualisation has the correct appearance and is not spatially distorted. Task 5 [15] In some cases,MRI data may not be perfectly aligned with the imaging axes due to patient positioning or scanner calibration.As a result,the reconstructed volume may appear rotated for each axial slice,as in the 3D MRI data used in task 4.As such,subsequent analysis (such as segmentation)may be inaccurate. For this task,you should correct the orientation of the reconstructed brain volume from Task 4.You should determine the appropriate transformation (e.g.,imrotate or interp3)to undo the rotation using 15°off-set for each axial slice.Finally,display the corrected data again in a visualisation matching that for Task 4. Task 6[20] Segmentation of tumours in MRI volumes is an essential step in medical image analysis, supporting both clinical assessment and quantitative studies.One intuitive approach is to use the pixel intensity distribution to identify the tumour.Typically,tumour tissue exhibits intensity values that are distinct from surrounding brain tissue.Histogram analysis can help identify an appropriate threshold for segmentation. For this task,you will first work with a single slice,and then extend the segmentation to the full 3D volume.Write a single script. to perform. both parts of this task,and a function to compute the Dice coefficient explained below. Step 1:Single-slice segmentation 1.Select a representative slice from the de-rotated 3D reconstructed volume from task 5;for this task,use slice number 15(axial plane,figure 2). Figure 2. 2.Plot the histogram of pixel intensities in this slice.Examine the histogram to identify an intensity range corresponding to the tumour,and annotate the selected pixel value range onto the histogram,for instance using the ‘xline'command.Other annotation styles are acceptable. 3.Apply thresholding to generate a binary mask for the tumour in this slice:pixels within the chosen intensity range should be assigned a value of 1(tumour),and all others should be 0(background). 4.To clearly visualise the segmentation result,overlay the binary tumour mask on top of the original grayscale MRI slice using a different colour (eg.Figure 3).This allows the tumour region to be highlighted while preserving visibility of the underlying anatomical structures.Sample outputs are shown below,but other visualisations are acceptable. 5.Display the histogram,tumour binary mask,and overlayed image in multiple planes within a single figure window using subplots. Figure 3. Step 2:3D volume segmentation 1.Extend your thresholding approach to the full de-rotated 3D reconstructed MRI volume from task 5.Examine the histogram of the voxel intensity in this 3D volume and annotate the selected pixel value range onto the histogram.Apply the intensity threshold across the entire 3D volume to generate a 3D binary mask representing the tumour. 2.Download the file“ground_truth.mat”,which contains the ground-truth 3D tumour mask,from Moodle.Write a function to compare your 3D segmented tumour mask with the ground-truth mask and compute the Dice coefficient,and have your script display the Dice result in the command window in an elegant fashion.This Dice coefficient measures the similarity between two 3D binary volumes.It is defined as twice the number of overlapping voxels divided by the total number of voxels in both volumes combined.A Dice coefficient of 1 indicates perfect overlap,while 0 indicates no overlap.Mathematically,for two binary masks A and B,the Dice coefficient is calculated as: where |A|and |B|are the number of voxels in each mask,and |A∩B|is the number of voxels where both masks overlap. 3.Render the tumour as a 3D volume using MATLAB's volume visualisation tools such as 'volshow’,'isosurface',or'patch'.Other appropriate approaches are acceptable.The 3D rendering should clearly display the spatial extent of the tumour within the brain, allowing intuitive appreciation of its shape and location.Ensure you manipulate transparency,colour,and lighting to achieve an informative and pleasing visualisation. Task 7 [10]-Level 7 students only! In addition to tumour segmentation,MRI can be used to study the internal structure of the brain.Different anatomical regions,such as grey matter,white matter,cerebrospinal fluid,and bone,often exhibit distinct intensity characteristics in T1-or T2-weighted images.Accurate segmentation of these regions is important forquantitative neuroimaging,volumetric analysis, and functional studies. For this task,you will segment multiple head MRI regions on axial slice number 15 from the de-rotated 3D reconstructed volume from Task 5.Depending on the intensity values,multiple thresholds may be required to separate the following four anatomical features;skull,tumour, brain,and subarachnoid space (see Fig.4 which highlights these anatomical features).In this task,write a script to perform binary segmentation,as in Task 6,to generate initial masks for each structure.Once the masks are created,apply morphological image processing operations to refine the segmentation and produce clear boundaries for each region.Accuracy is not the primary concern;the focus is on obtaining visually distinct structures. Finally,assign distinct labels or colours to each segmented region(bone,tumour,brain,and subarachnoid space),so that all structures can be visualised simultaneously.You may either overlay the masks on the original MRI slice or draw the boundaries using contours.Ensure that your visualisation clearly indicates which segmentation corresponds to each anatomical structure.Sample outputs are provided below,but othervisualisations are acceptable-as long as your result clearly distinguishes and displays each region. Figure 4. Red: bone; green: subarachnoid space; blue: brain; pink: tumour.
2025-2026, Term 1 PSY4101 Assignment 2 (individual work): Data analysis problem set Submit ONE SOFTCOPY (AS A PDF FILE) ON TURNITIN Instructions - Write/Type your name and student ID clearly in your submission. - Mark the problem number and subpart number clearly for each answer you provide. - Your answers can be handwritten, word-processed (e.g., using Google Docs or MS Word), or in a mix of both. For handwritten answers, please make sure your handwriting is legible. - For all questions related to null-hypothesis significance tests (NHST), set α = 0.05 unless otherwise specified. - Please ensure that all numerical answers are rounded to three decimal places. - For each analysis in jamovi, please provide the syntax generated from jamovi (jamovi user guide for enabling syntax mode). This syntax allows us to trace your analysis, so that, if you make an error, we can identify the type of error and give you partial credit if possible. - Use of generative AI declaration (Write statements (see Section B of the notes on assessment items for details) below regardless of whether or not you have used AI in any parts of your work. If you have used any generative artificial intelligence (AI) (e.g., software supported by large language models or LMMs such as ChatGPT) in any part of your work, please include a “use of generative AI statement” at the end of your work to declare when, where, how, and how much you have used them in your work. - Using generative AI per se does not result in any penalty, but failure to appropriately and adequately acknowledge the use of it could be regarded as plagiarism. If you use generative AI in your work, the more details you include in your statement, the less likely you will face such a penalty. Below are some example statements: “I asked ChatGPT questions about the topic, and it gave me a list of readings to start with. Below are the questions I asked ChatGPT and the answers given by ChatGPT…” “I used generative AI to improve my writing / check for grammatical errors / get suggestions of words/expressions only after I had written the first draft all by myself.” “I did not use any generative AI in any part of this work.” Please insert your use of generative AI declaration in the box below: IMPORTANT: 50% of your final mark will be deducted if the statements are not included Assignment Scoring Instructions: - Please note that the total score for this assignment is 125%. However, we will cap the maximum score at 100%. This means that if your score exceeds 100%, it will be recorded as 100%. If your score is 100% or below, it will be recorded as is. - This structure provides you with "extra room" to earn points, not "extra points." It is meant to encourage you to do your best with less pressure of losing points. Problem 1 (50%) Pat is an analyst at a teaching-quality unit of a university and is interested in finding out the factors affecting students’ performance in exams. Specifically, Pat would like to study how personality (measured based on the Big-Five scale), behavior. before exam (measured as the number of hours spent on revision before an exam), and emotion before exam (measured as anxiety level) may influence a student’s exam performance (measured as exam scores). The dataset contains questionnaire data from a sample of 103 students. Dataset for Problem 1: Problem 1_data.omv A. (30%) One of Pat’s original hypotheses was that anxiety is a significant predictor of exam scores even after the effects of personality have been controlled for. To test this hypothesis, first conduct a linear regression with exam scores being the outcome and all 5 personality scores as the predictors. i. (6%) For each of the following assumptions of linear regression, state whether there is any evidence that the assumption was violated in this regression analysis. Report relevant statistics and/or figures to support your answer. If the assumption was violated, justify whether we should proceed with the analysis. a. (3%) the linear-independence assumption b. (3%) the normality assumption ii. (4%) Write down the regression equation with the coefficient estimates. iii. (5%) Which personality factor yielded the smallest p value as a predictor in this model? Test whether this factor significantly predicted exam performance and write a sentence to interpret the regression coefficient of this predictor. iv. (5%) Did the model have significant explanatory power on exam scores? Write a sentence to report how much variability in exam scores was explained by personality and test whether it was significant. Now, insert anxiety into the model with the 5 personality factors already included in the model. v. (6%) Did anxiety provide any additional explanatory power, over and above personality, in predicting exam performance? Test this and report the results in no more than 2 sentences. vi. (4%) Given the regression results above, what would you expect to see if you extract the part (aka semipartial) correlation between anxiety and exam scores with personality factors being partialed out? Briefly explain your expectation and verify it using jamovi. B. (20%) Before collecting the data, Pat had two other hypotheses, which are stated below. For each of the hypotheses, conduct an appropriate analysis and write a short paragraph in a “result-section” style. (with relevant statistics and/or graph(s)) to support your answer. i. (10%) Pat hypothesized that revision duration would moderate the effect of anxiety on exam performance by weakening the effect of anxiety on exam performance. Include a simple-slope analysis to interpret how revision duration moderated the relationship between anxiety and exam performance. ii. (10%) To explain how neuroticism influences revision duration, Pat hypothesizes that anxiety is a mediator. Report whether the mediation is complete or partial, and whether it is consistent or inconsistent. Problem 2 (40%) Charlie is interested in the genetic and environmental effects on the body metrics on newborns and collected data from a sample of 42 cases of newborns, including body metrics of each newborn such as body length, birth weight, head circumference, possible sources of genetic influence such as father’s and mother’s heights, and other environmental factors such as father’s years of education. One key factor that Charlie wanted to focus on was the smoking habit of the parents, especially the mother’s. Charlie hypothesized that a mother’s smoking habit has a negative effect on her newborn’s body metrics. Dataset for Problem 2: Problem 2_data.omv A. (12%) Charlie wondered whether the newborn’s body metrics are influenced by a gene-and-environment interaction. Specifically, head circumference could be the result of an interaction between the daily number of cigarettes smoked by the mother and the mother’s height. Conduct an appropriate analysis with the genetic variable as the original predictor in the model to test this hypothesis. Report your results in a short paragraph, including the interpretation of the coefficient of the interaction effect, supported by a simple-slope analysis. B. (18%) Charlie would like to find out what factors affect the daily number of cigarettes smoked by the mother as it seems to be an important environmental factor. Charlie noticed that the numbers of cigarettes smoked by the mother and father seem to be correlated, and a potential mediator could be the father’s years of education. i. (12%) Conduct an analysis to test this hypothesis, and write a short paragraph in “result-section” style. (with relevant statistics and/or graph(s)) to support your answer. Report whether the mediation is complete or partial, and whether it is consistent or inconsistent. ii. (6%) How strong does the result from this mediation analysis support a causal relationship among the predictor, mediator, and the outcome? Write a few sentences to justify your answer. C. (10%) One of Charlie’s specific hypotheses was that the newborn’s birth weight would be lower for a smoking mother than that for a non-smoking mother, after controlling for genetic factors. i. (5%) Test the above hypothesis using an appropriate analysis with father’s and mother’s heights being the two genetic factors to be controlled for. Report your results in a short paragraph. ii. (2%) Write a sentence to interpret the regression intercept. iii. (3%) Write a sentence to interpret the regression coefficient of the binary variable of “smoker” (0=non-smoker, 1=smoker) in the full model. Problem 3 (35%) You are a research assistant in the Department of Psychology at a large university. The department is conducting a study to understand the factors that influence students' academic performance, specifically their GPA. The university administration is particularly interested in how students' study habits and socioeconomic backgrounds impact their academic success, beyond their prior academic achievement. To carry out this study, you have access to a dataset from a recent survey of undergraduate students. The survey collected information on their GPA, HKDSE scores, English test scores (IELTS), study habits, and socioeconomic status. The variables available in the dataset are: ● GPA: The students' current college GPA (on a 4.0 scale). ● HKDSE: Best 5 scores ● IELTS: score of IELTS (Max score = 9). ● StudyHours: Average number of study hours per week. ● StudyEnv: Quality of the study environment, rated on a scale from 1 (poor) to 10 (excellent). ● FamilyIncome: Family's annual income (in HKD1,000 units). ● ParentsEdu: Parents' highest education level, coded as follows: ● 1: Primary School or below ● 2: Secondary School ● 3: High diploma or Associate degree ● 4: Bachelor's degree ● 5: Master's degree or above Dataset for Problem 3: Problem3_data.omv Note: This dataset is not real and is used for assignment purposes only. A. The department has tasked you with analyzing this data to identify the key predictors of GPA. Specifically, they want you to control for prior academic achievement (HKDSE) and language ability (IELTS scores) and then test the additional impact of study habits (Quality of the study environment, study hours) and socioeconomic status (family income and parent’s education level). i. (10%) Conduct a multiple regression analysis to determine whether GPA is predicted by previous test scores, i.e., HKDSE and IELTS scores. a. (4%) How much of the variance in GPA can be explained by HKDSE and IELTS scores? Report the F-statistic and p-value for the overall model. b. (6%) Whether each of the predictors (HKDSE and IELTS scores) significantly predict GPA? Report the findings for each predictor and write a sentence to interpret the regression coefficients of the significant predictor(s). ii. (20%) Extend your analysis by including additional predictors related to study habits and socioeconomic status into the existing regression model. a. (4%) How much of the variance in GPA can be explained by all predictors? Report the F-statistic and p-value for the new model. b. (4%) After accounting for HKDSE and IELTS scores, did study habits and socioeconomic status significantly improve the prediction of college GPA? Write a sentence to report how much variability in GPA was explained by habits and socioeconomic status and test whether it was significant. c. (12%) In the final model with all predictors included, does each of the study habit and socioeconomic status variables significantly predict GPA with other test scores (HKDSE & IELTS) already in the model? Report the findings for each of these predictors and write a sentence to interpret the regression coefficients of the significant predictor(s). iii. (5%) Some argue that family income and parents' education may be highly correlated, potentially affecting the results due to one of the assumptions of multiple linear regression models. Which of the assumptions of multiple linear regression relates to this concern? Conduct appropriate test(s) to assess and address this concern.