Scipy expit 绘制函数图像

举报
千江有水千江月 发表于 2021/12/20 12:22:51 2021/12/20
【摘要】 环境信息ModelArtsCodeLabConda-python3scipy 1.2.2  代码示例import scipy.specialimport numpy as npimport matplotlib.pyplot as plt%matplotlib inline# number = 100x = np.linspace(-10,10,100)xarray([-10. ...

环境信息

  • ModelArts
    • CodeLab
      • Conda-python3
        • scipy 1.2.2

代码示例

import scipy.special
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# number = 100
x = np.linspace(-10,10,100)
x

array([-10.        ,  -9.7979798 ,  -9.5959596 ,  -9.39393939,
        -9.19191919,  -8.98989899,  -8.78787879,  -8.58585859,
        -8.38383838,  -8.18181818,  -7.97979798,  -7.77777778,
        -7.57575758,  -7.37373737,  -7.17171717,  -6.96969697,
        -6.76767677,  -6.56565657,  -6.36363636,  -6.16161616,
        -5.95959596,  -5.75757576,  -5.55555556,  -5.35353535,
        -5.15151515,  -4.94949495,  -4.74747475,  -4.54545455,
        -4.34343434,  -4.14141414,  -3.93939394,  -3.73737374,
        -3.53535354,  -3.33333333,  -3.13131313,  -2.92929293,
        -2.72727273,  -2.52525253,  -2.32323232,  -2.12121212,
        -1.91919192,  -1.71717172,  -1.51515152,  -1.31313131,
        -1.11111111,  -0.90909091,  -0.70707071,  -0.50505051,
        -0.3030303 ,  -0.1010101 ,   0.1010101 ,   0.3030303 ,
         0.50505051,   0.70707071,   0.90909091,   1.11111111,
         1.31313131,   1.51515152,   1.71717172,   1.91919192,
         2.12121212,   2.32323232,   2.52525253,   2.72727273,
         2.92929293,   3.13131313,   3.33333333,   3.53535354,
         3.73737374,   3.93939394,   4.14141414,   4.34343434,
         4.54545455,   4.74747475,   4.94949495,   5.15151515,
         5.35353535,   5.55555556,   5.75757576,   5.95959596,
         6.16161616,   6.36363636,   6.56565657,   6.76767677,
         6.96969697,   7.17171717,   7.37373737,   7.57575758,
         7.77777778,   7.97979798,   8.18181818,   8.38383838,
         8.58585859,   8.78787879,   8.98989899,   9.19191919,
         9.39393939,   9.5959596 ,   9.7979798 ,  10.        ])
y = scipy.special.expit(x)
y

array([4.53978687e-05, 5.55606489e-05, 6.79983174e-05, 8.32200197e-05,
       1.01848815e-04, 1.24647146e-04, 1.52547986e-04, 1.86692945e-04,
       2.28478855e-04, 2.79614739e-04, 3.42191434e-04, 4.18766684e-04,
       5.12469082e-04, 6.27124987e-04, 7.67413430e-04, 9.39055039e-04,
       1.14904229e-03, 1.40591988e-03, 1.72012560e-03, 2.10440443e-03,
       2.57431039e-03, 3.14881358e-03, 3.85103236e-03, 4.70911357e-03,
       5.75728612e-03, 7.03711536e-03, 8.59898661e-03, 1.05038445e-02,
       1.28252101e-02, 1.56514861e-02, 1.90885420e-02, 2.32625358e-02,
       2.83228820e-02, 3.44451957e-02, 4.18339400e-02, 5.07243606e-02,
       6.13831074e-02, 7.41067363e-02, 8.92170603e-02, 1.07052146e-01,
       1.27951705e-01, 1.52235823e-01, 1.80176593e-01, 2.11963334e-01,
       2.47663801e-01, 2.87185901e-01, 3.30246430e-01, 3.76354517e-01,
       4.24816868e-01, 4.74768924e-01, 5.25231076e-01, 5.75183132e-01,
       6.23645483e-01, 6.69753570e-01, 7.12814099e-01, 7.52336199e-01,
       7.88036666e-01, 8.19823407e-01, 8.47764177e-01, 8.72048295e-01,
       8.92947854e-01, 9.10782940e-01, 9.25893264e-01, 9.38616893e-01,
       9.49275639e-01, 9.58166060e-01, 9.65554804e-01, 9.71677118e-01,
       9.76737464e-01, 9.80911458e-01, 9.84348514e-01, 9.87174790e-01,
       9.89496155e-01, 9.91401013e-01, 9.92962885e-01, 9.94242714e-01,
       9.95290886e-01, 9.96148968e-01, 9.96851186e-01, 9.97425690e-01,
       9.97895596e-01, 9.98279874e-01, 9.98594080e-01, 9.98850958e-01,
       9.99060945e-01, 9.99232587e-01, 9.99372875e-01, 9.99487531e-01,
       9.99581233e-01, 9.99657809e-01, 9.99720385e-01, 9.99771521e-01,
       9.99813307e-01, 9.99847452e-01, 9.99875353e-01, 9.99898151e-01,
       9.99916780e-01, 9.99932002e-01, 9.99944439e-01, 9.99954602e-01])
plt.grid()
plt.plot(x,y)

scipy-expit-plt-1.png

备注

  1. 欢迎各位同学一起来交流学习心得^_^
  2. 在线课程、沙箱实验、认证、大赛、论坛和直播,其中包含了许多优质的内容,推荐了解与学习。
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。