The Chaos Game and Benford's law: will I notice the bias?

142 Views Asked by At

If I construct a Sierpinsky Gasket using The Chaos Game algorithm, but the random data I am using to decide the vertex of the next step is ruled by Benford's law (so it is partially biased), how would I notice that bias when looking at the Sierpinski Gasket?

enter image description here (credit of the image to Wikipedia)

An excerpt from Wikipedia:

Benford's law, also called the first-digit law, is an observation about the frequency distribution of leading digits in many real-life sets of numerical data. The law states that in many naturally occurring collections of numbers, the leading significant digit is likely to be small. For example, in sets which obey the law, the number $1$ appears as the most significant digit about $30$% of the time, while $9$ appears as the most significant digit less than $5$% of the time.

So if I am deciding the next vertex by taking the first digit of a random number that belongs to a set of numerical data under Bendfor's law, will I notice the bias when looking at the Sierpinsky Gasket?

My intuition is that we would see more points near one of the vertices. For instance if the digit obtained from our "random" set is $1,2,3$ then the next vertex is $V_1$, if $4,5,6$ then $V_2$ and in other case $V_3$. In the example I am writing, there would be more points near $V_1$ due to the bias of Benford's law.

Is this correct? thank you!

1

There are 1 best solutions below

4
On BEST ANSWER

Yes, you'll notice it!
https://www.openprocessing.org/sketch/445696

Source code for posterity:

function setup() {
  createCanvas(windowWidth, windowHeight);
  background(255);
  stroke(0);
  speed = 100;

  // Set up the triangle
  radius = min(windowWidth, windowHeight) / 2;
  cx = windowWidth / 2;
  cy = windowHeight / 2;
  v1x = cx + radius * cos(0);
  v1y = cy + radius * sin(0);
  v2x = cx + radius * cos(2 * PI / 3);
  v2y = cy + radius * sin(2 * PI / 3);
  v3x = cx + radius * cos(4 * PI / 3);
  v3y = cy + radius * sin(4 * PI / 3);

  // Probabilities
  // https://en.wikipedia.org/wiki/Benford's_law#Mathematical_statement
  p123 = (log(1+1) + log(1+1/2) + log(1+1/3)) / log(10);
  p123456 = p123 + (log(1+1/4) + log(1+1/5) + log(1+1/6)) / log(10);

  // Current point
  px = v1x;
  py = v1y;
}

function draw() {
  for (i = 0; i < speed; ++i) {
    r = random(1);
    if (r < p123) {
      px = (px + v1x) / 2;
      py = (py + v1y) / 2;
    } else if (r < p123456) {
      px = (px + v2x) / 2;
      py = (py + v2y) / 2;
    } else {
      px = (px + v3x) / 2;
      py = (py + v3y) / 2;
    }

    point(px, py);
  }
}