MATH6005/6182 Assignment 1
MATH6005: Worth 20%
MATH6182: Worth 20% Submission date: 18th November, 2024 Rules
You must work on your own on this assignment with no help from others or GenAI.
- You must submit a single Jupyter notebook file as a submission.
- Clearly indicate your name and student number on the code. Save the file with your studentnumber, e.g student number.ipynb
- Ensure that your code is clean, well-structured, and free of errors. Non-functioning codes will bepenalized.
Problem 1 (40 marks) he electricity consumption in a household is modeled as follows:U(t) = (B + C(t) + f(A, t)) × F(t)where B represents the minimum base usageindependent of other factors, C(t) is the dynamic electricityconsumption based on the daily temperature, defined as C(t) = −κ · T[t], with κ with κ being a constant
and T[t] the temperature (◦C) on day t, f(A, t) 代写MATH6005/6182 probability of rainfall models the electricity consumption based on the number of
occupants A, defined as f(A, t) = A · (uM + UE + Uof f ), where uM is the occupant usage during morningpeak hours (6am–9am), uE is the usage during evening peak hours (6pm - 10pm) and uof f is the usage atoff-peak hours and F(t) is the daily adjustment factor, set as 1.2on weekdays and 0.8 on weekends. Giventhe following parametersB = 50kW h; k = 0.1, A = 5, uM = 1.5kWh, uE = 2.0kW h and uof f = 0.5kW h Simulate a random dataset for daily temperature T[t] over 28 days, with a mean of 20◦C and a standarddeviation of 10◦C. Take the first day to be a Monday.
- Calculate and print the daily electricity consumption for each of the 28 days.
- Use matplotlib to plot a graph of electricity consumption over the 28-day period.
- Analyze the average electricity usage by days of the week and produce a bar chart of the results.
- Compare electricity consumption between weekdays and weekends, and discuss any noticeable differences.Problem 2 (20 marks) The iterative formula for finding the roots of an equation is given byxk+1 = xk − f(xk)10f ′(xk)− f ′ (xk)600f ′′(xk), where f ′ (x) is the first derivative of f(x) and f ′′(x) is the second derivative of f(x). The function to besolved is:f(x) = 2x 2 + 3sin(x) − 4 exp(0.5x) +ln(x). Starting with k = 1, the initial guess initial guess x1 = 2.0 and stopping criterion |xk+1 − xk| < 10−6 ,
- Find the roots of the equation f(x) = 0 using the formula provided.
- Report the number of iterations required for the method to converge to a solution.
- Plot the graph of |xk+1 − xk| against the number of iterations.
- Using different starting points, analyze the performance of the method. Identify at least one startingpoint where the method fails to converge and explain the behavior observed.
Problem 3 (40 marks)
The formula for calculating the probability of rainfall in a city is given by:P(rain) =1
1 + exp(−(a · tmax + b · tmin + c · af − d · sun)), where tmax is the mean monthly maximum temperature, tmin is the mean monthly minimum temperature,af is the number of air frost days recorded in the month, sun is the total sunshine duration (in hours), anda,b,c,d are coefficients representing the impact of each variable on the probability of rainfall, with valuesa = 0.05, b = 0.04, c = 0.03 and d = 0.02, respectively. Using the provided weather data.csv dataset,perform the following tasks:
- Calculate the average probability of rainfall in London, Manchester and Southampton for the year
- Identify the city with the highest probability of rainfall in 2023.
- Plot a bar chart showing the monthly rainfall probability trends in Southampton for the year 2022.
- Plot the graph of Liverpool’s average annual rainfall probability between 2020 and 2023.