arr.py 文件源码

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

项目:cebl 作者: idfah 项目源码 文件源码
def punion(probs, axis=None):
    """Find the unions of given list of probabilities assuming indepdendence.

    Args:
        probs:  Matrix-like probabilities to union.

        axis:   Axis along which union will be performed.

    Returns:
        Matrix of probability unions.
    """
    def punion1d(probs):
        """Union for 1d array.
        """
        finalp = 0.0
        for p in probs:
            finalp += p*(1.0-finalp)
        return finalp

    probs = np.asarray(probs)

    if axis is None:
        return punion1d(probs.reshape((-1,)))
    else:
        return np.apply_along_axis(func1d=punion1d, axis=axis, arr=probs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号