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
评论列表
文章目录