In [23]:
class ECDF(object):

    def __init__(self, observations):
        self.observations = observations

    def __call__(self, x):
        counter = 0.0
        for i in range(len(self.observations)):
            if self.observations[i] <= x:
                counter += 1
        return counter / len(self.observations)

In [24]:
from random import uniform
samples = [uniform(0, 1) for i in range(10)]
F = ECDF(samples)

print(F(0.5))  # Evaluate ecdf at x = 0.5


0.5

In [19]:
ecdf = ECDF(3)

In [20]:
ecdf.renshu(5)


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-20-1d8d0537bcc2> in <module>()
----> 1 ecdf.renshu(5)

AttributeError: 'ECDF' object has no attribute 'renshu'

In [17]:
ecdf.renshu2()


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-17-0f1541af2830> in <module>()
----> 1 ecdf.renshu2()

<ipython-input-14-0010cbfe6864> in renshu2(self)
      9 
     10     def renshu2(self):
---> 11         print(observations)

NameError: name 'observations' is not defined

In [ ]: