|
5 | 5 | <title></title> |
6 | 6 | <meta name="generator" content="LibreOffice 4.2.4.2 (MacOSX)"> |
7 | 7 | <meta name="created" content="0;0"> |
8 | | - <meta name="changed" content="20140605;223752655486000"> |
| 8 | + <meta name="changed" content="20140616;225009144635000"> |
9 | 9 | <style type="text/css"> |
10 | 10 | <!-- |
11 | 11 | td p { color: #000000; font-family: "Verdana"; font-size: 12pt } |
|
22 | 22 | <col width="511"> |
23 | 23 | <col width="690"> |
24 | 24 | <tr> |
25 | | - <td height="57" bgcolor="#0066cc" style="border: none; padding: 0in"> |
| 25 | + <td height="58" bgcolor="#0066cc" style="border: none; padding: 0in"> |
26 | 26 | <p align="center"><font color="#ffffff"><font face="Arial"><font size="5" style="font-size: 18pt"><b>Task</b></font></font></font></p> |
27 | 27 | </td> |
28 | 28 | <td bgcolor="#0066cc" style="border: none; padding: 0in"> |
|
92 | 92 | 3</font></font></p> |
93 | 93 | </td> |
94 | 94 | <td bgcolor="#cfe7f5" style="border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in"> |
95 | | - <p align="left"><font face="Andale Mono"><font size="1" style="font-size: 8pt"><font color="#ff420e"><font size="2" style="font-size: 10pt"><b>P></b></font></font> |
96 | | - a = np.array([[1],[2],[3]])<br><br><font color="#ff420e"><font size="2" style="font-size: 10pt"><b>P></b></font></font> |
97 | | - a<br>array([[1],<br> [2],<br> |
98 | | - [3]])</font></font></p> |
| 95 | + <p align="left"><font color="#ff420e"><font face="Andale Mono"><font size="2" style="font-size: 10pt"><b>P></b></font></font></font><font face="Andale Mono"><font size="1" style="font-size: 8pt"> |
| 96 | + </font></font><font face="Andale Mono"><font size="1" style="font-size: 8pt">a</font></font><font color="#2fff12"><font face="AndaleMono, serif"><font size="4" style="font-size: 14pt"> |
| 97 | + </font></font></font><font color="#000000"><font face="Andale Mono"><font size="1" style="font-size: 8pt">= |
| 98 | + np.array([1,2,3]).reshape(1,3)</font></font></font></p> |
| 99 | + <p align="left"><font face="Andale Mono"><font size="1" style="font-size: 8pt"><br></font></font><font color="#ff420e"><font face="Andale Mono"><font size="2" style="font-size: 10pt"><b>P></b></font></font></font><font face="Andale Mono"><font size="1" style="font-size: 8pt"> |
| 100 | + </font></font><font color="#000000"><font face="Andale Mono"><font size="1" style="font-size: 8pt">b.shape<br>(1, |
| 101 | + 3)</font></font></font></p> |
| 102 | + <p align="left"><br> |
| 103 | + </p> |
99 | 104 | </td> |
100 | 105 | <td bgcolor="#cfe7f5" style="border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in"> |
101 | 106 | <p align="left"><font face="Andale Mono"><font size="1" style="font-size: 8pt"><font color="#0000ff"><font size="2" style="font-size: 10pt"><b>R></b></font></font> |
|
124 | 129 | <p align="left"><font face="Andale Mono"><font size="1" style="font-size: 8pt"><font color="#ff420e"><font size="2" style="font-size: 10pt"><b>P></b></font></font> |
125 | 130 | b = np.array([1,2,3])<br><br><font color="#ff420e"><font size="2" style="font-size: 10pt"><b>P></b></font></font> |
126 | 131 | b<br>array([1, 2, 3])</font></font></p> |
| 132 | + <p align="left"><font face="Andale Mono"><font size="1" style="font-size: 8pt"># |
| 133 | + note that numpy doesn't have <br># explicit “row-vectors”, but |
| 134 | + 1-D <br># arrays</font></font></p> |
| 135 | + <p style="margin-bottom: 0in"><font face="Liberation Serif, serif"><font size="3" style="font-size: 12pt"><font color="#ff420e"><font face="Andale Mono"><font size="2" style="font-size: 10pt"><b>P></b></font></font></font><font color="#2fff12"><font face="AndaleMono, serif"><font size="1" style="font-size: 8pt"><b> |
| 136 | + </b></font></font></font><font color="#000000"><font face="Andale Mono"><font size="1" style="font-size: 8pt">b.shape</font></font></font></font></font></p> |
| 137 | + <p style="margin-bottom: 0in"><font face="Andale Mono"><font size="1" style="font-size: 8pt">(3,)</font></font></p> |
| 138 | + <p align="left"><font face="Andale Mono"><font size="1" style="font-size: 8pt"><br></font></font><br> |
| 139 | + </p> |
127 | 140 | </td> |
128 | 141 | <td bgcolor="#ffffff" style="border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in"> |
129 | 142 | <p align="left"><font face="Andale Mono"><font size="1" style="font-size: 8pt"><font color="#0000ff"><font size="2" style="font-size: 10pt"><b>R></b></font></font> |
|
213 | 226 | </td> |
214 | 227 | <td bgcolor="#cfe7f5" style="border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in"> |
215 | 228 | <p align="left"><font face="Andale Mono"><font size="1" style="font-size: 8pt"><font color="#ff420e"><font size="2" style="font-size: 10pt"><b>P></b></font></font> |
216 | | - np.ones([3,2])<br>array([[ 1., 1.],<br> |
| 229 | + np.ones((3,2))<br>array([[ 1., 1.],<br> |
217 | 230 | [ 1., 1.],<br> [ 1., 1.]])</font></font></p> |
218 | 231 | </td> |
219 | 232 | <td bgcolor="#cfe7f5" style="border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in"> |
|
551 | 564 | A = np.array([[1,2,3],[4,5,6],[7,8,9]])<br><br><font color="#ff420e"><font size="2" style="font-size: 10pt"><b>P></b></font></font> |
552 | 565 | A<br>array([[1, 2, 3],<br> [4, 5, 9],<br> |
553 | 566 | [7, 8, 9]])<br><br><font color="#ff420e"><font size="2" style="font-size: 10pt"><b>P></b></font></font> |
554 | | - total_elements = A.shape[0] * A.shape[1]<br><br><font color="#ff420e"><font size="2" style="font-size: 10pt"><b>P></b></font></font> |
555 | | - B = A.reshape(1, total_elements) <br><br># or |
556 | | - A.reshape(1,9)<br># Alternative: A.shape = (1,9) <br># |
557 | | - to change the array in place<br><br><font color="#ff420e"><font size="2" style="font-size: 10pt"><b>P></b></font></font> |
| 567 | + total_elements = np.prod(A.shape)</font></font></p> |
| 568 | + <p align="left"><font face="Andale Mono"><font size="1" style="font-size: 8pt"><font color="#ff420e"><font size="2" style="font-size: 10pt"><b>P></b></font></font> |
| 569 | + B = A.reshape(1, total_elements) <br><br># alternative |
| 570 | + shortcut:<br># A.reshape(1,-1)<br><br><font color="#ff420e"><font size="2" style="font-size: 10pt"><b>P></b></font></font> |
558 | 571 | B<br>array([[1, 2, 3, 4, 5, 6, 7, 8, 9]])</font></font></p> |
559 | 572 | </td> |
560 | 573 | <td bgcolor="#ffffff" style="border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in"> |
|
1107 | 1120 | </td> |
1108 | 1121 | </tr> |
1109 | 1122 | <tr valign="top"> |
1110 | | - <td height="539" bgcolor="#ffffff" style="border-top: none; border-bottom: none; border-left: none; border-right: 1px solid #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in"> |
| 1123 | + <td height="540" bgcolor="#ffffff" style="border-top: none; border-bottom: none; border-left: none; border-right: 1px solid #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in"> |
1111 | 1124 | <p align="left"><font face="Arial"><font size="2" style="font-size: 10pt"><b>Generating |
1112 | 1125 | a Gaussian dataset:<br><br>creating random vectors from the |
1113 | 1126 | multivariate normal<br>distribution given mean and covariance |
|
0 commit comments