Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Data segments Fraction of the data points between - 2 . 6 and 3 . 1 inclusively Does the segment have the symptom? - 4
Data segments Fraction of the data points between and inclusively Does the segment have the symptom?
False
False
True
Note: Both and in the data segment are counted. True
True
False
True
True
False
Note that the algorithmic parameters segmentlen, interval and threshold may take on different values in different tests.
After computing whether each complete segment has the symptom, we can summarise the results in a Python list of Boolean values. We will refer to this list using the variable name disorderstatus where disorder means the symptom is present. For the flowrate data in the sample code, the variable disorderstatus is:
disorderstatus False False, True, True, True, False, True, True, False
Note that there are elements in disorderstatus and they correspond to the complete segments in the given flowrate. Note also that you can obtain disorderstatus from the rightmost column in the table above.
The next part of the computation is to determine the episodes from the variable disorderstatus.
Determining the episodes
An episode is formed by consecutive segments that have symptoms and an episode must have a minimum number of segments. The algorithmic parameter minsegment specifies the minimum number of segments an episode must have. The value of minsegment is in the sample code but its value can change from test to test.
The determination of the episodes requires only two variables: disorderstatus and minsegment. For minsegment equals to the variable disorderstatus given above has two episodes, which are highlighted by the orange colour:
False False, True, True, True, False, True, True, False
The first episode starts in the third segment corresponding to a Python list index of and a duration of segments. The second episode starts in the seventh segment corresponding to a Python list index of and a duration of segments. We will summarise the information on the episodes by using a list of lists as follows:
The first list corresponds to the first episode. The first element in is the Python list index of the segment that the episode begins and the second element is the number of segments in the episode. Similarly for the second list. The variable episodes, in the last line of the sample code above is expected to take on the value of this list of lists.
Let us consider the case where the variable minsegment has the value of instead. Then, in this case, the variable disorderstatus given above has only one episode, which is highlighted by the orange colour:
False False, True, True, True, False, True, True, False
This is because each episode is now required to have at least segments. We will summarise the information on the episodes by using a list of lists as follows:
If we further increase the variable minsegment to the value of then there are no episodes in the variable disorderstatus given above. In this case, we summarise the information on the episodes by using an empty list, ie
Validity checks
The description above shows how the data flowrate and algorithmic parameters segmentlen, interval, threshold, minsegment are used to compute the episodes. Note that the algorithmic parameters must be valid so that the computation can be carried out. We require that your code performs a number of validity checks before computing the episodes. For example, the algorithmic parameter segmentlen must be a positive integer greater than or equal to for it to be valid, otherwise it is not valid. The following table state the requirements for the algorithmic parameters to be valid and what assumptions you can make when testing.
Algorithmic parameters Requirements for the parameter to be valid Assumptions you can make when testing
segmentlen A positive integer greater than or equal to You can assume that, when we test your code, the given segmentlen is always a number int or float
In other words, the given segmentlen cannot be of data type str list e
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started