numpy 高阶函数 —— np.histogram
来源:互联网 发布:linux 502端口映射 编辑:程序博客网 时间:2024/05/16 13:39
np.diff(a, n=1, axis=-1):n 表示差分的阶数;
>> x = np.array([1, 2, 4, 7, 0])>> np.diff(x)array([ 1, 2, 3, -7])>> np.diff(x, n=2)array([ 1, 1, -10])
1. np.histogram
官方文档:numpy.histogram — NumPy v1.12 Manual
- numpy.histogram(a, bins=10, range=None, normed=False, weights=None, density=None)
- 返回值,有两个,
- hist : array
- bin_edges : array of dtype float,bin edges 的长度要是 hist 的长度加1,bin edges (length(hist)+1),也即 (bin_edges[0], bin_edges[1]) ⇒ hist[0],….,(bin_edges[-2], bin_edges[-1]) ⇒ hist[-1],bin_edges 参数与输入参数的 bins 保持一致;
- 返回值,有两个,
>>> a = np.arange(5)>>> hist, bin_edges = np.histogram(a, density=True)>>> histarray([ 0.5, 0. , 0.5, 0. , 0. , 0.5, 0. , 0.5, 0. , 0.5])>>> hist.sum()2.4999999999999996>>> np.sum(hist*np.diff(bin_edges))1.0 # hist*np.diff(bin_edges) ⇒ 其实表示一种概率分布;
0 0
- numpy 高阶函数 —— np.histogram
- Numpy—np.random.seed()函数的应用
- numpy: np.asarray 函数
- numpy 基础 —— np.linalg
- numpy 基础 —— np.linalg
- numpy 基础 —— np.linalg
- numpy函数之np.maximum
- numpy函数之np.newaxis
- Numpy学习—np.random.randn()、np.random.rand()和np.random.randint()
- Numpy学习——数组填充np.pad()函数的应用
- Numpy学习——数组填充np.pad()函数的应用
- numpy 参数(一) —— np.linalg
- numpy 辨异(二) —— np.identity()/np.eye()
- numpy 辨异(四)—— np.repeat 与 np.tile
- numpy np.repeat 与 np.tile的区别, numpy.ravel()函数
- 一文详解numpy中np.nonzero()函数
- 一文详解numpy中np.nonzero()函数
- numpy 之 np.where
- Linux vim编写程序时出现高亮字符,如何取消?
- 神经网络的简介
- java内存模型
- 全新手在linux上安装jdk
- Java CAS 和ABA问题
- numpy 高阶函数 —— np.histogram
- PAT-A-1093. Count PAT's (25)
- Docker基础入门及示例
- 用idea搭建SSH框架--校内测试
- Sql Server 安全性实验
- 客观世界的音乐和人的关系
- 用c语言编写小游戏:贪吃蛇
- Linux防火墙iptables
- 杨辉三角