博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
#np.random.normal,产生制定分布的数集(默认是标准正态分布)
阅读量:5105 次
发布时间:2019-06-13

本文共 1702 字,大约阅读时间需要 5 分钟。

http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.normal.html

 

 

#np.random.normal,产生制定分布的数集

#http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.normal.html
# mean and standard deviation
# 均值的物理意义mu,Mean (“centre”) of the distribution.
# 方差的物理意义sigma,Standard deviation (spread or “width”) of the distribution
import numpy as np
mu, sigma = 0, 0.1
s = np.random.normal(mu, sigma, 1000)
#验证均值和方差,是否和随机生成的一样
print(abs(mu - np.mean(s)) < 0.01)
print(abs(sigma - np.std(s, ddof=1)) < 0.01) #ddof不知道什么意思
import matplotlib.pyplot as plt
count, bins, ignored = plt.hist(s, 10, normed=True)
plt.plot(bins, 1/(sigma * np.sqrt(2 * np.pi)) *np.exp( - (bins - mu)**2 / (2 * sigma**2) ),linewidth=2, color='r')
plt.show()

numpy.random.normal

numpy.random.
normal
(
loc=0.0,
scale=1.0,
size=None
)

Draw random samples from a normal (Gaussian) distribution.

The probability density function of the normal distribution, first derived by De Moivre and 200 years later by both Gauss and Laplace independently , is often called the bell curve because of its characteristic shape (see the example below).

The normal distributions occurs often in nature. For example, it describes the commonly occurring distribution of samples influenced by a large number of tiny, random disturbances, each with its own unique distribution .

 

Parameters:

loc : float

Mean (“centre”) of the distribution.

scale : float

Standard deviation (spread or “width”) of the distribution.

size : int or tuple of ints, optional

Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. Default is None, in which case a single value is returned.

 

转载于:https://www.cnblogs.com/qqhfeng/p/5336293.html

你可能感兴趣的文章
Java Web开发后端常用技术汇总
查看>>
How to use jQuery countdown plugin
查看>>
富文本常用封装(NSAttributedString浅析)
查看>>
c++ STL
查看>>
json数据在前端(javascript)和后端(php)转换
查看>>
[Serializable]的应用--注册码的生成,加密和验证
查看>>
Groovy中那些神奇注解之ToString
查看>>
宇宙第一开发工具:vs2019 开发Python
查看>>
Tomcat Https配置
查看>>
待续--mysql中key 、primary key 、unique key 与index区别
查看>>
Day19内容回顾
查看>>
bootstrap分页
查看>>
洛谷 P1144 最短路计数 解题报告
查看>>
第七次作业
查看>>
c++map的用法
查看>>
js交互
查看>>
vim工具
查看>>
Openssl genrsa命令
查看>>
Openssl crl2pkcs7命令
查看>>
MySql update inner join!MySql跨表更新 多表update sql语句?如何将select出来的部分数据update到另一个表里面?...
查看>>