Skip to content

Commit ccb6399

Browse files
committed
update week6 exercise
1 parent 6ac4ce8 commit ccb6399

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

week6_exercise.ipynb

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"### 1. Given two 1-d arrays of simulated values and observed values, Write a Pyhton function to calculate the mean error, coefficient of determination and nash coefficient. Not allowed to use loops."
7+
"### 1. Given two 1-d arrays of simulated values and observed values, Write a Pyhton function \n",
8+
"\n",
9+
"### to calculate the mean error, coefficient of determination and nash coefficient. Loops are NOT allowed."
810
]
911
},
1012
{
1113
"cell_type": "markdown",
1214
"metadata": {},
1315
"source": [
14-
"### 2. Given `x` and `y`, write a Python function to perform linear regression which returns `a`, `c` and `sum of square errors` where `ax + c = y` \n",
16+
"### 2. Given `x` and `y`, write a Python function to perform linear regression \n",
17+
"\n",
18+
"### which returns `a`, `c` and `sum of square errors` where `ax + c = y` \n",
1519
"```python\n",
1620
"def linear_regression(x, y):\n",
1721
" \n",
@@ -26,11 +30,11 @@
2630
"### 3. Eestimate the mean precipitation on different land use types.\n",
2731
"\n",
2832
"```python\n",
29-
"landuse = np.random.randint(1, 5, [5, 5])\n",
30-
"precipitation = np.random.random([5, 5])\n",
33+
"landuse = np.random.randint(1, 5, [5, 5])\n",
34+
"precip = np.random.random([5, 5])\n",
3135
"\n",
3236
"print('landuse\\n', landuse)\n",
33-
"print('landuse\\n', precipitation)\n",
37+
"print('precip \\n', precip)\n",
3438
"```\n",
3539
"\n"
3640
]
@@ -39,7 +43,17 @@
3943
"cell_type": "markdown",
4044
"metadata": {},
4145
"source": [
42-
"### 4. We have two array. The first array is the distribution of irrigated land. The second array is the precipitation. \n",
46+
"### 4. We have two array. The first array is the distribution of irrigated land. \n",
47+
"\n",
48+
"### The second array is the precipitation. \n",
49+
"\n",
50+
"```python\n",
51+
"landuse = np.random.randint(0, 1, [6, 6])\n",
52+
"precip = np.random.random([6, 6])\n",
53+
"\n",
54+
"print('landuse\\n', landuse)\n",
55+
"print('precip \\n', precip)\n",
56+
"```\n",
4357
"\n",
4458
"A. Create a function to create the buffer zones of varied distances to the irrigated land.\n",
4559
"\n",
@@ -50,7 +64,10 @@
5064
"cell_type": "markdown",
5165
"metadata": {},
5266
"source": [
53-
"### 5. Write a Python function to find the nearest point of a list of given points. You are not allowed to use any type of loops.\n",
67+
"### 5. Write a Python function to find the nearest point of a list of given points. \n",
68+
"\n",
69+
"### You are not allowed to use any type of loops.\n",
70+
"\n",
5471
"e. g. points = [(3, 4), (1, 2), (7, 8), (9, 4), (6, 5), (8, 7), (4, 7)]\n",
5572
"\n",
5673
"Hint: using numpy to create a N x N array which contain the distances between each ith an jth point pair; where N is the numer of points."

0 commit comments

Comments
 (0)