- Python : 3.8.11
- numpy : 1.20.1
- OS : Ubuntu Kylin 20.04
- Conda : 4.10.1
- jupyter lab : 3.1.4
代码示例
import numpy as np
复制代码
# normal 正态分布
# loc 均值、中心点
# scale 标准差
# size shape
np.random.normal(loc=0.0,scale=0.5,size=(2,3))
array([[-0.15069357, 0.26875581, 0.31638909],
[-0.71754672, -0.05140111, -0.22627883]])
复制代码
np.random.normal(loc=0.0,scale=0.5,size=(2,3))
array([[-0.25230081, -0.46464863, -1.16539577],
[-0.48035575, 0.32226706, 0.4507823 ]])
复制代码
源码学习
help(np.random.normal)
Help on built-in function normal:
normal(...) method of numpy.random.mtrand.RandomState instance
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 [2]_, 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 [2]_.
.. note::
New code should use the ``normal`` method of a ``default_rng()``
instance instead; please see the :ref:`random-quick-start`.
......
复制代码
学习推荐
- Python文档 - English
- Python文档 - 中文
- Python规范 PEP
- Python规范 google版
- Python 源码
- Python PEP
- 优麒麟
- 掘金平台
- gitee平台
Python具有开源、跨平台、解释型、交互式等特性,值得学习。
Python的设计哲学:优雅,明确,简单。提倡用一种方法,最好是只有一种方法来做一件事。
代码的书写要遵守规范,这样有助于沟通和理解。
每种语言都有独特的思想,初学者需要转变思维、踏实践行、坚持积累。