python⽣成t分布随机数_numpy教程:随机数模块
numpy.random
随机数种⼦
RandomState
RandomState exposes a number of methods for generating random numbersdrawn from a variety of probability distributions.
使⽤⽰例
prng = np.random.RandomState(123456789) # 定义局部种⼦
prng.rand(2, 4)
prng.chisquare(1, size=(2, 2)) # 卡⽅分布
prng.standard_t(1, size=(2, 3)) # t 分布
prng.poisson(5, size=10) # 泊松分布
random.seed()
random.seed(123456789) # 种⼦不同,产⽣的随机数序列也不同,随机数种⼦都是全局种⼦
要每次产⽣随机数相同就要设置种⼦,相同种⼦数的Random对象,相同次数⽣成的随机数字是完全相同的;
random.seed(1)
python生成1到100之间随机数这样random.randint(0,6, (4,5))每次都产⽣⼀样的4*5的随机矩阵
This method is called when RandomState is initialized. It can be called again to re-seed the generator.
numpy.random模块
linspace(start, end, num): 如linspace(0,1,11)结果为[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1];
arange(n): 产⽣⼀个从0到n-1的向量,如arange(4)结果为[0,1,2,3]
简单随机⽣成数据相关函

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。