Changes between Version 1 and Version 2 of libpipi/sandbox


Ignore:
Timestamp:
10/22/2008 12:57:42 PM (16 years ago)
Author:
Sam Hocevar
Comment:

Cantor polynomial

Legend:

Unmodified
Added
Removed
Modified
  • libpipi/sandbox

    v1 v2  
     1== Numbering tiles ==
     2
     3If we want a straightforward way to linearly index tiles without necessarily knowing the image size, we can use the following enumeration:
     4
     5|| 0 || 1 || 3 || 6 || 10 || 15 || 21 ||
     6|| 2 || 4 || 7 || 11 || 16 || 22 || 29 ||
     7|| 5 || 8 || 12 || 17 || 23 || 30 || 38 ||
     8|| 9 || 13 || 18 || 24 || 31 || 39 || … ||
     9|| 14 || 19 || 25 || 32 || 40 || … || ||
     10|| 20 || 26 || 33 || 41 || … || || ||
     11|| 27 || 34 || 42 || … || || || ||
     12
     13One way to generate these values is using the '''Cantor polynomial''':
    114{{{
    215#!latex
    3 $\mbox{Var}[\tau(X_p,X_d)] = \mbox{Var}[E(\tau(X_p,X_d)|X_p)] E[\mbox{Var}(\tau(X_p,X_d)|X_p)]$
     16$n = \dfrac{(x + y) (x + y + 1)}{2} + y$
    417}}}
     18
     19Efficiently inverting that polynomial is not trivial. Here is one way to do it:
     20{{{
     21#!latex
     22$k = E(\dfrac{\sqrt{8n+1}-1}{2})$
     23
     24$y = n - \dfrac{k (k + 1)}{2}$
     25
     26$x = k - y$
     27}}}