convenient functions in numpy

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]])
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

五道口纳什

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值