HW2.py 文件源码

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

项目:Stochastic-Processes 作者: vincentlaucsb 项目源码 文件源码
def emp_cdf(samples,x):
    ''' Indicator Function for Empirical Distribution:
        1: if X_i <= x
        0: otherwise

        sample = X_i
    '''
    def indicator(sample):
        # Note: This function will grab the value of "x" from the scope of the parent function.
        if sample <= x: return 1
        else: return 0
    sigma = 0
    n = len(samples)

    for X_i in samples:
        sigma += indicator(X_i)
    return (1/n) * sigma

# Function is a string with a matematical expression, e.g. function='x+5'
# Input: function is a f: R --> R
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号