title: Apply a function to numpy array in Python
body: <p>I am trying to apply a function to every element of numpy array along with few parameters. </p>
  
  <pre><code>def wcdf(u, A, k):
      if(u &gt; 0):
          y=(1 - np.exp(-(u/A)**(k)));
          return y
      else:
          return(0)
  </code></pre>
  
  <p>I don't know what I am missing but whenever array has a <code>0</code> it returns <code>0</code> for every element.</p>
  
  <pre><code>f=np.vectorize(wcdf)
  u=f(np.array([1,2]),10,2);
  print(u)
  </code></pre>
  
  <blockquote>
    <p>Result : [ 0.00995017  0.03921056]</p>
  </blockquote>
  
  <p>The above works fine, but when I have a zero then:</p>
  
  <pre><code>u=f(np.array([0,2]),10,2);
  print(u)
  </code></pre>
  
  <blockquote>
    <p>Result : [0 0]</p>
  </blockquote>
  
  <p>Can somebody point out what am I doing wrong!!!!</p>
  
  <p>Thanks</p>