A. Briefly describe the three main types of errors you encountered while working with Python:
Add one example for each of them in your description. [200 words maximum]
Model answer:
B. The code below computes an average test score from a series of individual tests carried out on a generic item of a certain production line (e.g., car components or appliances). Each test yields an integer number from 0 to 10. If the average score is >= 8, and if no individual score is below 5, the item is accepted for further processing; otherwise it is discarded.
The code below implements this computation, but has three errors. Identify the 3 errors (use the line numbers as reference) and explain briefly how to fix them.
Model answer:
C. Select which of the following 3 statements are TRUE concerning assertions and exceptions? (you can select more than one statement)
Remember, the generic assertion statement is defined as follows:
Model answer:
D. What will happen when running this piece of code?
(select only one answer)
Model answer:
Consider the code below, defining a generic Rocket class:
E. Identify the following (you may use the line numbers as a reference):
Model answer:
F. What will happen when running the code in lines 21-22? (select only one answer)
Model answer:
G. Imagine the Rocket class is now contained in a module named space.py. Which of the following are correct import statements? (you may select more than one statement)
Model answer:
In the space below, describe the key steps that would be required to create a continuous parametric probability distribution that represents annual maximum wave height. State your assumptions, then list your analysis steps (be brief!), followed by a statement about whether or not there may be any limitations to this approach. An outline of what your answer should look like is shown here:
State assumptions (2 sentences max for this item)
State limitations (2 sentences max for this item)
Model answer:
X and Y are two (unit-less) quantities that have been measured in the lab in order to investigate certain properties. Rather than using a ‘standard’ parametric distribution, theoretical cumulative distribution
functions for X and Y have been fitted satisfactorily to datao btained after many years of measurements.
These are given by $F_X(x)$ and $F_Y(y)$ below:
A. What is $P(X ≤ −0.99)$?
Model answer:
$P(x≤−0.99)=F_X(−0.99)=(−0.99+1)/2=0.005$
B. What is the design value of Y?
Model answer:
A certain group of engineers want to design for values of Y with exceedance probability of 0.001. That is $P(Y>y)=0.001$. Assume X and Y are independent.
C. What is $P(X≤−0.1,Y≤1)$? (approximate using at least 4 decimal places)
Model answer:
Independent, $P(X≤−0.1,Y≤1)=P(X≤−0.1)P(Y≤1)=0.45∗0.6321=0.2845$
D. What is $P(X>0.8∣Y>10)$?
Model answer:
Independent, $P(X>0.8│Y>10)=P(X>0.8)=0.1$
As it turns out, the joint cumulative distribution of X and Y (denoted as FXY) has also been approximated from measurements with sufficient accuracy and is given:
E. What is $P(X>0.8,Y>4.6)$ in the case the joint distribution is as above? (approximate using at least 4 decimal places)
Model answer:
$P(X>0.8,Y>4.6)=1−P(X<0.8)−P(Y<4.6)+P(X<0.8,Y<4.6)=1−0.9−0.9899+0.8918=0.0019$
A csv-file is used to create a pandas dataframe, df. The command df.describe() returns the following:
A. Based on the data summary above, which of the following distributions would be a good first choice to represent the data?
Model answer:
B. Which of the following is a suitable justification for your answer to the previous question?
Model answer:
C. You decide to use the Gumbel distribution to fit the data. Compute the distribution parameters using the data summary above
$\beta = 112.8$ & $\alpha =147.7$ for $\gamma = 0.5772$
A. Assume you are given an assignment to model a specific system of interest (could be any system). To model it, you need to make some assumptions. Among the many criteria and constraints at stake, what is the main criteria that should drive your decision process to make such assumptions? (choose one answer)
Model answer:
B. When would you need to work on an inverse problem? (choose one answer)
Model answer:
C. As engineer and scientist, what should be our final goal after we develop a model? (choose one answer)
Model answer:
A. Using Taylor expansion, derive the forward Euler approximation for the first derivative. Show the truncation error introduced by the approximation.
Model answer:
B. Derive the discrete form of the following ODE using the forward Euler approximation and calculate first 5 timesteps of the solution using dt = 0.2:
Model answer:
C. A colleague proposes using the backward Euler method. List one advantage and one disadvantage of this approach compared to forward Euler.
Model answer:
We can use two instruments to measure the water level at a given location and time. In the following, you may assume that all measurements are independent and the water level does not change between subsequent measurements. Instrument A has precision of 3 mm, instrument B has a precision of 8 mm.
A. It needs to be decided whether to take one measurement with the most precise instrument (option 1), or we take one measurement with each instrument and estimate the water level from both measurements (option 2). By how much will the precision of the estimated water level improve or deteriorate if option 2 is used instead of option 1?
Model answer:
B. Instrument A is expensive and complex to use, whereas instrument B is cheap and simple to use. One of the instruments must be selected for future use. Therefore it is assessed how many measurements are needed with each instrument to obtain an acceptable precision. What will be the 99% confidence interval of the estimated water level if we use 4 repeated measurements to estimate the water level with instrument A? And how many measurements do we need to take with instrument B to obtain at least the same (or tighter) confidence interval?
Model answer:
Once per month the height of a fixed benchmark site on a volcano is determined using GNSS. The volcanologist uses as a null hypothesis that the height is constant. After 6 months (i.e., using 6 observations), she wants to test her hypothesis with the overall model test and a probability of false alarm of 0.025.
A. What would be the threshold value she needs to use?
Model answer:
For degrees of freedom use $q=m−n=6−1=5$, with $\alpha=0.025$ the threshold value from the table (Central $\chi ^2$-distribution) follows as $12.8325$.
B. Assume the null hypothesis is rejected. The volcanologist now wants to test whether a sudden height change occurred at a certain time $t_c$ after the first observation at $t_0$ (i.e., height is constant before $t_c$, then changes at $t_c$ and after that remains constant again). Specify the hypotheses and describe a testing procedure which allows to identify whether such deformation occurred and at which time it did. No need to do any calculations.
Recursive w-test: calculate absolute value of $w$-test statistic with each $C_i$, the alternative hypothesis with maximum value is accepted IF it exceeds the threshold value.
We are interested in modelling the local weather and decide to build a discrete-state, discrete-time Markov chain model for this purpose. We start simple by building an hour-by-hour simulator,in which we distinguish between 3 types of weather as process states:
We formulate the probabilities of the future state Sn+1 = {Sn+11, Sn+12, Sn+13} at time $n+1$ (not an exponent) using the following equation:
Using historic weather data for the same month as weare interested in, we can conclude the following:
While having breakfast between 7:00 and 8:00 you observe a clear sky.
A. Based on the observations above, build the Markov transition matrix T for this given weather data.
Model asnwer:
B. Evaluate the probability that it rains between 9:00 and 10:00.
Model asnwer:
We are interested in the probability of state S3 at time 9, given the state S1 at time 7:
C. Explain how Monte Carlo simulation can be used to predict the probability that there will be rain at some point in the afternoon (between 12:00 and 18:00), given your observations at breakfast. In your answer, identify the model, the model input and the model output, as well as the place of the Markov chain in this simulation.
Model answer:
There are different variations possible to answer this question, particularly in the definition of the model and input. Here is one possible answer:
Starting from the framework of [INPUT]--> [MODEL] --> [OUTPUT], we can define the model as the predictor of rain or no rain (TRUE/FALSE) in the afternoon.
The INPUT of the model is the weather pattern for the day, which can be sampled using the Markov chain sampler, starting from the observation in the morning. This means the input is a (sample from a) stochastic process, which therefore contains uncertainty. (+1, +1)
The OUTPUT of the model is boolean or binary, indicating the occurrence of rain in the afternoon (TRUE/FALSE) of (1/0). (+1)
The MODEL is the interpretation of the weather pattern: the check if there is rain between 12:00 and 18:00 in the afternoon. (+1)
Because there is uncertainty in the input (in the weather pattern for the day), there will be uncertainty in the output. The likelihood of rain in the afternoon is a measure of this uncertainty. Monte Carlo simulationcan be used to quantify the uncertainty in the output of models as an effect of uncertainty in the input by repeated evaluation of the model for input samples, followed by a statistical evaluation of the output.
In particular, the likelihood of rain in the afternoon can be evaluated by sampling many (N) weather patterns as model input and evaluating the number of times it rains in the afternoon N_rain. The ratio N_rain/N is an estimation of the likelihood of rain in the afternoon. (+1)
Alternatively, the Markov chain sampler can be formulated as part of the model, but this would imply that the input of the model is deterministic and the output is stochastic, i.e. the uncertainty is in the model itself. This can still be solved with Monte Carlo analysis, and the procedure is identical, but the concept of the propagation of uncertainty is lost.
D. Explain how you can evaluate the average number of hours of rain per day using your model.
Model answer:
Answer example 1: Simulate a Markov process for a very long time (e.g. N = 10.000 hours) and count the number of times n the rain state appears in this series. The average number of hours rain per day is then calculated as n/N*24 hours.
Answer example 2: Start from a certain probability state. Evaluate the probability of the next state , where is the Markov transition matrix, in a loop until the probability converges to a steady state .The probability it rains at any given hour is given by component . The average number of hours of rain in a day is given as.
Answer example 3: Simulate many (e.g. N=1000) separate and independent Markov processes of 24 hour length. This simulation should have a burn-in period (e.g. 124-hours and ignore the first 100) to be independent. Count the number of hours of rain for each of the 24-hour processes. Take the average of the counted numbers of hours.
E. Which of the following stochastic processes can be used for this model of rain intensity? (multiple answers possible)
Model asnwer: