zoukankan      html  css  js  c++  java
  • python机器学习库numpy---14、numpy实现正态分布

    python机器学习库numpy---14、numpy实现正态分布

    一、总结

    一句话总结:

    numpy实现正态分布就是 x轴模拟一些点,y轴根据正态分布的公式算出这些点的结果,然后画图即可
    # Python实现正态分布
    # 绘制正态分布概率密度函数
    import numpy as np
    import matplotlib.pyplot as plt
    
    u = 0  # 均值μ
    sig = np.sqrt(0.2)  # 标准差δ
    print(sig)
    
    x = np.linspace(u - 3 * sig, u + 3 * sig, 150)
    y = np.exp(-(x - u) ** 2 / (2 * sig ** 2)) / (np.sqrt(2 * np.pi) * sig)
    print(x)
    print("=" * 80)
    print(y)
    plt.plot(x, y, "r-", linewidth=2)
    plt.grid(True)
    plt.show()

    二、numpy实现正态分布

    博客对应课程的视频位置:14、numpy实现正态分布-范仁义-读书编程笔记
    https://www.fanrenyi.com/video/38/357

    # Python实现正态分布
    # 绘制正态分布概率密度函数
    import numpy as np
    import matplotlib.pyplot as plt
    
    u = 0  # 均值μ
    sig = np.sqrt(0.2)  # 标准差δ
    print(sig)
    
    x = np.linspace(u - 3 * sig, u + 3 * sig, 150)
    y = np.exp(-(x - u) ** 2 / (2 * sig ** 2)) / (np.sqrt(2 * np.pi) * sig)
    print(x)
    print("=" * 80)
    print(y)
    plt.plot(x, y, "r-", linewidth=2)
    plt.grid(True)
    plt.show()
    
    0.4472135954999579
    [-1.34164079 -1.32363219 -1.30562358 -1.28761498 -1.26960638 -1.25159778
     -1.23358918 -1.21558058 -1.19757198 -1.17956338 -1.16155477 -1.14354617
     -1.12553757 -1.10752897 -1.08952037 -1.07151177 -1.05350317 -1.03549457
     -1.01748597 -0.99947736 -0.98146876 -0.96346016 -0.94545156 -0.92744296
     -0.90943436 -0.89142576 -0.87341716 -0.85540856 -0.83739995 -0.81939135
     -0.80138275 -0.78337415 -0.76536555 -0.74735695 -0.72934835 -0.71133975
     -0.69333114 -0.67532254 -0.65731394 -0.63930534 -0.62129674 -0.60328814
     -0.58527954 -0.56727094 -0.54926234 -0.53125373 -0.51324513 -0.49523653
     -0.47722793 -0.45921933 -0.44121073 -0.42320213 -0.40519353 -0.38718492
     -0.36917632 -0.35116772 -0.33315912 -0.31515052 -0.29714192 -0.27913332
     -0.26112472 -0.24311612 -0.22510751 -0.20709891 -0.18909031 -0.17108171
     -0.15307311 -0.13506451 -0.11705591 -0.09904731 -0.08103871 -0.0630301
     -0.0450215  -0.0270129  -0.0090043   0.0090043   0.0270129   0.0450215
      0.0630301   0.08103871  0.09904731  0.11705591  0.13506451  0.15307311
      0.17108171  0.18909031  0.20709891  0.22510751  0.24311612  0.26112472
      0.27913332  0.29714192  0.31515052  0.33315912  0.35116772  0.36917632
      0.38718492  0.40519353  0.42320213  0.44121073  0.45921933  0.47722793
      0.49523653  0.51324513  0.53125373  0.54926234  0.56727094  0.58527954
      0.60328814  0.62129674  0.63930534  0.65731394  0.67532254  0.69333114
      0.71133975  0.72934835  0.74735695  0.76536555  0.78337415  0.80138275
      0.81939135  0.83739995  0.85540856  0.87341716  0.89142576  0.90943436
      0.92744296  0.94545156  0.96346016  0.98146876  0.99947736  1.01748597
      1.03549457  1.05350317  1.07151177  1.08952037  1.10752897  1.12553757
      1.14354617  1.16155477  1.17956338  1.19757198  1.21558058  1.23358918
      1.25159778  1.26960638  1.28761498  1.30562358  1.32363219  1.34164079]
    ================================================================================
    [0.00990991 0.01117334 0.01257742 0.01413501 0.01585976 0.01776612
     0.01986938 0.02218564 0.02473178 0.02752546 0.03058507 0.03392971
     0.03757912 0.04155362 0.04587403 0.05056158 0.05563783 0.06112453
     0.06704349 0.07341646 0.08026498 0.08761016 0.09547258 0.10387202
     0.11282733 0.12235614 0.13247473 0.1431977  0.15453784 0.16650581
     0.17910996 0.19235604 0.20624703 0.22078286 0.23596021 0.2517723
     0.26820873 0.28525524 0.30289362 0.32110154 0.33985247 0.35911557
     0.37885569 0.39903332 0.41960463 0.44052155 0.46173184 0.48317922
     0.50480361 0.52654127 0.54832514 0.57008507 0.59174821 0.61323933
     0.6344813  0.65539544 0.67590207 0.69592095 0.7153718  0.73417482
     0.75225127 0.76952396 0.78591781 0.80136042 0.81578255 0.82911869
     0.84130753 0.85229239 0.86202174 0.87044953 0.8775356  0.88324596
     0.88755311 0.8904362  0.89188126 0.89188126 0.8904362  0.88755311
     0.88324596 0.8775356  0.87044953 0.86202174 0.85229239 0.84130753
     0.82911869 0.81578255 0.80136042 0.78591781 0.76952396 0.75225127
     0.73417482 0.7153718  0.69592095 0.67590207 0.65539544 0.6344813
     0.61323933 0.59174821 0.57008507 0.54832514 0.52654127 0.50480361
     0.48317922 0.46173184 0.44052155 0.41960463 0.39903332 0.37885569
     0.35911557 0.33985247 0.32110154 0.30289362 0.28525524 0.26820873
     0.2517723  0.23596021 0.22078286 0.20624703 0.19235604 0.17910996
     0.16650581 0.15453784 0.1431977  0.13247473 0.12235614 0.11282733
     0.10387202 0.09547258 0.08761016 0.08026498 0.07341646 0.06704349
     0.06112453 0.05563783 0.05056158 0.04587403 0.04155362 0.03757912
     0.03392971 0.03058507 0.02752546 0.02473178 0.02218564 0.01986938
     0.01776612 0.01585976 0.01413501 0.01257742 0.01117334 0.00990991]
    
    In [ ]:
     
     
    我的旨在学过的东西不再忘记(主要使用艾宾浩斯遗忘曲线算法及其它智能学习复习算法)的偏公益性质的完全免费的编程视频学习网站: fanrenyi.com;有各种前端、后端、算法、大数据、人工智能等课程。
    博主25岁,前端后端算法大数据人工智能都有兴趣。
    大家有啥都可以加博主联系方式(qq404006308,微信fan404006308)互相交流。工作、生活、心境,可以互相启迪。
    聊技术,交朋友,修心境,qq404006308,微信fan404006308
    26岁,真心找女朋友,非诚勿扰,微信fan404006308,qq404006308
    人工智能群:939687837

    作者相关推荐

  • 相关阅读:
    网络基础 港湾FlexHammer5010交换机镜像端口配置
    HttpWatch HttpWatch时间表(HttpWatch Time Charts)
    网络基础 计算机网络速率,带宽,吞吐量概念
    Kubernetes 1.11.2概述和搭建(多节点)
    Ubuntu 搭建docker registry 私有仓库
    Ubuntu 搭建etcd
    python 多线程删除MySQL表
    python 统计MySQL表信息
    基于Prometheus的Pushgateway实战
    基于docker 搭建Elasticsearch6.2.4(centos)
  • 原文地址:https://www.cnblogs.com/Renyi-Fan/p/13585354.html
Copyright © 2011-2022 走看看