美文网首页
使用pyplot绘制cdf图

使用pyplot绘制cdf图

作者: 137c | 来源:发表于2019-10-09 17:57 被阅读0次

cdf图参考博客:

https://www.cnblogs.com/wangjingchn/p/7376470.html
http://ju.outofmemory.cn/entry/146829

直方图

hist,bin_edges=np.histogram(arr)

>>hist  #每个区间的频数
array([ 2,  2,  6,  8, 15, 18, 16, 19,  5,  9], dtype=int64)
>>bin_edges #每个区间的分界点
array([-2.58122354, -2.13107873, -1.68093391, -1.2307891 , -0.78064429,
       -0.33049947,  0.11964534,  0.56979015,  1.01993497,  1.47007978,
        1.92022459])

subplot

绘制子图的格式:

plt.subplot(221) #要生成两行两列,这是第一个图plt.subplot('行','列','编号')

其中,编号遵循---行优先!


image.png

生成numpy数组nadarray

  1. 生成随机数组:
    arr = np.random.normal(size=100)
  2. 使用列表list转化成numpy:
data=data.split('\t') #data是一行用回车符分隔的字符串,转化成列表
for 
data=np.array(data)

np.linspace

numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None)

在指定的间隔内返回均匀间隔的数字。

返回num均匀分布的样本,在[start, stop]。

这个区间的端点可以任意的被排除在外。(endpoint=False)

>>>
>>> np.linspace(2.0, 3.0, num=5)
    array([ 2.  ,  2.25,  2.5 ,  2.75,  3.  ])
>>> np.linspace(2.0, 3.0, num=5, endpoint=False)
    array([ 2. ,  2.2,  2.4,  2.6,  2.8])
>>> np.linspace(2.0, 3.0, num=5, retstep=True)
    (array([ 2.  ,  2.25,  2.5 ,  2.75,  3.  ]), 0.25)
原文链接:https://blog.csdn.net/you_are_my_dream/article/details/53493752

相关文章

网友评论

      本文标题:使用pyplot绘制cdf图

      本文链接:https://www.haomeiwen.com/subject/lcdipctx.html