Python生成高斯随机数(标准正态分布随机数)

代码np.random.normal(loc=0.0, scale=1.0, size=None)

import random
import numpy as np
x=[]
for i in range(100):
    a=np.random.normal(loc=0.0, scale=1.0, size=None)
    x.append(a)
print(x)

对应的参数:

loc:均值
scale:标准差
size:输出形式/维度

输出示例:

[-0.27253811517094106, 0.5609684144467797, 0.334971283784437, -0.1822778169662192, 1.2681223959150012, 1.2328794595153236, -0.3123326943041807, 0.1509173477179033, 0.26710212597423183, -0.7132879236969326, 1.4473196811471687, 0.6774980094513453, -1.6030403311814199, 0.8648297512590672, 0.9541298220551128, 0.19975976654455535, 0.39949933286608913, 0.6426455545555159, -0.7099122674171993, -1.0921728091444043, -1.1605676669247265, -0.5213446266079783, -1.0729374918398586, -0.42508116246866895, -2.1225656950542566, -0.018079339358717344, -0.3967882207036764, -0.11615681742789798, 0.3959781462653823, -0.4422546552470426, -0.45658310669718555, -0.41665303539298026, 0.4106375960351183, 0.7946145527667485, 0.40155698536767886, -0.43160558716163333, -0.8187458265642145, 0.4733591470772272, -0.512925141874276, 0.8942315459113407, -0.18699899393413216, -1.920234569791857, -1.3199069899730669, -0.12743885240423444, -0.06967172106188232, -0.2246066523578624, 0.03641342849134644, -0.053470943398817916, 1.1744274015249043, -0.9435170352866044, -0.11353662588737247, -1.8692171469851853, -0.476445232927885, -0.2708492260528827, -0.11651492597485748, 0.02964131159954893, 0.25578306216680463, 1.2023111385087462, 1.122831951168718, -0.7308969156174356, 0.3811122809887224, 0.335473588586483, -1.1167554592019655, -1.1514348899396745, 0.7231538350180756, 0.9542725371333689, -1.831688480671393, 0.09182126579647497, 0.1739749571732342, 0.620176859551349, 0.6958403843497568, -1.090884581324445, 0.7600870398395901, -1.030191097275002, -0.7290470403280889, 0.06036403155582693, -0.2664700890089135, -0.3855530279087296, 0.6286878598349667, -0.8480215298426873, -1.180616696418588, -1.005016623815381, 1.042715871847052, -0.38178882402768816, 0.31263870120857723, 2.3554699344809262, 0.36228557870792766, -0.7734401711015115, 1.1189369662279494, -0.38014393103580185, -0.8177391087304116, -0.793471802195223, 0.6238413958778506, 1.0469161789217385, -1.4572003375874896, 1.1824881239007394, 0.3499870978487047, 0.06894617572574108, -0.6243622120335651, 0.8697811358505547]

你可能感兴趣的:(python,numpy)