2014-06-06 03:40:21 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
< html >
< head >
< meta http-equiv = "content-type" content = "text/html; charset=utf-8" >
< title > < / title >
2014-07-18 18:13:22 +00:00
< meta name = "generator" content = "LibreOffice 4.2.5.2 (MacOSX)" >
2014-06-06 03:40:21 +00:00
< meta name = "created" content = "0;0" >
2014-07-18 18:13:22 +00:00
< meta name = "changed" content = "20140718;140930381877000" >
2014-06-06 03:40:21 +00:00
< style type = "text/css" >
<!--
td p { color: #000000; font-family: "Verdana"; font-size: 12pt }
p { color: #000000; font-family: "Verdana"; font-size: 12pt }
-->
< / style >
< / head >
< body lang = "en-US" text = "#000000" dir = "ltr" style = "background: transparent" >
2014-07-18 18:13:22 +00:00
< table width = "948" cellpadding = "2" cellspacing = "0" style = "page-break-before: always" >
< col width = "171" >
< col width = "174" >
< col width = "128" >
< col width = "136" >
< col width = "126" >
< col width = "188" >
2014-06-06 03:40:21 +00:00
< tr >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "60" bgcolor = "#0066cc" style = "border: none; padding: 0in" >
2014-06-06 03:40:21 +00:00
< p align = "center" > < font color = "#ffffff" > < font face = "Arial" > < font size = "5" style = "font-size: 18pt" > < b > Task< / b > < / font > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#0066cc" style = "border: none; padding: 0in" >
< p align = "center" > < font color = "#ffffff" > < font face = "monospace" > < font size = "5" style = "font-size: 18pt" > < b > MATLAB/Octave< / b > < / font > < / font > < / font > < / p >
2014-06-06 03:40:21 +00:00
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#0066cc" style = "border: none; padding: 0in" >
< p align = "center" > < font color = "#ffffff" > < font face = "monospace" > < font size = "5" style = "font-size: 18pt" > < b > Python
2014-06-06 03:40:21 +00:00
NumPy< / b > < / font > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#0066cc" style = "border: none; padding: 0in" >
< p align = "center" > < font color = "#ffffff" > < font face = "monospace" > < font size = "5" style = "font-size: 18pt" > < b > R< / b > < / font > < / font > < / font > < / p >
2014-06-06 03:40:21 +00:00
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#0066cc" style = "border: none; padding: 0in" >
< p align = "center" > < font color = "#ffffff" > < font face = "monospace" > < font size = "5" style = "font-size: 18pt" > < b > Julia< / b > < / font > < / font > < / font > < / p >
2014-06-06 03:40:21 +00:00
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#0066cc" style = "border: none; padding: 0in" >
2014-06-06 03:40:21 +00:00
< p align = "center" > < font color = "#ffffff" > < font face = "Arial" > < font size = "5" style = "font-size: 18pt" > < b > Task< / b > < / font > < / font > < / font > < / p >
< / td >
< / tr >
< tr >
2014-07-18 18:13:22 +00:00
< td colspan = "6" width = "944" height = "70" bgcolor = "#ffffff" style = "border: none; padding: 0in" >
2014-06-06 03:40:21 +00:00
< p align = "center" > < font face = "Arial" > < font size = "4" style = "font-size: 14pt" > < b > CREATING
MATRICES< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "158" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Creating
Matrices < br > (here: 3x3 matrix)< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = [1 2 3; 4 5 6; 7 8 9]< br > A =< br > 1 2
3< br > 4 5 6< br > 7 8
9< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
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 >
A< br > array([[1, 2, 3],< br > [4, 5, 6],< br >
[7, 8, 9]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = matrix(c(1,2,3,4,5,6,7,8,9),nrow=3,byrow=T)< br > < br >
#
equivalent to
< br > # A = matrix(1:9,nrow=3,byrow=T)
< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A< br > [,1] [,2] [,3]< br > [1,] 1 2 3< br > [2,] 4 5 6< br > [3,] 7 8 9< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[1 2 3; 4 5 6; 7 8 9]< br > 3x3 Array{Int64,2}:< br > 1 2 3< br > 4 5 6< br > 7
8 9< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Creating
Matrices < br > (here: 3x3 matrix)< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "128" bgcolor = "#cfe7f5" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Creating
an 1D column vector< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
a = [1; 2; 3]< br > a =< br > 1< br > 2< br >
3< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font color = "#ff420e" > < font face = "monospace" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font > < / font >
< font face = "monospace" > < font size = "1" style = "font-size: 8pt" > a< / font > < / font > < font color = "#2fff12" >
< / font > < font color = "#000000" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > =
2014-06-17 03:00:23 +00:00
np.array([1,2,3]).reshape(1,3)< / font > < / font > < / font > < / p >
2014-07-18 18:13:22 +00:00
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < br > < / font > < / font > < font color = "#ff420e" > < font face = "monospace" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font > < / font >
< font color = "#000000" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > b.shape< br > (1,
2014-06-17 03:00:23 +00:00
3)< / font > < / font > < / font > < / p >
< p align = "left" > < br >
< / p >
2014-06-06 03:40:21 +00:00
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
a = matrix(c(1,2,3), nrow=3, byrow=T)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
a< br > [,1]< br > [1,] 1< br > [2,] 2< br > [3,] 3< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
a=[1; 2; 3]< br > 3-element Array{Int64,1}: < br > 1< br > 2< br > 3< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Creating
an 1D column vector< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "128" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Creating
an< br > 1D row vector< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
b = [1 2 3]< br > b =< br > 1 2 3< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
b = np.array([1,2,3])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
b< br > array([1, 2, 3])< / font > < / font > < / p >
2014-07-18 18:13:22 +00:00
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > #
2014-06-17 03:00:23 +00:00
note that numpy doesn't have < br > # explicit “row-vectors”, but
1-D < br > # arrays< / font > < / font > < / p >
2014-07-18 18:13:22 +00:00
< p style = "margin-bottom: 0in" > < font face = "Liberation Serif, serif" > < font size = "3" style = "font-size: 12pt" > < font color = "#ff420e" > < font face = "monospace" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font > < / font > < font color = "#2fff12" >
< / font > < font color = "#000000" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > b.shape< / font > < / font > < / font > < / font > < / font > < / p >
< p style = "margin-bottom: 0in" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > (3,)< / font > < / font > < / p >
2014-06-22 16:39:16 +00:00
< p align = "left" > < br >
2014-06-17 03:00:23 +00:00
< / p >
2014-06-06 03:40:21 +00:00
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
b = matrix(c(1,2,3), ncol=3)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
b< br > [,1] [,2] [,3]< br > [1,] 1 2 3< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
b=[1 2 3] < br > 1x3 Array{Int64,2}:< br > 1 2 3< br > < br > # note that this
is a 2D array. < br > # vectors in Julia are columns< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Creating
an< br > 1D row vector< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "128" bgcolor = "#cfe7f5" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Creating
a < br > random m x n matrix< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
rand(3,2)< br > ans =< br > 0.21977 0.10220< br >
0.38959 0.69911< br > 0.15624 0.65637< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
np.random.rand(3,2)< br > array([[ 0.29347865, 0.17920462],< br >
[ 0.51615758, 0.64593471],< br >
[ 0.01067605, 0.09692771]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
matrix(runif(3*2), ncol=2)< br > [,1] [,2]< br > [1,] 0.5675127
0.7751204< br > [2,] 0.3439412 0.5261893< br > [3,] 0.2273177 0.223438< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
rand(3,2)< br > 3x2 Array{Float64,2}:< br > 0.36882 0.267725< br > 0.571856
0.601524< br > 0.848084 0.858935< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Creating
a < br > random m x n matrix< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "128" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Creating
a< br > zero m x n matrix < / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
zeros(3,2)< br > ans =< br > 0 0< br > 0
0< br > 0 0< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
np.zeros((3,2))< br > array([[ 0., 0.],< br >
[ 0., 0.],< br > [ 0.,
0.]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
mat.or.vec(3, 2)< br > [,1] [,2]< br > [1,] 0 0< br > [2,] 0 0< br > [3,] 0 0< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
zeros(3,2)< br > 3x2 Array{Float64,2}:< br > 0.0 0.0< br > 0.0 0.0< br > 0.0
0.0< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Creating
a< br > zero m x n matrix < / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "128" bgcolor = "#cfe7f5" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Creating
an< br > m x n matrix of ones< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
ones(3,2)< br > ans =< br > 1 1< br > 1
1< br > 1 1< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-17 03:00:23 +00:00
np.ones((3,2))< br > array([[ 1., 1.],< br >
2014-06-06 03:40:21 +00:00
[ 1., 1.],< br > [ 1., 1.]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font color = "#0000ff" > < font face = "monospace" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font > < / font > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" >
< / font > < / font > < font color = "#000000" > < font face = "AndaleMono, serif" > < font size = "1" style = "font-size: 8pt" > matrix(1L,
3, 2)< br > < / font > < / font > < / font > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < br > [,1]
[,2]< br > [1,] 1 1< br > [2,] 1 1< br > [3,] 1 1< / font > < / font > < / p >
2014-06-06 03:40:21 +00:00
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
ones(3,2)< br > 3x2 Array{Float64,2}:< br > 1.0 1.0< br > 1.0 1.0< br > 1.0
1.0< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Creating
an< br > m x n matrix of ones< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "128" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Creating
an< br > identity matrix< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
eye(3)< br > ans =< br > Diagonal Matrix< br > 1 0
0< br > 0 1 0< br > 0 0
1< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
np.eye(3)< br > array([[ 1., 0., 0.],< br >
[ 0., 1., 0.],< br > [
0., 0., 1.]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
diag(3)< br > [,1] [,2] [,3]< br > [1,] 1 0 0< br > [2,] 0 1 0< br > [3,] 0 0
1< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
eye(3)< br > 3x3 Array{Float64,2}:< br > 1.0 0.0 0.0< br > 0.0 1.0 0.0< br > 0.0
0.0 1.0< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Creating
an< br > identity matrix< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "217" bgcolor = "#cfe7f5" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Creating
a< br > diagonal matrix< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
a = [1 2 3]< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
diag(a)< br > ans =< br > Diagonal Matrix< br > 1 0
0< br > 0 2 0< br > 0 0
3< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
a = np.array([1,2,3])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
np.diag(a)< br > array([[1, 0, 0],< br > [0,
2, 0],< br > [0, 0, 3]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
diag(1:3)< br > [,1] [,2] [,3]< br > [1,] 1 0 0< br > [2,] 0 2 0< br > [3,] 0
0 3< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
a=[1, 2, 3] < br > < br > # added commas because julia< br > # vectors are
columnar< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
diagm(a)< br > 3x3 Array{Int64,2}:< br > 1 0 0< br > 0 2 0< br > 0 0 3< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Creating
a< br > diagonal matrix< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr >
2014-07-18 18:13:22 +00:00
< td colspan = "6" width = "944" height = "128" bgcolor = "#ffffff" style = "border: none; padding: 0in" >
2014-06-06 03:40:21 +00:00
< p align = "center" > < font face = "Arial" > < font size = "4" style = "font-size: 14pt" > < b > ACCESSING
MATRIX ELEMENTS< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "159" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Getting
the dimension< br > of a matrix< br > (here: 2D, rows x cols)< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = [1 2 3; 4 5 6]< br > A =< br > 1 2 3< br >
4 5 6< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
size(A)< br > ans =< br > 2 3< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = np.array([ [1,2,3], [4,5,6] ])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A< br > array([[1, 2, 3],< br > [4, 5,
6]])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A.shape< br > (2, 3)< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = matrix(1:6,nrow=2,byrow=T)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A< br > [,1] [,2] [,3]< br > [1,] 1 2 3< br > [2,] 4 5 6
< / font > < / font > < / p >
2014-07-18 18:13:22 +00:00
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
dim(A)< br > [1] 2 3< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[1 2 3; 4 5 6]< br > 2x3 Array{Int64,2}:< br > 1 2 3< br > 4 5 6< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
size(A)< br > (2,3)< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Getting
the dimension< br > of a matrix< br > (here: 2D, rows x cols)< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "240" bgcolor = "#cfe7f5" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Selecting
rows < / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = [1 2 3; 4 5 6; 7 8 9]< br > < br > % 1st row< br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A(1,:)< br > ans =< br > 1 2 3< br > < br > % 1st 2
rows< br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A(1:2,:)< br > ans =< br > 1 2 3< br >
4 5 6< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = np.array([ [1,2,3], [4,5,6], [7,8,9] ])< br > < br > # 1st row< br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A[0,:]< br > array([1, 2, 3])< br > < br > # 1st 2 rows< br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A[0:2,:]< br > array([[1, 2, 3], [4, 5, 6]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = matrix(1:9,nrow=3,byrow=T)
< br > < br > # 1st row< br >
< font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A[1,]< br > [1] 1 2 3< br > < br >
# 1st 2 rows
< br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A[1:2,]< br > [,1] [,2] [,3]< br > [1,] 1 2 3< br > [2,] 4 5 6< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[1 2 3; 4 5 6; 7 8 9]; < br > #semicolon suppresses output< br > < br > #1st
row< br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A[1,:] < br > 1x3 Array{Int64,2}:< br > 1 2 3< br > < br > #1st 2 rows< br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A[1:2,:] < br > 2x3 Array{Int64,2}:< br > 1 2 3< br > 4 5 6< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Selecting
rows < / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "304" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Selecting
columns< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = [1 2 3; 4 5 6; 7 8 9]< br > < br > % 1st column< br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A(:,1)< br > ans =< br > 1< br > 4< br >
7< br > < br > % 1st 2 columns< br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A(:,1:2)< br > ans =< br > 1 2< br > 4
5< br > 7 8< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = np.array([ [1,2,3], [4,5,6], [7,8,9] ])< br > < br > # 1st column
(as row vector)< br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A[:,0]< br > array([1, 4, 7])< br > < br > # 1st column (as column
vector)< br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A[:,[0]]< br > array([[1],< br > [4],< br >
[7]])< br > < br > # 1st 2 columns< br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A[:,0:2]< br > array([[1, 2], < br > [4,
5], < br > [7, 8]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = matrix(1:9,nrow=3,byrow=T)
< br > < br > # 1st column as row
vector
< br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
t(A[,1])< br > [,1] [,2] [,3]< br > [1,] 1 4 7
< br > < br > # 1st column
as column vector
< br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A[,1]< br > [1] 1 4 7
< br > < br > # 1st 2 columns
< br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A[,1:2]< br > [,1] [,2]< br > [1,] 1 2< br > [2,] 4 5< br > [3,] 7 8< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[1 2 3; 4 5 6; 7 8 9];< br > < br > #1st column< br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A[:,1] < br > 3-element Array{Int64,1}:< br > 1< br > 4< br > 7< br > < br > #1st 2
columns< br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A[:,1:2] < br > 3x2 Array{Int64,2}:< br > 1 2< br > 4 5< br > 7 8< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Selecting
columns< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "260" bgcolor = "#cfe7f5" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Extracting
rows and columns by criteria< br > < br > (here: get rows that have
value 9 in column 3)< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = [1 2 3; 4 5 9; 7 8 9]< br > A =< br > 1 2
3< br > 4 5 9< br > 7 8
9< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A(A(:,3) == 9,:)< br > ans =< br > 4 5 9< br >
7 8 9< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = np.array([ [1,2,3], [4,5,9], [7,8,9]])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A< br > array([[1, 2, 3],< br > [4, 5, 9],< br >
[7, 8, 9]])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A[A[:,2] == 9]< br > array([[4, 5, 9],< br >
[7, 8, 9]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font color = "#0000ff" > < font face = "monospace" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font > < / font > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" >
A = matrix(1:9,nrow=3,byrow=T)
< br > < br > < / font > < / font > < font color = "#0000ff" > < font face = "monospace" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font > < / font > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" >
2014-06-06 03:40:21 +00:00
A< br > [,1] [,2] [,3]< br > [1,] 1 2 3< br > [2,] 4 5 9< br > [3,] 7 8
2014-07-18 18:13:22 +00:00
9
< br > < br > < / font > < / font > < font color = "#0000ff" > < font face = "monospace" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font > < / font > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" >
< / font > < / font > < font color = "#000000" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > A[A[,3]==9,]< / font > < / font > < / font > < / p >
< p align = "left" style = "margin-bottom: 0in" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > [1]
2014-06-06 03:40:21 +00:00
7 8 9< / font > < / font > < / p >
2014-07-18 18:13:22 +00:00
< p align = "left" > < br >
< / p >
2014-06-06 03:40:21 +00:00
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[1 2 3; 4 5 9; 7 8 9]< br > 3x3 Array{Int64,2}:< br > 1 2 3< br > 4 5 9< br > 7
8 9< br > < br > # use '.==' for< br > # element-wise check< br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A[ A[:,3] .==9, :] < br > 2x3 Array{Int64,2}:< br > 4 5 9< br > 7 8 9< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Extracting
rows and columns by criteria< br > < br > (here: get rows that have
value 9 in column 3)< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "118" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Accessing
elements< br > (here: 1st element)< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = [1 2 3; 4 5 6; 7 8 9]< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A(1,1)< br > ans = 1< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
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 >
A[0,0]< br > 1< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = matrix(c(1,2,3,4,5,9,7,8,9),nrow=3,byrow=T)
< br > < br >
< font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A[1,1]< br > [1] 1< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[1 2 3; 4 5 6; 7 8 9];< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A[1,1]< br > 1< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Accessing
elements< br > (here: 1st element)< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr >
2014-07-18 18:13:22 +00:00
< td colspan = "6" width = "944" height = "128" bgcolor = "#ffffff" style = "border: none; padding: 0in" >
2014-06-06 03:40:21 +00:00
< p align = "center" > < font face = "Arial" > < font size = "4" style = "font-size: 14pt" > < b > MANIPULATING
SHAPE AND DIMENSIONS< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "173" 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" >
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Converting < br > a
matrix into a row vector (by column)< / b > < / font > < / font > < / p >
< / td >
< td width = "174" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A = [1 2 3; 4 5 6; 7 8 9]< / font > < / font > < / p >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A(:)< / font > < / font > < / p >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > ans
= < / font > < / font >
< / p >
< p > < font face = "Liberation Serif, serif" > < font size = "1" style = "font-size: 8pt" > < font face = "AndaleMono, serif" > 1
< br > 4 < br > 7< br > 2< br > 5< br > 8< br > 3< br > 6< br > < / font > < font face = "AndaleMono, serif" > 9< / font > < / font > < / font > < / p >
< / td >
< td width = "128" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A = np.array([[1,2,3],[4,5,6],[7,8,9]])< / font > < / font > < / p >
< p align = "left" > < font color = "#ff420e" > < font face = "monospace" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font > < / font > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" >
< / font > < / font > < font color = "#000000" > < font face = "AndaleMono, serif" > < font size = "1" style = "font-size: 8pt" > A.flatten(1)< / font > < / font > < / font > < / p >
< p align = "left" style = "margin-bottom: 0in" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font face = "AndaleMono, serif" > array([1,
4, 7, 2, 5, 8, 3, 6, 9])< / font > < / font > < / font > < / p >
< p align = "left" > < br >
< / p >
< / td >
< td width = "136" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A = matrix(1:9,nrow=3,byrow=T)< / font > < / font > < / p >
< p align = "left" style = "margin-bottom: 0in" > < br >
< / p >
< p align = "left" style = "margin-bottom: 0in" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R>
< / b > < / font > < / font > < font face = "AndaleMono, serif" > as.vector(A)< / font > < / font > < / font > < / p >
< p align = "left" style = "margin-bottom: 0in" > < br >
< / p >
< p style = "margin-bottom: 0in" > < font face = "Liberation Serif, serif" > < font size = "1" style = "font-size: 8pt" > < font face = "AndaleMono, serif" > [1]
1 4 7 2 5 8 3 6 9< / font > < / font > < / font > < / p >
< p align = "left" > < br >
< / p >
< / td >
< td width = "126" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A=[1 2 3; 4 5 6; 7 8 9]< / font > < / font > < / p >
< p align = "left" style = "margin-bottom: 0in" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font > < font color = "#2fb41d" > < font face = "AndaleMono, serif" > < font size = "3" style = "font-size: 12pt" >
< / font > < / font > < / font > < font color = "#000000" > < font face = "AndaleMono, serif" > vec(A)< / font > < / font > < / font > < / font > < / p >
< p style = "margin-bottom: 0in" > < font face = "Liberation Serif, serif" > < font size = "1" style = "font-size: 8pt" > < font face = "AndaleMono, serif" > 9-element
Array{Int64,1}:< / font > < / font > < / font > < / p >
< p > < font face = "Liberation Serif, serif" > < font size = "1" style = "font-size: 8pt" > < font color = "#000000" > < font face = "AndaleMono, serif" > 1< br > 4< br > 7< br > 2< br > 5< br > 8< br > 3< br > 6< br > 9< / font > < / font > < / font > < / font > < / p >
< / td >
< td width = "188" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Converting < br > a
matrix into a row vector (by column)< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
< td width = "171" height = "173" bgcolor = "#cfe7f5" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Converting < br > row
to column vectors< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
b = [1 2 3]
< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
b = b'< br > b =< br > 1< br > 2< br >
3< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
b = np.array([1, 2, 3])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
b = b[np.newaxis].T< br > # alternatively < br > # b =
b[:,np.newaxis]< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
b< br > array([[1],< br > [2],< br >
[3]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
b = matrix(c(1,2,3), ncol=3)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
t(b)< br > [,1]< br > [1,] 1< br > [2,] 2< br > [3,] 3< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
b=vec([1 2 3])< br > 3-element Array{Int64,1}:< br > 1< br > 2< br > 3< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Converting < br > row
to column vectors< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "275" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Reshaping
Matrices< br > < br > (here: 3x3 matrix to row vector)< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = [1 2 3; 4 5 6; 7 8 9]< br > A =< br > 1 2
3< br > 4 5 6< br > 7 8
9< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
total_elements = numel(A)< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
B = reshape(A,1,total_elements) < br > % or reshape(A,1,9)< br > B
=< br > 1 4 7 2 5 8
3 6 9< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
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 >
A< br > array([[1, 2, 3],< br > [4, 5, 9],< br >
[7, 8, 9]])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-17 03:00:23 +00:00
total_elements = np.prod(A.shape)< / font > < / font > < / p >
2014-07-18 18:13:22 +00:00
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-17 03:00:23 +00:00
B = A.reshape(1, total_elements) < br > < br > # alternative
shortcut:< br > # A.reshape(1,-1)< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
B< br > array([[1, 2, 3, 4, 5, 6, 7, 8, 9]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = matrix(1:9,nrow=3,byrow=T)
< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A< br > [,1] [,2] [,3]< br > [1,] 1 2 3< br > [2,] 4 5 6< br > [3,] 7 8 9
< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
total_elements = dim(A)[1] * dim(A)[2]< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
B = matrix(A, ncol=total_elements)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
B< br > [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]< br > [1,] 1 4 7 2
5 8 3 6 9< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[1 2 3; 4 5 6; 7 8 9]< br > 3x3 Array{Int64,2}:< br > 1 2 3< br > 4 5 6< br > 7
8 9< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
total_elements=length(A)< br > 9< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font > B=reshape(A,1,total_elements)< br > 1x9
Array{Int64,2}:< br > 1 4 7 2 5 8 3 6 9< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Reshaping
Matrices< br > < br > (here: 3x3 matrix to row vector)< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "240" bgcolor = "#cfe7f5" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Concatenating
matrices< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = [1 2 3; 4 5 6]< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
B = [7 8 9; 10 11 12]< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
C = [A; B]< br > 1 2 3< br >
4 5 6< br > 7
8 9< br > 10 11 12< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = np.array([[1, 2, 3], [4, 5, 6]])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
B = np.array([[7, 8, 9],[10,11,12]])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
C = np.concatenate((A, B), axis=0)< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
C< br > array([[ 1, 2, 3], < br > [ 4,
5, 6], < br > [ 7, 8, 9], < br >
[10, 11, 12]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = matrix(1:6,nrow=2,byrow=T)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
B = matrix(7:12,nrow=2,byrow=T)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
C = rbind(A,B)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
C< br > [,1] [,2] [,3]< br > [1,] 1 2 3< br > [2,] 4 5 6< br > [3,] 7 8 9< br > [4,]
10 11 12< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[1 2 3; 4 5 6];< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
B=[7 8 9; 10 11 12];< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
C=[A; B]< br > 4x3 Array{Int64,2}:< br > 1 2 3< br > 4 5 6< br > 7 8 9< br > 10
11 12< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Concatenating
matrices< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "256" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Stacking < br > vectors
and matrices< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
a = [1 2 3]< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
b = [4 5 6]< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
c = [a' b']< br > c =< br > 1 4< br > 2
5< br > 3 6< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
c = [a; b]< br > c =< br > 1 2 3< br >
4 5 6< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
a = np.array([1,2,3])< br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
b = np.array([4,5,6])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
np.c_[a,b]< br > array([[1, 4],< br > [2,
5],< br > [3, 6]])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
np.r_[a,b]< br > array([[1, 2, 3],< br > [4,
5, 6]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
a = matrix(1:3, ncol=3)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
b = matrix(4:6, ncol=3)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
matrix(rbind(A, B), ncol=2)< br > [,1] [,2]< br > [1,] 1 5< br > [2,] 4
3
< br > < br >
< font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
rbind(A,B)< br > [,1] [,2] [,3]< br > [1,] 1 2 3< br > [2,] 4 5 6< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
a=[1 2 3];< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
b=[4 5 6];< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
c=[a' b']< br > 3x2 Array{Int64,2}:< br > 1 4< br > 2 5< br > 3 6< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
c=[a; b]< br > 2x3 Array{Int64,2}:< br > 1 2 3< br > 4 5 6< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Stacking < br > vectors
and matrices< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr >
2014-07-18 18:13:22 +00:00
< td colspan = "6" width = "944" height = "114" bgcolor = "#ffffff" style = "border: none; padding: 0in" >
2014-06-06 03:40:21 +00:00
< p align = "center" > < font face = "Arial" > < font size = "4" style = "font-size: 14pt" > < b > BASIC
MATRIX OPERATIONS< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "253" bgcolor = "#cfe7f5" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Matrix-scalar< br > operations< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font > A
2014-06-06 03:40:21 +00:00
= [1 2 3; 4 5 6; 7 8 9]< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A * 2< br > ans =< br > 2 4 6< br >
8 10 12< br > 14 16
18< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A + 2< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A - 2< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A / 2< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
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 >
A * 2< br > array([[ 2, 4, 6],< br >
[ 8, 10, 12],< br > [14, 16, 18]])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A + 2< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A - 2< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A / 2< / font > < / font > < / p >
2014-07-18 18:13:22 +00:00
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > #
2014-06-22 16:39:16 +00:00
Note that NumPy was optimized for< br > # in-place assignments< br > #
e.g., A += A instead of < br > # A = A + A< / font > < / font > < / p >
2014-06-06 03:40:21 +00:00
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = matrix(1:9, nrow=3, byrow=T)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A * 2< br > [,1] [,2] [,3]< br > [1,] 2 4 6< br > [2,] 8 10 12< br > [3,] 14
16 18
< / font > < / font > < / p >
2014-07-18 18:13:22 +00:00
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A + 2< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A - 2< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A / 2< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[1 2 3; 4 5 6; 7 8 9];< br > < br > # elementwise operator< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A .* 2 < br > 3x3 Array{Int64,2}:< br > 2 4 6< br > 8 10 12< br > 14 16 18
< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A .+ 2;< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A .- 2;< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A ./ 2;< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Matrix-scalar< br > operations< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "165" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Matrix-matrix< br > multiplication< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font > A
2014-06-06 03:40:21 +00:00
= [1 2 3; 4 5 6; 7 8 9]< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A * A< br > ans =< br > 30 36
42< br > 66 81 96< br >
102 126 150< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
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 >
np.dot(A,A) # or A.dot(A)< br > array([[ 30, 36, 42],< br >
[ 66, 81, 96],< br >
[102, 126, 150]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = matrix(1:9, nrow=3, byrow=T)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A %*% A< br > [,1] [,2] [,3]< br > [1,] 30 36 42< br > [2,] 66 81 96< br > [3,]
102 126 150< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[1 2 3; 4 5 6; 7 8 9];< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A * A< br > 3x3 Array{Int64,2}:< br > 30 36 42< br > 66 81 96< br > 102 126
150< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Matrix-matrix< br > multiplication< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "190" bgcolor = "#cfe7f5" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Matrix-vector< br > multiplication< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = [1 2 3; 4 5 6; 7 8 9]< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
b = [ 1; 2; 3 ]< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A * b< br > ans =< br > 14< br > 32< br >
50< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
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 >
b = np.array([ [1], [2], [3] ])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
np.dot(A,b) # or A.dot(b)< br > < br > array([[14], [32], [50]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = matrix(1:9, ncol=3)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
b = matrix(1:3, nrow=3)< br > < br >
< font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
t(b %*% A)< br > [,1]< br > [1,] 14< br > [2,] 32< br > [3,] 50< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[1 2 3; 4 5 6; 7 8 9];< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
b=[1; 2; 3];< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A*b< br > 3-element Array{Int64,1}:< br > 14< br > 32< br > 50< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Matrix-vector< br > multiplication< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "240" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Element-wise < br > matrix-matrix operations< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font > A
2014-06-06 03:40:21 +00:00
= [1 2 3; 4 5 6; 7 8 9]< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A .* A< br > ans =< br > 1 4
9< br > 16 25 36< br > 49
64 81< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A .+ A< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A .- A< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A ./ A< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
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 >
A * A< br > array([[ 1, 4, 9],< br >
[16, 25, 36],< br > [49, 64, 81]])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A + A< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A - A< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A / A< / font > < / font > < / p >
2014-07-18 18:13:22 +00:00
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > #
2014-06-22 16:39:16 +00:00
Note that NumPy was optimized for< br > # in-place assignments< br > #
e.g., A += A instead of < br > # A = A + A< / font > < / font > < / p >
2014-06-06 03:40:21 +00:00
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = matrix(1:9, nrow=3, byrow=T)
< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A * A< br > [,1] [,2] [,3]< br > [1,] 1 4 9< br > [2,] 16 25 36< br > [3,] 49
64 81
< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A + A< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A - A< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A / A< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[1 2 3; 4 5 6; 7 8 9];< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A .* A< br > 3x3 Array{Int64,2}:< br > 1 4 9< br > 16 25 36< br > 49 64 81
< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A .+ A; < br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A .- A; < br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A ./ A;< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Element-wise < br > matrix-matrix operations< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "164" bgcolor = "#cfe7f5" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Matrix
elements to power n < br > < br > (here: individual elements
squared)< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font > A
2014-06-06 03:40:21 +00:00
= [1 2 3; 4 5 6; 7 8 9]< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A.^2< br > ans =< br > 1 4 9< br >
16 25 36< br > 49 64 81< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
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 >
np.power(A,2)< br > array([[ 1, 4, 9],< br >
[16, 25, 36],< br > [49, 64, 81]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = matrix(1:9, nrow=3, byrow=T)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A ^ 2< br > [,1] [,2] [,3]< br > [1,] 1 4 9< br > [2,] 16 25 36< br > [3,] 49
64 81< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[1 2 3; 4 5 6; 7 8 9];< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A .^ 2< br > 3x3 Array{Int64,2}:< br > 1 4 9< br > 16 25 36< br > 49 64 81< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Matrix
elements to power n < br > < br > (here: individual elements
squared)< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "225" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Matrix
to power n< br > < br > (here: matrix-matrix multiplication with
itself)< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font > A
2014-06-06 03:40:21 +00:00
= [1 2 3; 4 5 6; 7 8 9]< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A ^ 2< br > ans =< br > 30 36
42< br > 66 81 96< br >
102 126 150< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
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 >
np.linalg.matrix_power(A,2)< br > array([[ 30, 36,
42],< br > [ 66, 81, 96],< br >
[102, 126, 150]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = matrix(1:9, ncol=3)< br > < br >
# requires the ‘ expm’
package
< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
install.packages('expm')
< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
library(expm)
< br > < br >
< font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A %^% 2< br > [,1] [,2] [,3]< br > [1,] 30 66 102< br > [2,] 36 81 126< br > [3,]
42 96 150< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[1 2 3; 4 5 6; 7 8 9];< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A ^ 2< br > 3x3 Array{Int64,2}:< br > 30 36 42< br > 66 81 96< br > 102 126
150< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Matrix
to power n< br > < br > (here: matrix-matrix multiplication with
itself)< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "172" bgcolor = "#cfe7f5" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Matrix
transpose< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font > A
2014-06-06 03:40:21 +00:00
= [1 2 3; 4 5 6; 7 8 9]< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A'< br > ans =< br > 1 4 7< br > 2
5 8< br > 3 6 9< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
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 >
A.T< br > array([[1, 4, 7],< br > [2, 5,
8],< br > [3, 6, 9]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = matrix(1:9, nrow=3, byrow=T)
< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
t(A)< br > [,1] [,2] [,3]< br > [1,] 1 4 7< br > [2,] 2 5 8< br > [3,] 3 6 9< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[1 2 3; 4 5 6; 7 8 9]< br > 3x3 Array{Int64,2}:< br > 1 2 3< br > 4 5 6< br > 7
8 9< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A'< br > 3x3 Array{Int64,2}:< br > 1 4 7< br > 2 5 8< br > 3 6 9< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Matrix
transpose< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "176" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Determinant
of a matrix:< br > A -> |A|< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = [6 1 1; 4 -2 5; 2 8 7]< br > A =< br > 6 1
1< br > 4 -2 5< br > 2 8
7< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
det(A)< br > ans = -306< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font > A
2014-06-06 03:40:21 +00:00
= np.array([[6,1,1],[4,-2,5],[2,8,7]])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A< br > array([[ 6, 1, 1],< br >
[ 4, -2, 5],< br > [ 2, 8,
7]])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
np.linalg.det(A)< br > -306.0< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = matrix(c(6,1,1,4,-2,5,2,8,7), nrow=3, byrow=T)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A< br > [,1] [,2] [,3]< br > [1,] 6 1 1< br > [2,] 4 -2 5< br > [3,] 2 8 7< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
det(A)< br > [1] -306< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[6 1 1; 4 -2 5; 2 8 7]< br > 3x3 Array{Int64,2}:< br > 6 1 1< br > 4 -2
5< br > 2 8 7< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
det(A)< br > -306.0< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Determinant
of a matrix:< br > A -> |A|< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "202" bgcolor = "#cfe7f5" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Inverse
of a matrix< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = [4 7; 2 6]< br > A =< br > 4 7< br > 2
6< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
A_inv = inv(A)< br > A_inv =< br > 0.60000 -0.70000< br >
-0.20000 0.40000< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = np.array([[4, 7], [2, 6]])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A< br > array([[4, 7], < br > [2,
6]])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A_inverse = np.linalg.inv(A)< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A_inverse< br > array([[ 0.6, -0.7], < br >
[-0.2, 0.4]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = matrix(c(4,7,2,6), nrow=2, byrow=T)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A< br > [,1] [,2]< br > [1,] 4 7< br > [2,] 2 6< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
solve(A)< br > [,1] [,2]< br > [1,] 0.6 -0.7< br > [2,] -0.2 0.4< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[4 7; 2 6]< br > 2x2 Array{Int64,2}:< br > 4 7< br > 2 6< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
A_inv=inv(A)< br > 2x2 Array{Float64,2}:< br > 0.6 -0.7< br > -0.2 0.4< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Inverse
of a matrix< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr >
2014-07-18 18:13:22 +00:00
< td colspan = "6" width = "944" height = "202" bgcolor = "#ffffff" style = "border: none; padding: 0in" >
2014-06-06 03:40:21 +00:00
< p align = "center" > < font face = "Arial" > < font size = "4" style = "font-size: 14pt" > < b > ADVANCED
MATRIX OPERATIONS< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "311" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Calculating
the covariance matrix < br > of 3 random variables < br > < br > (here:
covariances of the means < br > of x1, x2, and x3)< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
x1 = [4.0000 4.2000 3.9000 4.3000 4.1000]’ < br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
x2 = [2.0000 2.1000 2.0000 2.1000 2.2000]'< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
x3 = [0.60000 0.59000 0.58000 0.62000 0.63000]’ < br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
cov( [x1,x2,x3] )< br > ans =< br > 2.5000e-02
7.5000e-03 1.7500e-03< br > 7.5000e-03
7.0000e-03 1.3500e-03< br > 1.7500e-03
1.3500e-03 4.3000e-04< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
x1 = np.array([ 4, 4.2, 3.9, 4.3, 4.1])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
x2 = np.array([ 2, 2.1, 2, 2.1, 2.2])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
x3 = np.array([ 0.6, 0.59, 0.58, 0.62, 0.63])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
np.cov([x1, x2, x3])< br > Array([[ 0.025 , 0.0075 ,
0.00175],< br > [ 0.0075 , 0.007
, 0.00135],< br > [ 0.00175,
0.00135, 0.00043]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
x1 = matrix(c(4, 4.2, 3.9, 4.3, 4.1), ncol=5)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
x2 = matrix(c(2, 2.1, 2, 2.1, 2.2), ncol=5)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
x3 = matrix(c(0.6, 0.59, 0.58, 0.62, 0.63), ncol=5)
< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
cov(matrix(c(x1, x2, x3), ncol=3))< br > [,1] [,2] [,3]< br > [1,]
0.02500 0.00750 0.00175< br > [2,] 0.00750 0.00700 0.00135< br > [3,]
0.00175 0.00135 0.00043< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
x1=[4.0 4.2 3.9 4.3 4.1]';< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
x2=[2. 2.1 2. 2.1 2.2]';< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
x3=[0.6 .59 .58 .62 .63]';< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
cov([x1 x2 x3])< br > 3x3 Array{Float64,2}:< br > 0.025 0.0075
0.00175< br > 0.0075 0.007 0.00135< br > 0.00175 0.00135 0.00043< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Calculating
the covariance matrix < br > of 3 random variables < br > < br > (here:
covariances of the means < br > of x1, x2, and x3)< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "309" bgcolor = "#cfe7f5" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Calculating < br > eigenvectors
and eigenvalues< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = [3 1; 1 3]< br > A =< br > 3 1< br > 1
3< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
[eig_vec,eig_val] = eig(A)< br > eig_vec =< br > -0.70711
0.70711< br > 0.70711 0.70711< br > eig_val
=< br > Diagonal Matrix< br > 2 0< br > 0
4< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = np.array([[3, 1], [1, 3]])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
A< br > array([[3, 1],< br > [1, 3]])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
eig_val, eig_vec = np.linalg.eig(A)< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
eig_val< br > array([ 4., 2.])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
eig_vec< br > Array([[ 0.70710678, -0.70710678],< br >
[ 0.70710678, 0.70710678]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A = matrix(c(3,1,1,3), ncol=2)< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
A< br > [,1] [,2]< br > [1,] 3 1< br > [2,] 1 3< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
eigen(A)< br > $values< br > [1] 4 2< br > < br > $vectors< br > [,1] [,2]< br > [1,]
0.7071068 -0.7071068< br > [2,] 0.7071068 0.7071068< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
A=[3 1; 1 3]< br > 2x2 Array{Int64,2}:< br > 3 1< br > 1 3< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
(eig_vec,eig_val)=eig(a)< br > ([2.0,4.0],< br > 2x2
Array{Float64,2}:< br > -0.707107 0.707107< br > 0.707107 0.707107)< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#cfe7f5" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Calculating < br > eigenvectors
and eigenvalues< / b > < / font > < / font > < / p >
< / td >
< / tr >
< tr valign = "top" >
2014-07-18 18:13:22 +00:00
< td width = "171" height = "542" 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" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Generating
a Gaussian dataset:< br > < br > creating random vectors from the
multivariate normal< br > distribution given mean and covariance
matrix< br > < br > (here: 5 random vectors with < br > mean 0, covariance
= 0, variance = 2)< / b > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "174" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: none; border-right: 1px dotted #000000; padding-top: 0in; padding-bottom: 0in; padding-left: 0in; padding-right: 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > %
2014-06-06 03:40:21 +00:00
requires statistics toolbox package< br > % how to install and load
it in Octave:< br > < br > % download the package from: < br > %
http://octave.sourceforge.net/packages.php< br > % pkg install < br > %
~/Desktop/io-2.0.2.tar.gz < br > % pkg install < br > %
~/Desktop/statistics-1.2.3.tar.gz< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
pkg load statistics< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
mean = [0 0]< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
cov = [2 0; 0 2]< br > cov =< br > 2 0< br > 0
2< br > < br > < font color = "#006699" > < font size = "2" style = "font-size: 10pt" > < b > M> < / b > < / font > < / font >
mvnrnd(mean,cov,5)< br > 2.480150 -0.559906< br >
-2.933047 0.560212< br > 0.098206
3.055316< br > -0.985215 -0.990936< br > 1.122528
0.686977< br > < / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "128" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
2014-06-06 03:40:21 +00:00
mean = np.array([0,0])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
cov = np.array([[2,0],[0,2]])< br > < br > < font color = "#ff420e" > < font size = "2" style = "font-size: 10pt" > < b > P> < / b > < / font > < / font >
np.random.multivariate_normal(mean, cov, 5)< br > < br > Array([[
1.55432624, -1.17972629], < br >
[-2.01185294, 1.96081908], < br >
[-2.11810813, 1.45784216], < br >
[-2.93207591, -0.07369322], < br >
[-1.37031244, -1.18408792]])< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "136" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: 1px dotted #000000; padding: 0in 0.02in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > #
2014-06-06 03:40:21 +00:00
requires the ‘ mass’ package< br > < br >
< font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
install.packages('MASS')< br > < br >
< font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
library(MASS)
< br > < br > < font color = "#0000ff" > < font size = "2" style = "font-size: 10pt" > < b > R> < / b > < / font > < / font >
mvrnorm(n=10, mean, cov)< br > [,1] [,2]< br > [1,] -0.8407830
-0.1882706< br > [2,] 0.8496822 -0.7889329< br > [3,] -0.1564171
0.8422177< br > [4,] -0.6288779 1.0618688< br > [5,] -0.5103879
0.1303697< br > [6,] 0.8413189 -0.1623758< br > [7,] -1.0495466
-0.4161082< br > [8,] -1.3236339 0.7755572< br > [9,] 0.2771013
1.4900494< br > [10,] -1.3536268 0.2338913< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "126" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px dotted #000000; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in" >
< p align = "left" > < font face = "monospace" > < font size = "1" style = "font-size: 8pt" > #
2014-06-06 03:40:21 +00:00
requires the Distributions package from
https://github.com/JuliaStats/Distributions.jl< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
using Distributions< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
mean=[0., 0.]< br > 2-element Array{Float64,1}:< br > 0.0< br > 0.0< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
cov=[2. 0.; 0. 2.]< br > 2x2 Array{Float64,2}:< br > 2.0 0.0< br > 0.0
2.0< br > < br > < font color = "#9966cc" > < font size = "2" style = "font-size: 10pt" > < b > J> < / b > < / font > < / font >
rand( MvNormal(mean, cov), 5)< br > 2x5 Array{Float64,2}:< br > -0.527634
0.370725 -0.761928 -3.91747 1.47516< br > -0.448821 2.21904 2.24561
0.692063 0.390495< / font > < / font > < / p >
< / td >
2014-07-18 18:13:22 +00:00
< td width = "188" bgcolor = "#ffffff" style = "border-top: none; border-bottom: none; border-left: 1px solid #000000; border-right: 1px solid #000000; padding: 0in 0.02in" >
2014-06-06 03:40:21 +00:00
< p align = "left" > < font face = "Arial" > < font size = "2" style = "font-size: 10pt" > < b > Generating
a Gaussian dataset:< br > < br > creating random vectors from the
multivariate normal< br > distribution given mean and covariance
matrix< br > < br > (here: 5 random vectors with < br > mean 0, covariance
= 0, variance = 2)< / b > < / font > < / font > < / p >
< / td >
< / tr >
< / table >
< p > <!-- ************************************************************************** --> < br > < br >
< / p >
< / body >
< / html >