import numpy as np

 # 创建
# 创建一维数组
a = np.array([1, 2, 3])
print(a)
'''
[1 2 3]
'''
# 创建多维数组
b = np.array([(1, 2, 3), (4, 5, 6)])
print(b)
'''
[[1 2 3]
[4 5 6]]
'''
# 创建等差一维数组
c = np.arange(1, 5, 0.5)
print(c)
'''
[1. 1.5 2. 2.5 3. 3.5 4. 4.5]
'''
# 创建随机数数组
d = np.random.random((2, 2))
print(d)
'''
[[0.65746941 0.09766114]
[0.15024283 0.9212932 ]]
'''
# 创建一个确定起始点和终止点和个数的等差一维数组
##包含终止点
e = np.linspace(1, 2, 10)
print(e)
'''
[1. 1.11111111 1.22222222 1.33333333 1.44444444 1.55555556 1.66666667 1.77777778 1.88888889 2. ]
'''
##不包含终止点
f = np.linspace(1, 2, 10, endpoint=False)
print(f)
'''
[1. 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9]
'''
# 创建一个全为‘1’的 数组
g = np.ones([2, 3])
print(g)
'''
[[1. 1. 1.]
[1. 1. 1.]]
'''
# 创建一个全为‘0’的数组
h = np.zeros([2, 3])
print(h)
'''
[[0. 0. 0.]
[0. 0. 0.]]
'''
# 创建一个全为'自定义的值'的数组
i = np.full((2, 3), fill_value=21)
print(i)
'''
[[21 21 21]
[21 21 21]]
'''
# 创建一个对角线为‘1’,其他的位置为‘0’
j = np.eye(4)
print(j)
'''
[[1. 0. 0. 0.]
[0. 1. 0. 0.]
[0. 0. 1. 0.]
[0. 0. 0. 1.]]
'''
# 创建一个标准的正态分布
h = np.random.randn(50)
print(h)
'''
[ 0.01250963 -0.7387912 0.34890184 0.45922031 0.69632711 1.45936167
-0.01958069 -0.42200162 -1.59439929 -0.38340785 -0.09423212 0.46495457
-1.07383807 1.26489024 1.50519718 1.21760287 -1.43837182 0.11904866
0.29399612 -1.66294523 1.42131044 0.13073129 0.02832415 1.57078671
-0.96096118 0.1636397 0.25686109 0.92687274 -0.14074038 -0.2355995
0.06471922 0.00188039 0.56639013 -0.12014897 -0.5348929 -0.91173276
1.04026246 -1.39317966 -0.42333174 -0.28924722 1.09360504 0.16879087
-0.4505147 0.38581222 -0.42106339 0.29927751 -0.9056031 -0.86102655
-0.61423026 -0.94604185]
'''
# 创建一个自定义的正态分布
h = np.random.normal(loc=175, scale=0.3, size=50)
print(h)
# loc为位置参数
# scale为尺度参数,值越大离散程度越大
# size为总数据个数
'''
[175.01002617 175.49445311 175.15833447 174.42510606 174.78144183
174.84035925 174.76628391 174.84687069 174.93967239 175.29902946
175.08438032 175.1476928 174.992446 174.87066715 175.02578143
175.03768609 175.20249608 174.96956083 174.62277043 175.59116051
175.59419255 174.74925345 175.44279974 175.07262176 174.91848554
174.90220037 175.19871001 175.04802743 174.71962518 175.07843723
174.87821195 174.88255464 175.56090823 174.44660242 175.11230508
174.89422801 174.63803226 175.03060753 174.84452539 174.99050179
174.9037525 174.90163791 175.42865325 174.76396595 174.99927621
175.15771656 174.72123296 175.22466598 174.72349497 174.95927315]
'''
# 通过函数创建数组
k = np.fromfunction(lambda i, j: (i + 1) * (j + 1), (9, 9))
print(k)
'''
[[ 1. 2. 3. 4. 5. 6. 7. 8. 9.]
[ 2. 4. 6. 8. 10. 12. 14. 16. 18.]
[ 3. 6. 9. 12. 15. 18. 21. 24. 27.]
[ 4. 8. 12. 16. 20. 24. 28. 32. 36.]
[ 5. 10. 15. 20. 25. 30. 35. 40. 45.]
[ 6. 12. 18. 24. 30. 36. 42. 48. 54.]
[ 7. 14. 21. 28. 35. 42. 49. 56. 63.]
[ 8. 16. 24. 32. 40. 48. 56. 64. 72.]
[ 9. 18. 27. 36. 45. 54. 63. 72. 81.]]
'''

最新文章

  1. IIS HTTP 错误 404.17 - Not Found HTTP 错误 404.2 解决方法
  2. eclipse中使用javadoc生成文档
  3. javascript高级程序设计---Event对象三
  4. Ubuntu-12.04-server 配置修改静态 IP地址
  5. cocos2d 遍历CCAarray
  6. yaffs文件系统
  7. 解决g++:command not found(centos7.0)
  8. Oracle index hint syntax
  9. 如何应对“改变现状”的失败"
  10. 聚类算法K-Means, K-Medoids, GMM, Spectral clustering,Ncut
  11. 获取IP Address
  12. Nginx负载均衡和反向代理的配置和优化
  13. .net基础学java系列(二)IDE
  14. Sublime_SideBarEnhancements
  15. JS学习大作业-Excel
  16. Git分支merge和rebase的区别
  17. shell 批量查看job 配置
  18. Delphi编程中使用回车键不换行处理方法!!
  19. 【数据服务中间件】一、HttpServlet
  20. Linux Shell编程 sort、wc命令

热门文章

  1. 阿里云搭建hadoop集群服务器,内网、外网访问问题(详解。。。)
  2. 请整体描述Java异常体系
  3. 原型相关的方法isPrototypeOf、Object.getPrototypeOf、hasOwnProperty、Object.getOwnPropertyName、Object.keys
  4. Ajax 与 JSON
  5. 移动端meta标签设置
  6. L1 Cache, L2 Cache读取命中率与时钟周期计算
  7. 自定义RatingBar评分控件
  8. 网络 Internet 的发展
  9. CSS 小结笔记之背景
  10. leetcode之二叉树的层序遍历