当前位置:网站首页>numpy.cumsum
numpy.cumsum
2022-07-24 07:23:00 【Wanderer001】
Reference resources numpy.cumsum - cloud + Community - Tencent cloud
numpy.cumsum(a, axis=None, dtype=None, out=None)[source]
Return the cumulative sum of the elements along a given axis.
Parameters
aarray_like
Input array.
axisint, optional
Axis along which the cumulative sum is computed. The default (None) is to compute the cumsum over the flattened array.
dtypedtype, optional
Type of the returned array and of the accumulator in which the elements are summed. If dtype is not specified, it defaults to the dtype of a, unless a has an integer dtype with a precision less than that of the default platform integer. In that case, the default platform integer is used.
outndarray, optional
Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output but the type will be cast if necessary. See ufuncs-output-type for more details.
Returns
cumsum_along_axisndarray.
A new array holding the result is returned unless out is specified, in which case a reference to out is returned. The result has the same size as a, and the same shape as a if axis is not None or a is a 1-d array.
See also
Sum array elements.
Integration of array values using the composite trapezoidal rule.
Calculate the n-th discrete difference along given axis.
Notes
Arithmetic is modular when using integer types, and no error is raised on overflow.
Examples
>>> a = np.array([[1,2,3], [4,5,6]])
>>> a
array([[1, 2, 3],
[4, 5, 6]])
>>> np.cumsum(a)
array([ 1, 3, 6, 10, 15, 21])
>>> np.cumsum(a, dtype=float) # specifies type of output value(s)
array([ 1., 3., 6., 10., 15., 21.])>>> np.cumsum(a,axis=0) # sum over rows for each of the 3 columns
array([[1, 2, 3],
[5, 7, 9]])
>>> np.cumsum(a,axis=1) # sum over columns for each of the 2 rows
array([[ 1, 3, 6],
[ 4, 9, 15]])边栏推荐
- 【FreeRTOS】11 软件定时器
- Part II - C language improvement_ 2. Memory partition
- C language from entry to soil function
- Opencascade notes: GP package
- FPGA realizes reading and writing of axi4 bus
- Part II - C language improvement_ 1. Overview of C language
- 记账APP:小哈记账1——欢迎页的制作
- C language from entry to Earth - array
- [word] how to generate the index directory on the left
- AMD64(x86_64)架构abi文档:上
猜你喜欢

深度学习二三事-回顾那些经典卷积神经网络

Aggregated new ecological model - sharing purchase, membership and reward system

Mongodb application scenario and model selection (massive data storage model selection)

Blockbuster live broadcast | orb-slam3 series code explanation map points (topic 2)

C language from entry to soil (II)

全国职业院校技能大赛网络安全B模块 Windows操作系统渗透测试

FPGA realizes reading and writing of axi4 bus

Can recursion still play like this? Recursive implementation of minesweeping game

Feature Selective Anchor-Free Module for Single-Shot Object Detection

我的创作纪念日
随机推荐
django.db.utils. OperationalError: (2002, “Can‘t connect to local MySQL server through socket ‘/var/r
Take you step by step to learn C (one)
记账APP:小哈记账1——欢迎页的制作
全国职业院校技能大赛网络安全B模块 Windows操作系统渗透测试
MySQL queries all parents of the current node
记账APP:小哈记账2——注册页面的制作
定制 or 通用,中国 SaaS 未来发展趋势是什么?
Using depth and normal textures in unity
There are two tables in Oracle, a and B. these two tables need to be associated with the third table C. how to update the field MJ1 in table a to the value MJ2 in table B
CSDN, it's time to say goodbye!
Vulnhub DC1
nacos配置中心源码分析
Three implementation methods of single sign on
[line test] Figure finding regular questions
php 转义字符串
My creation anniversary
AMD64(x86_64)架构abi文档:上
2D目标检测综述之学习策略篇(终章)
C language from entry to soil (III)
Bookkeeping app: xiaoha bookkeeping 2 - production of registration page