title: Python: Replace every value in a NumPy array with a similar one
body: <p>Consider the following random function which returns nearly the same number it received (it returns a sample from the Gaussian distribution with mean <code>x</code> and standard deviation of 0.001 * <code>x</code>):</p>
  
  <pre><code>def similar(x, rel_std=0.001):
      sigma = rel_std * x
      mu = x
      return sigma * np.random.randn() + mu
  </code></pre>
  
  <p>So for example:</p>
  
  <pre><code>&gt; print(similar(1.0))
  0.99946018
  </code></pre>
  
  <p>This function seems to be applicable to arrays of arbitrary shape:</p>
  
  <pre><code>&gt; ones = np.ones(5)
  &gt; print(similar(ones))
  [0.99946018 0.99946018 0.99946018 0.99946018 0.99946018]
  
  &gt; example = np.array([[[6,7,8,9,10],[-1,-2,-3,-4,-5]],[[1,2,3,4,5], [-2,-1,0,1,2]]])
  &gt; print(similar(example))
  [[[ 6.00610123  7.0071181   8.00813497  9.00915185 10.01016872]
    [-1.00101687 -2.00203374 -3.00305062 -4.00406749 -5.00508436]]
  
   [[ 1.00101687  2.00203374  3.00305062  4.00406749  5.00508436]
    [-2.00203374 -1.00101687  0.          1.00101687  2.00203374]]]
  </code></pre>
  
  <p>However, as you might have noticed, it does not use for every cell a new random seed. What I am looking for is a function which uses randomness for <em>every</em> cell of an <em>arbitrarily</em> shaped NumPy array. Since the shape may be of any kind, I think nested <code>for</code>-loops are not usable.</p>
  
  <p>An additional requirement is that the approach should work reasonably fast even for arrays of shape (1024, 1024).
  Is there a way of writing a fast (e. g. by vectorizing) function performing the mentioned task?</p>
  
  <p>EDIT: I don't mind to change the definition of <code>similar</code>, or to use a function of different interface – as long as the suggestion fits the purpose of producing a »similar« matrix.</p>