1. Programming Assignment | Week 12
The Pearson correlation coefficient is a measure of association between two sets of data. In this problem, the data shall be represented as vectors (lists) X and Y. The formula for computing the coefficient is given below:
Xi corresponds to the element X[0] in the list X. We have used zero-indexing here.
Write a function named pearson that accepts two vectors X and Y as arguments and returns the Pearson correlation coefficient between them.
To help you with the computation, some functions have already been defined in the prefix code. You can write the entire function by just using the pre-defined functions. This is an important exercise that will help you in future projects when you start working with libraries.
You do not have to accept the input from the user or print output to the console. You just have to write the function definition.
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 1 2 3 4 5 6 7 8 9
1 2 3 2 3 4 3 4 5 | 0.89 | 0.89\n
| Passed after ignoring Presentation Error |
Test Case 2 | 1 2 3 4 5 6 7 8 9 10
-1 -2 -3 -4 -5 -1 -2 -3 -4 -5 | -0.49 | -0.49\n
| Passed after ignoring Presentation Error |
2. Programming Assignment | Week 12
A square metal plate in 2D space is the setup we are going to work with. The spatial extent of the metal plate is given by:
0 ≤ x,y ≤ 5
The temperature at any point (x,y) on the plate is given by the following equation. The temperature is measured in Celsius and can be negative:
f(x,y) = 30 + x2 + y2 − 3x − 4y
A micro-organism lives on the surface of the metal plate. It occupies only those points on the plate where both the coordinates are integers. The organism cannot survive in high temperatures and instinctively moves to regions of low temperature that are less or equal to a threshold T. If no such region is found, it can't survive. The terms high and low are used in a relative sense and should be compared with respect to the threshold.
Write a function named survival that accepts the value of T as argument and returns True if the organism can survive on the metal plate, and False otherwise.
You do not have to accept input from the user or print the output to the console. You just have to write the function definition.
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 30 | True | True\n
| Passed after ignoring Presentation Error |
Test Case 2 | 10 | False | False\n
| Passed after ignoring Presentation Error |
3. Programming Assignment | Week 12
Write a function named std_dev that accepts a list of real numbers X as argument. It should return the standard deviation of the points given by the following formula:
Here, Xi refers to the element X[i] in the list and X refers to the arithmetic mean of the numbers in X. Try to use list-comprehension wherever possible. However, we won't be evaluating you on this.
You do not have to accept the input from the user or print output to the console. You just have to write the function definition.
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 1,2,3,4,5,6,7,8,9 | 2.74 | 2.74\n
| Passed after ignoring Presentation Error |
Test Case 2 | 124,1124,-1342,-214,-153,-215,-15 | 721.94 | 721.94\n
| Passed after ignoring Presentation Error |
No comments:
Post a Comment
Keep your comments reader friendly. Be civil and respectful. No self-promotion or spam. Stick to the topic. Questions welcome.