title: Empirical cdf in python similiar to matlab's one
body: <p>I have some code in matlab, that I would like to rewrite into python. It's simple program, that computes some distribution and plot it in double-log scale.</p>
  
  <p>The problem I occured is with computing cdf. Here is matlab code:</p>
  
  <pre><code>for D = 1:10
      delta = D / 10;
      for k = 1:n
          N_delta = poissrnd(delta^-alpha,1);
          Y_k_delta = ( (1 - randn(N_delta)) / (delta.^alpha) ).^(-1/alpha);
          Y_k_delta = Y_k_delta(Y_k_delta &gt; delta);
          X(k) = sum(Y_k_delta);
          %disp(X(k))
  
      end
      [f,x] = ecdf(X);
  
      plot(log(x), log(1-f))
      hold on
  end
  </code></pre>
  
  <p>In matlab one I can simply use:</p>
  
  <pre><code>[f,x] = ecdf(X);
  </code></pre>
  
  <p>to get cdf (f) at points x. <a href="http://www.mathworks.com/help/stats/ecdf.html" rel="nofollow noreferrer">Here</a> is documentation for it.<br>
  In python it is more complicated:</p>
  
  <pre><code>import numpy as np
  from scipy.stats import norm
  import matplotlib.pyplot as plt
  from statsmodels.distributions.empirical_distribution import ECDF
  
  alpha = 1.5
  n = 1000
  X = []
  for delta in range(1,5):
      delta = delta/10.0
      for k in range(1,n + 1):
          N_delta = np.random.poisson(delta**(-alpha), 1)
          Y_k_delta = ( (1 - np.random.random(N_delta)) / (delta**alpha) )**(-1/alpha)
          Y_k_delta = [i for i in Y_k_delta if i &gt; delta]
          X.append(np.sum(Y_k_delta))
  
      ecdf = ECDF(X)
  
      x = np.linspace(min(X), max(X))
      f = ecdf(x)
      plt.plot(np.log(f), np.log(1-f))
  
  plt.show()
  </code></pre>
  
  <p>It makes my plot look very strange, definetly not smooth as matlab's one.<br>
  I think the problem is that I do not understand <code>ECDF</code> function or it works differently than in matlab.<br>
  I implemented <a href="https://stackoverflow.com/questions/3209362/how-to-plot-empirical-cdf-in-matplotlib-in-python">this</a> solution (the most points one) for my python code, but it looks like it doesn't work correctly.</p>