>>> import numpy as np
>>> np.zeros(10,dtype=int)
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])

>>> np.zeros((3,5))
array([[0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0.]])

>>> np.zeros(shape=(3,5),dtype=int)
array([[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]])

>>> np.ones(10)
array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])

>>> np.ones((3,5))
array([[1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1.]])

>>> np.full(shape=(3,5),fill_value=666)
array([[666, 666, 666, 666, 666],
[666, 666, 666, 666, 666],
[666, 666, 666, 666, 666]])

>>> [i for i in range(0,20,2)]
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]

>>> np.arange(0,20,2)
array([ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18])

>>> np.arange(0,1,0.2)
array([0. , 0.2, 0.4, 0.6, 0.8])

>>> np.linspace(0,20,10)
array([ 0. , 2.22222222, 4.44444444, 6.66666667, 8.88888889,
11.11111111, 13.33333333, 15.55555556, 17.77777778, 20. ])

>>> np.linspace(0,20,11)
array([ 0., 2., 4., 6., 8., 10., 12., 14., 16., 18., 20.])

>>> np.random.randint(10)
0

>>> np.random.randint(0,10,10)
array([1, 4, 7, 9, 0, 6, 1, 5, 2, 6])

>>> np.random.randint(2,10,size=10)
array([3, 3, 8, 9, 4, 3, 2, 7, 2, 4])

>>> np.random.randint(2,10,size=(3, 5))
array([[9, 8, 4, 2, 3],
[6, 3, 5, 8, 6],
[7, 8, 6, 7, 9]])

>>> np.random.seed(666)
>>> np.random.randint(2,10,size=(3, 5))
array([[6, 4, 7, 8, 8],
[8, 3, 8, 6, 7],
[5, 8, 5, 6, 9]])

>>> np.random.randint(2,10,size=(3, 5))
array([[6, 8, 3, 9, 2],
[8, 2, 9, 7, 4],
[6, 9, 7, 7, 7]])

>>> np.random.random()
0.7744794542685887

>>> np.random.random(10)
array([0.00510884, 0.11285765, 0.11095367, 0.24766823, 0.0232363 ,
0.72732115, 0.34003494, 0.19750316, 0.90917959, 0.97834699])

>>> np.random.random((3, 5))
array([[0.53280254, 0.25913185, 0.58381262, 0.32569065, 0.88889931],
[0.62640453, 0.81887369, 0.54734542, 0.41671201, 0.74304719],
[0.36959638, 0.07516654, 0.77519298, 0.21940924, 0.07934213]])

>>> np.random.normal(10,100)
-110.99026554923134

最新文章

  1. Watin 杂谈
  2. java能不能自己写一个类叫java.lang.System/String正确答案
  3. Sqoop实现关系型数据库到hive的数据传输
  4. 错误: 找不到或无法加载主类 Files\apache-activemq-5.10.0\bin\..\conf\login.config
  5. hibernate的工作原理
  6. 原生JS修改标签样式为带阴影效果
  7. Linux重定向的理解
  8. 6.struts登陆页面的演示
  9. HDU2084JAVA
  10. 转帖:Html.BeginForm
  11. Python内置函数(24)——frozenset
  12. springboot秒杀课程学习整理1-5
  13. kafka---->kafka connect的使用(一)
  14. 使用libvirtAPI打快照原理
  15. January 28th, 2018 Week 05th Sunday
  16. Flutter - Json序列化
  17. Nodejs搭建wss服务器
  18. Tomcat权威指南-读书摘要系列7
  19. Homebrew cask
  20. XML--将XML中数据提取出转换成表

热门文章

  1. 十五:SpringBoot-配置Actuator组件,实现系统监控
  2. Kubernetes --(k8s) service
  3. 【poj 2976】Dropping tests(算法效率--01分数规划 模版题+二分){附【转】01分数规划问题}
  4. CodeForces 893C (并查集板子题)
  5. R - 0 or 1(最短路)
  6. Codeforces Round #682 (Div. 2) C. Engineer Artem (构造)
  7. 2017, X Samara Regional Intercollegiate Programming Contest E. Bonuses and Teleports (思维,模拟)
  8. git忽略规则以及.gitignore文件不生效解决办法
  9. Jenkins+ant+Jmeter接口自动化框架搭建
  10. Win10 Nodejs搭建http-server注意点