#np.random.normal,产生制定分布的数集(默认是标准正态分布)
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 [R250], 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 [R250].
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.
#np.random.normal,产生制定分布的数集(默认是标准正态分布)的更多相关文章
- np.random.normal()正态分布
高斯分布的概率密度函数 numpy中 numpy.random.normal(loc=0.0, scale=1.0, size=None) 参数的意义为: loc:float 概率分布的均值,对应着整 ...
- np.random.normal()
高斯分布(Gaussian Distribution)的概率密度函数(probability density function): \[ f(x)=\frac1{\sqrt{2\pi}\sigma}\ ...
- NP:建立可视化输入的二次函数数据点集np.linspace+np.random.shuffle+np.random.normal
import numpy as np import matplotlib.pyplot as plt def fix_seed(seed=1): #重复观看一样东西 # reproducible np ...
- np.random 系列函数
1 random() # 产生区间 [0, 1) 均匀分布的浮点数样本值 np.random.seed(42) 2 rand(d0, d1, ..., dn) # 产生区间 [0, 1) 均 ...
- np.random模块的使用介绍
np.random模块常用的一些方法介绍 名称 作用 numpy.random.rand(d0, d1, …, dn) 生成一个[d0, d1, …, dn]维的numpy数组,数组的元素取自[0, ...
- Numpy-np.random.normal()正态分布
X ~ :随机变量X的取值和其对应的概率值P(X = ) 满足正态分布(高斯函数) 很多随机现象可以用正态分布描述或者近似描述 某些概率分布可以用正态分布近似计算 正态分布(又称高斯分布)的概率密度函 ...
- np.random的随机数函数
np.random的随机数函数(1) 函数 说明 rand(d0,d1,..,dn) 根据d0‐dn创建随机数数组,浮点数, [0,1),均匀分布 randn(d0,d1,..,dn) 根据d0‐dn ...
- np.random.multivariate_normal方法浅析
从多元正态分布中抽取随机样本. 多元正态分布,多正态分布或高斯分布是一维正态分布向更高维度的推广.这种分布由其均值和协方差矩阵来确定.这些参数类似于一维正态分布的平均值(平均值或"中心&qu ...
- numpy中的np.random.mtrand.RandomState
1 RandomState 的应用场景概述 在训练神经网络时,苦于没有数据,此时numpy为我们提供了 “生产” 数据集的一种方式. 例如在搭建神经网络(一)中的 4.3 准备数据集 章节中就是采用n ...
随机推荐
- PHP的依赖管理工具----composer
安装Composer 参考:https://getcomposer.org/doc/01-basic-usage.md composer 是PHP依赖管理工具 PHP最低版本要求5.3.2,需要允许o ...
- Javaweb基础--->Servlet(转载)
今天看到这篇博客,感觉还不错,拿来借鉴学习一下. 一.Servlet 是什么? Java Servlet 是运行在 Web 服务器或应用服务器上的程序,它是作为来自 Web 浏览器或其他 HTTP 客 ...
- secureCRT linux shell显示中文乱码 解决方法
引:有没有这样的经历: 1.在shell中直接查看包含中文的文件时,出现一堆火星文,不得不下载下来window看. 2.无法正常的在shell中输入中文. 3.make的时候输出一堆乱码. 以下是查阅 ...
- SQL语法结构
目录 一.增 1.增加字段 2.新建约束 二.删 1.删除字段 2.删除约束 三.改 1.修改字段 一.增 1.增加字段: ALTER TABLE [表名] ADD [字段名] NVARCHAR () ...
- Hadoop1.x Shell命令
refer to http://hadoop.apache.org/docs/r1.0.4/cn/hdfs_shell.html FS Shell 调用文件系统(FS)Shell命令应使用 bin/h ...
- vim 真是上瘾啊
再次更新 .vimrc " leaderlet mapleader = ","nnoremap <leader>ev :vsplit ~/.vimrc< ...
- 每天一个Linux命令(24)tar命令
tar命令可以为linux的文件和目录创建档案. (1)用法: 用法: tar [选项] [文件参数] (2)功能: 功能: 用来压缩和解压文件.tar本身不 ...
- Data Structure Binary Tree: Diameter of a Binary Tree
http://www.geeksforgeeks.org/diameter-of-a-binary-tree/ #include <iostream> #include <vecto ...
- 20145229吴姗珊 《Java程序设计》第8周学习总结
20145229吴姗珊 <Java程序设计>第8周总结 教材学习内容总结 第十四章 NIO与NIO2 NIO: InputStream.OutputStream的输入输出,基本上是以字节为 ...
- Windows 7 比Windows XP 难用的功能
Windows 7 的搜索功能做得实在难用,不仅慢,还经常搜不到文件(明明存在的文件却搜不到).相比Windows XP,这个功能差的太远了. Windows 7 的无线连网功能,即使设置为不要自动连 ...