gauss_1D.py 文件源码

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

项目:scipyplot 作者: robertocalandra 项目源码 文件源码
def set_data(self, y, variance, x=None):
        """
        update a gauss_1D with new data
        :param y: 
        :param variance: 
        :param x: 
        :return: 
        """
        n_points = len(y)
        if x is None:
            x = np.arange(n_points)
        self._handle.set_data(x, y)  # Update mean
        new_percentiles = []
        out = self.distribution.split("+")
        n_percentiles = len(out)
        sub_alpha = str(self.alpha / n_percentiles)  # Normalize w.r.t. the number of percentiles
        for i, percentile in enumerate(self._percentiles):
            percentile.remove()
            percentile = float(out[i])
            assert 0 <= percentile <= 100, 'Percentile must be >0 & <100. Instead is %f' % percentile
            interval = scipy.stats.norm.interval(percentile/100, loc=y, scale=np.sqrt(variance))
            interval = np.nan_to_num(interval)  # Fix stupid case of norm.interval(0) returning nan
            new_percentiles.append(plt.fill_between(x, interval[0], interval[1], color=self._handle.get_color(), alpha=sub_alpha))
        #       TODO: not implemented yet
        pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号