bam_accuracy.py 文件源码

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

项目:wub 作者: nanoporetech 项目源码 文件源码
def estimate_mode(acc):
    """ Estimate the mode of a set of float values between 0 and 1.

    :param acc: Data.
    :returns: The mode of the sample
    :rtype: float
    """
    # Taken from sloika.
    if len(acc) > 1:
        da = gaussian_kde(acc)
        optimization_result = minimize_scalar(lambda x: -da(x), bounds=(0, 1), method='Bounded')
        if optimization_result.success:
            try:
                mode = optimization_result.x[0]
            except IndexError:
                mode = optimization_result.x
        else:
            sys.stderr.write("Mode computation failed")
            mode = 0
    else:
        mode = acc[0]
    return mode
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号