I was looking at multiplicative cascades and thinking of a method from "the fractal geometry of nature" by BB Mandelbrot. I would like a way of generating a set of points that have a certain dimension and lacunarity, and remember something similar to this in the book. This is the closest I can come up with.

The basic idea is to divide the unit square into a grid and randomly choose squares from it, the probability for each square being determined by dimension d:

(1)This is done recursively for each square selected.

The only way of varying the lacunarity that I can remember is to use finer grids per step (n). If anyone has a better way of doing this, let me know.

Also, is there a good definition of lacunarity? I think it was described as proportional to the maximum circle that could fit in the gaps and that doesn't contain any points of the set (averaged across all possible seeds for generating the set).

I would attach an output image (and add it to Fractal to illustrate dimension), but I do not have a flikr account.

Python, with Python Image Library for image stuff:

```
import random
import math
import PIL.Image
import PIL.ImageFilter
#seed the random generator for repeatable output
seed = 42
rng = random.Random(seed)
def expand(image,
dimension,
n_per_level=2):
'''expand the image by n_per_level, adding detail
'''
p_per_pixel = (n_per_level ** dimension)/(n_per_level ** 2)
#note: using a filter when scaling (such as BILINEAR or BICUBIC) removes
# artifacts along division edges, if care is taken the output is seamless and tileable.
# for the sake of brevity, these are removed.
#scale the image
output = image.resize(
(image.size[0]*n_per_level,
image.size[1]*n_per_level))
#add detail
pixels = output.load()
for i in range(output.size[0]):
for j in range(output.size[1]):
#black are the points of the set
value = 1 - pixels[i,j] / 255.
p = p_per_pixel * value
if rng.random() < p:
pixels[i,j] = 0
else:
pixels[i,j] = 255.
return output
#start with one black pixel, greyscale image
image = PIL.Image.new('L',(1,1))
dimension = 1.5
#expand the image 'till it's big enough
while image.size[0] < 1024:
image = expand(image, dimension)
image.show()
image.save('fractal%d_%d.png' % (dimension*100,seed))
```