In [69]:
%matplotlib inline
import numpy as np
from matplotlib import pyplot as plt

from math import ceil, log
from numpy.random import random
from scipy.ndimage.interpolation import zoom

# 2d 1/f noise in the range -1, 1
def scaling_noise(shape):
    (h,w) = shape
    T = np.zeros(shape,np.float)
    p = ceil(log(max(shape),2))
    for scale in np.arange(1,p+1)**2:
        noise = np.random.normal(size=(scale,scale))
        T += (zoom(noise,(2**p)/scale,order=1) / scale)[:h,:w]
    return T

n=300
N = scaling_noise((n,n))
plt.imshow(N**2,cmap='terrain')


Out[69]:
<matplotlib.image.AxesImage at 0x7fa7efe3c890>

In [48]:
X, Y = np.mgrid[0:n,0:n]

In [70]:
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure(figsize=(10,10))
ax = fig.gca(projection='3d')
ax.plot_surface(X, Y, N**2, linewidth=0, cmap='terrain')
ax.set_zlim(-2, 2)


Out[70]:
(-2, 2)