MLSC.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:nanopores 作者: mitschabaude 项目源码 文件源码
def hplot(name, h, err, xlab="", ylab="", hstr="h", rate=None, fit=True, fig=True):
    from matplotlib.pyplot import figure, loglog, xlabel, ylabel, legend, show
    if fig is True:
        figure()
    loglog(h, err, 's-', label=name)
    if fit:
        p = numpy.polyfit(numpy.log(h), numpy.log(err), 1)
        C = numpy.exp(p[1])
        alpha = p[0]
        alg = [C*n**alpha for n in h]
        loglog(h, alg, '--', label="%.3f*%s^(%.3f)" %(C, hstr, alpha))
    if rate and h[0] != 0:
        alg = [err[0]/(h[0]**rate)*n**rate for n in h]
        loglog(h, alg, '--', label="%s^(%.3f)" %(hstr, rate))
    xlabel(xlab)
    ylabel(ylab)
    legend(loc='best')

# --- create interpolation for different h and orders ---
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号