def randomModel(shape, seed=None, anisotropy=None, its=100, bounds=[0,1]):

    if seed is None:
        seed = np.random.randint(1e3)
        print 'Using a seed of: ', seed

    if type(shape) in [int, long, float]:
        shape = (shape,) # make it a tuple for consistency

    np.random.seed(seed)
    mr = np.random.rand(*shape)
    if anisotropy is None:
        if len(shape) is 1:
            smth = np.array([1,10.,1],dtype=float)
        elif len(shape) is 2:
            smth = np.array([[1,7,1],[2,10,2],[1,7,1]],dtype=float)
        elif len(shape) is 3:
            kernal = np.array([1,4,1], dtype=float).reshape((1,3))
            smth = np.array(sp.kron(sp.kron(kernal,kernal.T).todense()[:],kernal).todense()).reshape((3,3,3))
    else:
        assert len(anisotropy.shape) is len(shape), 'Anisotropy must be the same shape.'
        smth = np.array(anisotropy,dtype=float)

    smth = smth/smth.sum() # normalize
    mi = mr
    for i in range(its):
        mi = ndi.convolve(mi, smth)

    # scale the model to live between the bounds.
    mi = (mi - mi.min())/(mi.max()-mi.min()) # scaled between 0 and 1
    mi = mi*(bounds[1]-bounds[0])+bounds[0]


    return mi
Create a random model by convolving a kernel with a
dataset/ETHPy150Open simpeg/simpeg/SimPEG/Utils/ModelBuilder.py/randomModel