import numpy as np
import scipy.stats as st
np.random.rand(d0, d1, …, dn)
仅表示服从 ∼U[0,1] (0-1均匀分布)的随机变量,参数控制维度。
>>> np.random.rand(2, 3)
array([[ 0.33265357, 0.03494197, 0.02490148],
[ 0.95236337, 0.98037261, 0.83386163]])
st.norm()
st.norm():表示标准正太分布;
st.norm().pdf(x):表示标准正太分布的概率密度函数;
标准正态分布的概率密度函数也即:
f(x)=12π−−√exp(−x22)
f(0)=12π√≈0.3989422804014327
>>> st.norm().pdf(0)
0.3989422804014327
np.r_, np.c_
两者均不是函数;
np.r_:Translates slice objects to concatenation along the first axis.在第一个轴上(axis=0)进行拼接,
np.r_[np.array([1, 2, 3]), 0, 0, np.array([4, 5, 6])]
array([1, 2, 3, 0, 0, 4, 5, 6])
np.c_:Translates slice objects to concatenation along the second axis.在第二个轴上(axis=1)进行拼接
>>> np.c_[np.array([[1,2,3]]), 0, 0, np.array([[4,5,6]])]
array([[1, 2, 3, 0, 0, 1, 2, 3]])