修訂. | 6612252ca3b5cc2900a43872987f35bd8ffc9d21 |
---|---|
大小 | 344 bytes |
時間 | 2024-06-26 04:53:05 |
作者 | Lorenzo Isella |
Log Message | I simple python script showcasing new.axis to quickly define a matrix in Python. |
import numpy as np
#Now it is time to evaluate the matrix N_mat[i,j]=n[i]n[j]
n= np.arange(4)
n
m=np.arange(6)
m
## Now I will define the matrix N_mat[i,j]=m[i]*n[j] with 6 rows
## and 4 columns
N_mat=m[:,np.newaxis]*n[np.newaxis,:]
N_mat
## which is very close to the mathematical definition. Can I achieve something
## similar in R?