日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python numpy 中 np.mean(a) 跟 a.mean() 的区别

發布時間:2025/3/19 python 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python numpy 中 np.mean(a) 跟 a.mean() 的区别 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

今天查看以前寫的文章時, 發現有個地方理解不了, 就是 np.mean(a) 跟 a.mean() 的區別是什么, 于是就查閱了相關資料:

  • 官方doc:

a.mean()

Docstring: a.mean(axis=None, dtype=None, out=None, keepdims=False)Returns the average of the array elements along given axis.Refer to `numpy.mean` for full documentation.See Also -------- numpy.mean : equivalent function Type: builtin_function_or_method

np.mean(a)

Signature: np.mean(a, axis=None, dtype=None, out=None, keepdims=<no value>) Docstring: Compute the arithmetic mean along the specified axis.Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis. `float64` intermediate and return values are used for integer inputs.Parameters ---------- a : array_likeArray containing numbers whose mean is desired. If `a` is not anarray, a conversion is attempted. axis : None or int or tuple of ints, optionalAxis or axes along which the means are computed. The default is tocompute the mean of the flattened array... versionadded:: 1.7.0If this is a tuple of ints, a mean is performed over multiple axes,instead of a single axis or all the axes as before. dtype : data-type, optionalType to use in computing the mean. For integer inputs, the defaultis `float64`; for floating point inputs, it is the same as theinput dtype. out : ndarray, optionalAlternate output array in which to place the result. The defaultis ``None``; if provided, it must have the same shape as theexpected output, but the type will be cast if necessary.See `doc.ufuncs` for details.keepdims : bool, optionalIf this is set to True, the axes which are reduced are leftin the result as dimensions with size one. With this option,the result will broadcast correctly against the input array.If the default value is passed, then `keepdims` will not bepassed through to the `mean` method of sub-classes of`ndarray`, however any non-default value will be. If thesub-class' method does not implement `keepdims` anyexceptions will be raised.Returns ------- m : ndarray, see dtype parameter aboveIf `out=None`, returns a new array containing the mean values,otherwise a reference to the output array is returned.See Also -------- average : Weighted average std, var, nanmean, nanstd, nanvarNotes ----- The arithmetic mean is the sum of the elements along the axis divided by the number of elements.Note that for floating-point input, the mean is computed using the same precision the input has. Depending on the input data, this can cause the results to be inaccurate, especially for `float32` (see example below). Specifying a higher-precision accumulator using the `dtype` keyword can alleviate this issue.By default, `float16` results are computed using `float32` intermediates for extra precision.Examples -------- >>> a = np.array([[1, 2], [3, 4]]) >>> np.mean(a) 2.5 >>> np.mean(a, axis=0) array([ 2., 3.]) >>> np.mean(a, axis=1) array([ 1.5, 3.5])In single precision, `mean` can be inaccurate:>>> a = np.zeros((2, 512*512), dtype=np.float32) >>> a[0, :] = 1.0 >>> a[1, :] = 0.1 >>> np.mean(a) 0.54999924Computing the mean in float64 is more accurate:>>> np.mean(a, dtype=np.float64) 0.55000000074505806 File: c:\users\huawei\appdata\local\programs\python\python36\lib\site-packages\numpy\core\fromnumeric.py Type: function
  • 總的來說, doc中所描述的是指 a.mean() 是 np.mean(a) 的簡單版, 使用方法基本是相同的, 唯一的不同就是前者是numpy數組對象的方法, 后者作為numpy的函數使用.
  • 函數的作用就是: 返回數組元素沿給定軸的算數平均值。(算術平均值是沿坐標軸上的元素的和除以元素的個數。)
  • 沿坐標軸是什么意思, 參考:

參考文章1: python numpy.mean() axis參數使用方法【sum(axis=)是求和,mean(axis=)是求平均值】
https://blog.csdn.net/Dontla/article/details/96466644

參考文章2: python 如何理解 numpy 數組操作中的 axis 參數?
https://blog.csdn.net/Dontla/article/details/99751690

總結

以上是生活随笔為你收集整理的python numpy 中 np.mean(a) 跟 a.mean() 的区别的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 最新超碰 | 影音先锋丝袜美腿 | 夜夜爽爽| 一区二区自拍偷拍 | 免费看av的网址 | 国产情侣在线播放 | 欧美日本激情 | 狠狠干很很操 | 九九热最新 | 日韩欧美视频 | 夜夜天天操 | 午夜精品久久久久久久99热黄桃 | 精品三级视频 | 日韩欧美一区二区三区在线 | 美女隐私黄www网站动漫 | 亚洲国产一区二区三区四区 | 神马午夜av| 99热国产精品 | 国产成人精品777777 | 国产精品久久99 | 成人精品一区二区三区在线 | 日韩成人精品在线观看 | 亚洲精品888| 牛夜精品久久久久久久99黑人 | 亚洲第一女人av | 国产视频99| 伊人色播 | 欧美日韩在线成人 | 日韩一区二区三区精品 | 干干天天 | 乱淫的女高中暑假调教h | 亚洲网站免费观看 | 亚洲欧美日韩综合在线 | 中文字幕国产剧情 | jiz亚洲 | 99精品综合 | 欧美裸体精品 | 久久精品黄色片 | 中文字幕影片免费在线观看 | 可以在线看黄的网站 | 国产午夜精品一区二区三区四区 | 国产一级视频免费观看 | 绝顶高潮videos合集 | 亚洲无码乱码精品国产 | 国产精品久久久久久久裸模 | 中国肥胖女人真人毛片 | 国产内谢 | 一级网站在线观看 | 国产a一区二区三区 | 免看黄大片aa | 色综合免费视频 | 国产资源在线观看 | 人人爽爽爽 | 青草成人| 亚洲免费视频网站 | 色哟哟在线观看 | 欧日韩av | 催眠调教艳妇成肉便小说 | 亚洲色婷婷一区二区三区 | 九九热在线视频观看 | 午夜国产精品视频 | 性――交――性――乱 | 一级片在线观看视频 | h成人在线 | 国产一区二区视频在线观看 | 在线观看的av网站 | 对白刺激国产子与伦 | 99久久精品免费看国产四区 | 在线视频国产一区 | 国产av无毛| 极品色av | 久久3p| brazzers猛女系列 | 亚洲精品www久久久久久广东 | 狠狠成人 | 色撸撸av | 高中男男gay互囗交观看 | 日韩美女视频在线观看 | 台湾男男gay做爽爽的视频 | 老妇荒淫牲艳史 | 男女毛片视频 | 黄色的网站在线 | 久久精品日韩无码 | 日本一级吃奶淫片免费 | 伦理片波多野结衣 | 国产中文字幕在线观看 | 超碰下载页面 | 一区二区三区四区免费观看 | 香蕉视频黄污 | 亚洲在线中文字幕 | 高h全肉污文play带道具 | 免费成人av在线 | 国产真实生活伦对白 | 天堂网在线资源 | 俄罗斯一级片 | wwwxxx在线播放| 欧美日韩成人在线视频 | 日韩精品极品 | 日韩一区二区三区久久 |