[Python] Empirical Distribution Function in Numpy

Discussão em 'Python' iniciado por Stack, Abril 5, 2025.

  1. Stack

    Stack Membro Participativo

    I have the following list of values:

    x = [-0.04124324405924407, 0, 0.005249724476788287, 0.03599351958245578, -0.00252785423151014, 0.01007584102031178, -0.002510349639322063,...]


    and I want to calculate the empirical density function, so I think I need to calculate the empirical cumulative distribution function and I've used this code:

    counts = np.asarray(np.bincount(x), dtype=float)
    cdf = counts.cumsum() / counts.sum()


    and then I calculate this value:

    print cdf[0.01007584102031178]


    and I always get 1 so I guess I made a mistake. Do you know how to fix it? Thanks!

    Continue reading...

Compartilhe esta Página