import numpy as np
import pylab as pl
import noise

nrow = 100
size = 4
x = y = np.linspace(0, size, nrow)
n = [[noise.pnoise2(i, j, repeatx=size, repeaty=size) for j in y] for i in x]
m = np.concatenate(n)
sorted_idx = np.argsort(m)
max_val = nrow * 2
idx = len(m) // max_val
for ii, val in enumerate(range(max_val)):
    m[sorted_idx[ii * idx:(ii + 1) * idx]] = val
landscape = (m - nrow) / nrow

pl.hist(landscape, bins=np.arange(-1, 1.01, 0.01))

pl.matshow(landscape.reshape(nrow, -1), vmin=-1, vmax=1)
pl.colorbar()

pl.show()