Github Pattern Classification Matrix Cheatsheet Table
Github Pattern Classification Matrix Cheatsheet Table
sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
MATLAB/Octave
Task
PythonNumPy
Julia
Task
CREATINGMATRICES
CreatingMatrices
(here:3x3matrix)
M>A=[123;456;789]
A=
123
456
789
P>A=np.array([[1,2,3],
[4,5,6],[7,8,9]])
P>A
array([[1,2,3],
[4,5,6],
[7,8,9]])
R>A=
J>A=[123;456;789]
matrix(c(1,2,3,4,5,6,7,8,9),nrow=3,byrow=T) 3x3Array{Int64,2}:
123
#equivalentto
456
#A=matrix(1:9,nrow=3,byrow=T)
789
CreatingMatrices
(here:3x3matrix)
R>A
[,1][,2][,3]
[1,]123
[2,]456
[3,]789
Creatingan1D
columnvector
Creatingan
1Drowvector
M>a=[1;2;3]
a=
1
2
3
M>b=[123]
b=
123
P>a=
np.array([1,2,3]).reshape(1,3)
R>a=matrix(c(1,2,3),nrow=3,byrow=T)
R>a
(1,3)
[,1]
[1,]1
[2,]2
[3,]3
P>b=np.array([1,2,3])
R>b=matrix(c(1,2,3),ncol=3)
P>b
R>b
P>b.shape
array([1,2,3])
[,1][,2][,3]
[1,]123
#notethatnumpydoesn'thave
#explicitrowvectors,but1D
#arrays
J>a=[1;2;3]
Creatingan1D
columnvector
J>b=[123]
Creatingan
1Drowvector
3elementArray{Int64,1}:
1
2
3
1x3Array{Int64,2}:
123
#notethatthisisa2Darray.
#vectorsinJuliaarecolumns
P>b.shape
(3,)
Creatinga
randommxn
matrix
M>rand(3,2)
P>np.random.rand(3,2)
R>matrix(runif(3*2),ncol=2)
array([[0.29347865,0.17920462], [,1][,2]
[0.51615758,0.64593471], [1,]0.56751270.7751204
[0.01067605,0.09692771]]) [2,]0.34394120.5261893
[3,]0.22731770.223438
J>rand(3,2)
Creatinga
randommxnmatrix
Creatinga
zeromxnmatrix
M>zeros(3,2)
P>np.zeros((3,2))
J>zeros(3,2)
Creatinga
zeromxnmatrix
ans=
0.219770.10220
0.389590.69911
0.156240.65637
ans=
00
00
00
array([[0.,0.],
[0.,0.],
[0.,0.]])
http://sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
R>mat.or.vec(3,2)
[,1][,2]
[1,]00
[2,]00
[3,]00
3x2Array{Float64,2}:
0.368820.267725
0.5718560.601524
0.8480840.858935
3x2Array{Float64,2}:
0.00.0
0.00.0
0.00.0
2/10
1/3/2015
sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
Creatingan
M>ones(3,2)
mxnmatrixofones ans=
11
11
11
P>np.ones((3,2))
array([[1.,1.],
[1.,1.],
[1.,1.]])
R>matrix(1L,3,2)
[,1][,2]
[1,]11
[2,]11
[3,]11
J>ones(3,2)
Creatingan
mxnmatrixofones
3x2Array{Float64,2}:
1.01.0
1.01.0
1.01.0
Creatingan
identitymatrix
M>eye(3)
P>np.eye(3)
R>diag(3)
J>eye(3)
Creatingan
identitymatrix
Creatinga
diagonalmatrix
M>a=[123]
P>a=np.array([1,2,3])
R>diag(1:3)
J>a=[1,2,3]
M>diag(a)
P>np.diag(a)
Creatinga
diagonalmatrix
ans=
DiagonalMatrix
100
010
001
ans=
DiagonalMatrix
100
020
003
array([[1.,0.,0.],
[0.,1.,0.],
[0.,0.,1.]])
array([[1,0,0],
[0,2,0],
[0,0,3]])
[,1][,2][,3]
[1,]100
[2,]010
[3,]001
[,1][,2][,3]
[1,]100
[2,]020
[3,]003
3x3Array{Float64,2}:
1.00.00.0
0.01.00.0
0.00.01.0
#addedcommasbecausejulia
#vectorsarecolumnar
J>diagm(a)
3x3Array{Int64,2}:
100
020
003
ACCESSINGMATRIXELEMENTS
Gettingthe
dimension
ofamatrix
(here:2D,rowsx
cols)
M>A=[123;456]
A=
123
456
M>size(A)
ans=
23
P>A=np.array([[1,2,3],[4,5,6] R>A=matrix(1:6,nrow=2,byrow=T)
])
P>A
array([[1,2,3],
[4,5,6]])
[,1][,2][,3]
[1,]123
[2,]456
P>A.shape
R>dim(A)
2x3Array{Int64,2}:
123
456
J>size(A)
Gettingthe
dimension
ofamatrix
(here:2D,rowsx
cols)
(2,3)
(2,3)
Selectingrows
R>A
J>A=[123;456]
M>A=[123;456;789]
P>A=np.array([[1,2,3],
%1strow
M>A(1,:)
ans=
123
#1strow
P>A[0,:]
array([1,2,3])
[4,5,6],[7,8,9]])
http://sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
[1]23
R>A=matrix(1:9,nrow=3,byrow=T)
#1strow
>A[1,]
R
[1]123
J>A=[123;456;789];
Selectingrows
#semicolonsuppressesoutput
#1strow
J>A[1,:]
1x3Array{Int64,2}:
3/10
1/3/2015
Selectingcolumns
sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
#1st2rows
P>A[0:2,:]
array([[1,2,3],[4,5,6]])
#1st2rows
R>A[1:2,]
[,1][,2][,3]
[1,]123
[2,]456
123
%1st2rows
M>A(1:2,:)
ans=
123
456
M>A=[123;456;789]
P>A=np.array([[1,2,3],
R>A=matrix(1:9,nrow=3,byrow=T)
J>A=[123;456;789];
#1stcolumn(asrowvector)
P>A[:,0]
array([1,4,7])
#1stcolumnasrowvector
R>t(A[,1])
[,1][,2][,3]
[1,]147
#1stcolumn
J>A[:,1]
3elementArray{Int64,1}:
1
4
7
%1stcolumn
M>A(:,1)
ans=
1
4
7
%1st2columns
M>A(:,1:2)
ans=
12
45
78
[4,5,6],[7,8,9]])
#1stcolumn(ascolumnvector)
P>A[:,[0]]
array([[1],
[4],
[7]])
#1st2columns
P>A[:,0:2]
array([[1,2],
[4,5],
[7,8]])
Extractingrowsand M>A=[123;459;789]
columnsbycriteria A=
P>A=np.array([[1,2,3],
(here:getrowsthat 459
789
havevalue9in
column3)
M>A(A(:,3)==9,:)
P>A
[4,5,9],[7,8,9]])
123
ans=
459
789
Accessingelements M>A=[123;456;789]
(here:1stelement)
M>A(1,1)
ans=1
#1stcolumnascolumnvector
R>A[,1]
[1]147
#1st2columns
R>A[,1:2]
[,1][,2]
[1,]12
[2,]45
[3,]78
R>A=matrix(1:9,nrow=3,byrow=T)
R>A
array([[1,2,3],
[4,5,9],
[7,8,9]])
[,1][,2][,3]
[1,]123
[2,]459
[3,]789
P>A[A[:,2]==9]
R>A[A[,3]==9,]
array([[4,5,9],
[7,8,9]])
[1]789
P>A=np.array([[1,2,3],
R>A=
P>A[0,0]
>A[1,1]
R
[1]1
[4,5,6],[7,8,9]])
http://sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
#1st2rows
J>A[1:2,:]
2x3Array{Int64,2}:
123
456
Selectingcolumns
#1st2columns
J>A[:,1:2]
3x2Array{Int64,2}:
12
45
78
J>A=[123;459;789]
3x3Array{Int64,2}:
123
459
789
#use'.=='for
#elementwisecheck
J>A[A[:,3].==9,:]
2x3Array{Int64,2}:
459
789
J>A=[123;456;789];
matrix(c(1,2,3,4,5,9,7,8,9),nrow=3,byrow=T)
J>A[1,1]
Extractingrowsand
columnsbycriteria
(here:getrowsthat
havevalue9in
column3)
Accessingelements
(here:1stelement)
4/10
1/3/2015
sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
MANIPULATINGSHAPEANDDIMENSIONS
Converting
amatrixintoarow
vector(bycolumn)
M>A=[123;456;789]
M>A(:)
ans=
P>A=np.array([[1,2,3],[4,5,6],
[7,8,9]])
array([1,4,7,2,5,8,3,6,9])
R>as.vector(A)
[1]147258369
M>b=[123]
P>b=np.array([1,2,3])
R>b=matrix(c(1,2,3),ncol=3)
M>b=b'
P>b=b[np.newaxis].T
R>t(b)
b=
1
2
3
#alternatively
#b=b[:,np.newaxis]
J>A=[123;456;789]
J>vec(A)
P>A.flatten(1)
1
4
7
2
5
8
3
6
9
Converting
rowtocolumn
vectors
R>A=matrix(1:9,nrow=3,byrow=T)
P>b
[,1]
[1,]1
[2,]2
[3,]3
ReshapingMatrices M>A=[123;456;789]
P>A=np.array([[1,2,3],[4,5,6],
R>A=matrix(1:9,nrow=3,byrow=T)
(here:3x3matrixto
rowvector)
P>A
Converting
amatrixintoarow
vector(bycolumn)
9elementArray{Int64,1}:
1
4
7
2
5
8
3
6
9
J>b=vec([123])
Converting
rowtocolumn
vectors
J>A=[123;456;789]
ReshapingMatrices
3elementArray{Int64,1}:
1
2
3
array([[1],
[2],
[3]])
A=
123
456
789
[7,8,9]])
R>A
M>total_elements=numel(A)
array([[1,2,3],
[4,5,9],
[7,8,9]])
[,1][,2][,3]
[1,]123
[2,]456
[3,]789
M>B=reshape(A,1,total_elements)
P>total_elements=
R>total_elements=dim(A)[1]*dim(A)[2]
%orreshape(A,1,9)
B=
147258369
3x3Array{Int64,2}:
123
456
789
(here:3x3matrixto
rowvector)
J>total_elements=length(A)
9
np.prod(A.shape)
R>B=matrix(A,ncol=total_elements)
P>B=A.reshape(1,
total_elements)
#alternativeshortcut:
#A.reshape(1,1)
J>B=reshape(A,1,total_elements)
1x9Array{Int64,2}:
147258369
R>B
[,1][,2][,3][,4][,5][,6][,7][,8]
[,9]
[1,]147258369
P>B
array([[1,2,3,4,5,6,7,8,
9]])
Concatenating
matrices
M>A=[123;456]
M>B=[789;101112]
M>C=[A;B]
123
456
789
101112
P>A=np.array([[1,2,3],[4,5, R>A=matrix(1:6,nrow=2,byrow=T)
6]])
J>A=[123;456];
R>B=matrix(7:12,nrow=2,byrow=T)
J>B=[789;101112];
[10,11,12]])
R>C=rbind(A,B)
J>C=[A;B]
P>C=np.concatenate((A,B),
R>C
P>B=np.array([[7,8,9],
axis=0)
P>C
http://sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
[,1][,2][,3]
[1,]123
[2,]456
Concatenating
matrices
4x3Array{Int64,2}:
123
456
789
101112
5/10
1/3/2015
sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
Stacking
M>a=[123]
vectorsandmatrices
M>b=[456]
M>c=[a'b']
c=
14
25
36
M>c=[a;b]
array([[1,2,3],
[4,5,6],
[7,8,9],
[10,11,12]])
[3,]789
[4,]101112
P>a=np.array([1,2,3])
P>b=np.array([4,5,6])
R>a=matrix(1:3,ncol=3)
J>a=[123];
R>b=matrix(4:6,ncol=3)
J>b=[456];
R>matrix(rbind(A,B),ncol=2)
J>c=[a'b']
P>np.c_[a,b]
array([[1,4],
[2,5],
[3,6]])
[,1][,2]
[1,]15
[2,]43
P>np.r_[a,b]
>rbind(A,B)
R
[,1][,2][,3]
[1,]123
[2,]456
array([[1,2,3],
[4,5,6]])
c=
123
456
Stacking
vectorsandmatrices
3x2Array{Int64,2}:
14
25
36
J>c=[a;b]
2x3Array{Int64,2}:
123
456
BASICMATRIXOPERATIONS
Matrixscalar
operations
M>A=[123;456;789]
M>A*2
P>A=np.array([[1,2,3],
[4,5,6],[7,8,9]])
R>A=matrix(1:9,nrow=3,byrow=T)
J>A=[123;456;789];
R>A*2
#elementwiseoperator
ans=
246
81012
141618
P>A*2
array([[2,4,6],
[8,10,12],
[14,16,18]])
[,1][,2][,3]
[1,]246
[2,]81012
[3,]141618
M>A+2
P>A+2
R>A+2
M>A2
P>A2
R>A2
J>A.+2;
M>A/2
P>A/2
R>A/2
J>A.2;
M>A=[123;456;789]
M>A*A
ans=
303642
668196
102126150
P>A=np.array([[1,2,3],
[4,5,6],[7,8,9]])
P>np.dot(A,A)#orA.dot(A)
array([[30,36,42],
[66,81,96],
[102,126,150]])
http://sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
J>A.*2
3x3Array{Int64,2}:
246
81012
141618
J>A./2;
#NotethatNumPywasoptimizedfor
#inplaceassignments
#e.g.,A+=Ainsteadof
#A=A+A
Matrixmatrix
multiplication
Matrixscalar
operations
R>A=matrix(1:9,nrow=3,byrow=T)
J>A=[123;456;789];
R>A%*%A
J>A*A
[,1][,2][,3]
[1,]303642
[2,]668196
[3,]102126150
Matrixmatrix
multiplication
3x3Array{Int64,2}:
303642
668196
102126150
6/10
1/3/2015
Matrixvector
multiplication
sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
M>A=[123;456;789]
M>b=[1;2;3]
M>A*b
Elementwise
matrix
matrixoperations
P>A=np.array([[1,2,3],
[4,5,6],[7,8,9]])
P>b=np.array([[1],[2],[3]])
ans=
14
32
50
P>np.dot(A,b)#orA.dot(b)
M>A=[123;456;789]
P>A=np.array([[1,2,3],
M>A.*A
array([[14],[32],[50]])
[4,5,6],[7,8,9]])
R>A=matrix(1:9,ncol=3)
J>A=[123;456;789];
R>b=matrix(1:3,nrow=3)
J>b=[1;2;3];
R>t(b%*%A)
[,1]
[1,]14
[2,]32
[3,]50
J>A*b
R>A=matrix(1:9,nrow=3,byrow=T)
J>A=[123;456;789];
R>A*A
J>A.*A
Matrixvector
multiplication
3elementArray{Int64,1}:
14
32
50
ans=
149
162536
496481
P>A*A
array([[1,4,9],
[16,25,36],
[49,64,81]])
[,1][,2][,3]
[1,]149
[2,]162536
[3,]496481
M>A.+A
P>A+A
R>A+A
J>A.+A;
M>A.A
P>AA
R>AA
J>A.A;
M>A./A
P>A/A
R>A/A
J>A./A;
R>A=matrix(1:9,nrow=3,byrow=T)
J>A=[123;456;789];
R>A^2
J>A.^2
3x3Array{Int64,2}:
149
162536
496481
Elementwise
matrix
matrixoperations
#NotethatNumPywasoptimizedfor
#inplaceassignments
#e.g.,A+=Ainsteadof
#A=A+A
Matrixelementsto
powern
M>A=[123;456;789]
(here:individual
elementssquared)
ans=
149
162536
496481
P>np.power(A,2)
array([[1,4,9],
[16,25,36],
[49,64,81]])
[,1][,2][,3]
[1,]149
[2,]162536
[3,]496481
Matrixtopowern
M>A=[123;456;789]
P>A=np.array([[1,2,3],
M>A.^2
M>A^2
(here:matrix
matrixmultiplication ans=
303642
withitself)
668196
102126150
P>A=np.array([[1,2,3],
[4,5,6],[7,8,9]])
[4,5,6],[7,8,9]])
P>np.linalg.matrix_power(A,2)
array([[30,36,42],
[66,81,96],
[102,126,150]])
Matrixelementsto
powern
3x3Array{Int64,2}:
149
162536
496481
(here:individual
elementssquared)
R>A=matrix(1:9,ncol=3)
J>A=[123;456;789];
Matrixtopowern
#requirestheexpmpackage
J>A^2
(here:matrix
matrixmultiplication
withitself)
R>install.packages('expm')
R>library(expm)
3x3Array{Int64,2}:
303642
668196
102126150
>A%^%2
R
[,1][,2][,3]
[1,]3066102
[2,]3681126
[3,]4296150
http://sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
7/10
1/3/2015
Matrixtranspose
sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
M>A=[123;456;789]
M>A'
ans=
147
258
369
P>A=np.array([[1,2,3],
[4,5,6],[7,8,9]])
R>A=matrix(1:9,nrow=3,byrow=T)
R>t(A)
P>A.T
array([[1,4,7],
[2,5,8],
[3,6,9]])
[,1][,2][,3]
[1,]147
[2,]258
[3,]369
J>A=[123;456;789]
Matrixtranspose
3x3Array{Int64,2}:
123
456
789
J>A'
3x3Array{Int64,2}:
147
258
369
Determinantofa
matrix:
A>|A|
M>A=[611;425;287]
A=
611
425
287
M>det(A)
P>A=np.array([[6,1,1],[4,2,5], R>A=matrix(c(6,1,1,4,2,5,2,8,7),
[2,8,7]])
nrow=3,byrow=T)
P>A
R>A
array([[6,1,1],
[4,2,5],
[2,8,7]])
ans=306
P>np.linalg.det(A)
306.0
[,1][,2][,3]
[1,]611
[2,]425
[3,]287
J>A=[611;425;287]
3x3Array{Int64,2}:
611
425
287
Determinantofa
matrix:
A>|A|
J>det(A)
306.0
R>det(A)
[1]306
Inverseofamatrix
M>A=[47;26]
A=
47
26
M>A_inv=inv(A)
A_inv=
0.600000.70000
0.200000.40000
P>A=np.array([[4,7],[2,6]])
R>A=matrix(c(4,7,2,6),nrow=2,byrow=T) J>A=[47;26]
P>A
R>A
array([[4,7],
[2,6]])
[,1][,2]
[1,]47
[2,]26
P>A_inverse=np.linalg.inv(A)
P>A_inverse
array([[0.6,0.7],
[0.2,0.4]])
R>solve(A)
[,1][,2]
[1,]0.60.7
[2,]0.20.4
Inverseofamatrix
2x2Array{Int64,2}:
47
26
J>A_inv=inv(A)
2x2Array{Float64,2}:
0.60.7
0.20.4
ADVANCEDMATRIXOPERATIONS
Calculatingthe
covariancematrix
of3random
variables
M>x1=[4.00004.20003.90004.3000
P>x1=np.array([4,4.2,3.9,
M>x2=[2.00002.10002.00002.1000
P>x2=np.array([2,2.1,2,2.1, R>x2=matrix(c(2,2.1,2,2.1,2.2),
4.1000]
2.2000]'
(here:covariancesof
M>x3=[0.600000.590000.580000.62000
themeans
0.63000]
4.3,4.1])
R>x1=matrix(c(4,4.2,3.9,4.3,4.1),
ncol=5)
J>x1=[4.04.23.94.34.1]';
J>x2=[2.2.12.2.12.2]';
2.2])
ncol=5)
J>x3=[0.6.59.58.62.63]';
P>x3=np.array([0.6,0.59,
R>x3=matrix(c(0.6,0.59,0.58,0.62,
J>cov([x1x2x3])
0.58,0.62,0.63])
http://sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
0.63),ncol=5)
3x3Array{Float64,2}:
Calculatingthe
covariancematrix
of3random
variables
(here:covariancesof
themeans
8/10
1/3/2015
ofx1,x2,andx3)
sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
M>cov([x1,x2,x3])
P>np.cov([x1,x2,x3])
R>cov(matrix(c(x1,x2,x3),ncol=3))
0.0250.00750.00175
0.00750.0070.00135
0.001750.001350.00043
ofx1,x2,andx3)
M>A=[31;13]
P>A=np.array([[3,1],[1,3]])
R>A=matrix(c(3,1,1,3),ncol=2)
J>A=[31;13]
P>A
R>A
Calculating
eigenvectors
andeigenvalues
ans=
2.5000e027.5000e031.7500e03
7.5000e037.0000e031.3500e03
1.7500e031.3500e034.3000e04
Calculating
eigenvectors
andeigenvalues
A=
31
13
M>[eig_vec,eig_val]=eig(A)
Generatinga
Gaussiandataset:
creatingrandom
vectorsfromthe
multivariatenormal
distributiongiven
meanand
covariancematrix
(here:5random
vectorswith
mean0,covariance
=0,variance=2)
Array([[0.025,0.0075,
0.00175],
[0.0075,0.007,
0.00135],
[0.00175,0.00135,
0.00043]])
array([[3,1],
[1,3]])
eig_vec=
0.707110.70711
0.707110.70711
eig_val=
DiagonalMatrix
20
04
P>eig_val,eig_vec=
%requiresstatisticstoolboxpackage
%howtoinstallandloaditinOctave:
P>mean=np.array([0,0])
np.linalg.eig(A)
P>eig_val
[,1][,2][,3]
[1,]0.025000.007500.00175
[2,]0.007500.007000.00135
[3,]0.001750.001350.00043
[,1][,2]
[1,]31
[2,]13
R>eigen(A)
$values
[1]42
2x2Array{Int64,2}:
31
13
J>(eig_vec,eig_val)=eig(a)
([2.0,4.0],
2x2Array{Float64,2}:
0.7071070.707107
0.7071070.707107)
array([4.,2.])
$vectors
[,1][,2]
Array([[0.70710678,0.70710678], [1,]0.70710680.7071068
[0.70710678,0.70710678]]) [2,]0.70710680.7071068
P>eig_vec
#requiresthemasspackage
>install.packages('MASS')
R
P>cov=np.array([[2,0],[0,2]])
%downloadthepackagefrom:
%
R>library(MASS)
P>
http://octave.sourceforge.net/packages.php
np.random.multivariate_normal(mean,
%pkginstall
cov,5)
R>mvrnorm(n=10,mean,cov)
%~/Desktop/io2.0.2.tar.gz
[,1][,2]
%pkginstall
Array([[1.55432624,1.17972629], [1,]0.84078300.1882706
%~/Desktop/statistics1.2.3.tar.gz
[2.01185294,1.96081908], [2,]0.84968220.7889329
[2.11810813,1.45784216], [3,]0.15641710.8422177
M>pkgloadstatistics
[2.93207591,0.07369322], [4,]0.62887791.0618688
[1.37031244,1.18408792]]) [5,]0.51038790.1303697
M>mean=[00]
[6,]0.84131890.1623758
[7,]1.04954660.4161082
M>cov=[20;02]
[8,]1.32363390.7755572
cov=
[9,]0.27710131.4900494
20
[10,]1.35362680.2338913
02
#requirestheDistributionspackagefrom
Generatinga
https://github.com/JuliaStats/Distributions.jl Gaussiandataset:
J>usingDistributions
J>mean=[0.,0.]
2elementArray{Float64,1}:
0.0
0.0
J>cov=[2.0.;0.2.]
2x2Array{Float64,2}:
2.00.0
0.02.0
J>rand(MvNormal(mean,cov),5)
creatingrandom
vectorsfromthe
multivariatenormal
distributiongiven
meanand
covariancematrix
(here:5random
vectorswith
mean0,covariance
=0,variance=2)
2x5Array{Float64,2}:
0.5276340.3707250.7619283.917471.47516
0.4488212.219042.245610.6920630.390495
M>mvnrnd(mean,cov,5)
2.4801500.559906
2.9330470.560212
0.0982063.055316
0.9852150.990936
1.1225280.686977
http://sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
9/10
1/3/2015
sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
http://sebastianraschka.com/github/pattern_classification/matrix_cheatsheet_table.html
10/10